diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 8304ff335..f5fa4c389 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -195,8 +195,15 @@ void FunctionListPanel::reload() const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); LangType langID = ((*_ppEditView)->getCurrentBuffer())->getLangType(); + const TCHAR *udln = NULL; + if (langID == L_USER) + { + udln = ((*_ppEditView)->getCurrentBuffer())->getUserDefineLangName(); + } + TCHAR *ext = ::PathFindExtension(fn); - if (_funcParserMgr.parse(fi, langID) || _funcParserMgr.parse(fi, ext)) + + if (_funcParserMgr.parse(fi, AssociationInfo(-1, langID, ext, udln))) { _treeView.addItem(fn, NULL, INDEX_ROOT, TEXT("-1")); } diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp index d69444b81..1f7f688de 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp @@ -229,13 +229,14 @@ bool FunctionParsersManager::getFuncListFromXmlTree() const TCHAR *langIDStr = (childNode->ToElement())->Attribute(TEXT("langID"), &langID); const TCHAR *exts = (childNode->ToElement())->Attribute(TEXT("ext")); const TCHAR *id = (childNode->ToElement())->Attribute(TEXT("id")); - if ((langIDStr || (exts && exts[0])) && (id && id[0])) + const TCHAR *userDefinedLangName = (childNode->ToElement())->Attribute(TEXT("userDefinedLangName")); + if (((langIDStr && langIDStr[0]) || (exts && exts[0]) || (userDefinedLangName && userDefinedLangName[0])) && (id && id[0])) { for (size_t i = 0, len = _parsers.size(); i < len; ++i) { if (_parsers[i]->_id == id) { - _associationMap.push_back(AssociationInfo(i, langID, exts?exts:TEXT(""))); + _associationMap.push_back(AssociationInfo(i, langIDStr?langID:-1, exts?exts:TEXT(""), userDefinedLangName?userDefinedLangName:TEXT(""))); break; } } @@ -246,29 +247,57 @@ bool FunctionParsersManager::getFuncListFromXmlTree() return (_parsers.size() != 0); } -FunctionParser * FunctionParsersManager::getParser(int langID) +FunctionParser * FunctionParsersManager::getParser(const AssociationInfo & assoInfo) { - for (size_t i = 0, len = _associationMap.size(); i < len; ++i) - { - if (langID == _associationMap[i]._langID) - return _parsers[_associationMap[i]._id]; - } - return NULL; -} - -FunctionParser * FunctionParsersManager::getParser(generic_string ext) -{ - if (ext == TEXT("")) + const unsigned char doNothing = 0; + const unsigned char checkLangID = 1; + const unsigned char checkUserDefined = 2; + const unsigned char checkExt = 3; + + unsigned char choice = doNothing; + // langID != -1 && langID != L_USER + if (assoInfo._langID != -1 && assoInfo._langID != L_USER) + choice = checkLangID; + // langID == L_USER, we chack the userDefinedLangName + else if (assoInfo._langID == L_USER && assoInfo._userDefinedLangName != TEXT("")) + choice = checkUserDefined; + // langID == -1, we chack the ext + else if (assoInfo._langID == -1 && assoInfo._ext != TEXT("")) + choice = checkExt; + else return NULL; for (size_t i = 0, len = _associationMap.size(); i < len; ++i) { - if (ext == _associationMap[i]._ext) - return _parsers[_associationMap[i]._id]; + switch (choice) + { + case checkLangID: + { + if (assoInfo._langID == _associationMap[i]._langID) + return _parsers[_associationMap[i]._id]; + } + break; + + case checkUserDefined: + { + if (assoInfo._userDefinedLangName == _associationMap[i]._userDefinedLangName) + return _parsers[_associationMap[i]._id]; + } + break; + + case checkExt: + { + if (assoInfo._ext == _associationMap[i]._ext) + return _parsers[_associationMap[i]._id]; + } + break; + + } } return NULL; } + void FunctionParser::funcParse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName, const std::vector< std::pair > * commentZones) { if (begin >= end) @@ -387,13 +416,13 @@ generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vect } } -bool FunctionParsersManager::parse(std::vector & foundInfos, int langID) +bool FunctionParsersManager::parse(std::vector & foundInfos, const AssociationInfo & assoInfo) { if (!_pXmlFuncListDoc) return false; // Serch the right parser from the given ext in the map - FunctionParser *fp = getParser(langID); + FunctionParser *fp = getParser(assoInfo); if (!fp) return false; @@ -404,24 +433,6 @@ bool FunctionParsersManager::parse(std::vector & foundInfos, int lang return true; } -bool FunctionParsersManager::parse(std::vector & foundInfos, generic_string ext) -{ - if (!_pXmlFuncListDoc) - return false; - - // Serch the right parser from the given ext in the map - FunctionParser *fp = getParser(ext); - if (!fp) - return false; - - // parse - int docLen = (*_ppEditView)->getCurrentDocLen(); - fp->parse(foundInfos, 0, docLen, _ppEditView); - - return true; -} - - size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, ScintillaEditView **ppEditView) { size_t cntOpen = 1; diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.h b/PowerEditor/src/WinControls/FunctionList/functionParser.h index 78f0ae23c..f90f963a1 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.h +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.h @@ -114,8 +114,19 @@ struct AssociationInfo { int _id; int _langID; generic_string _ext; - - AssociationInfo(int id, int langID, const TCHAR *ext): _id(id), _langID(langID), _ext(ext){}; + generic_string _userDefinedLangName; + + AssociationInfo(int id, int langID, const TCHAR *ext, const TCHAR *userDefinedLangName): _id(id), _langID(langID) { + if (ext) + _ext = ext; + else + _ext = TEXT(""); + + if (userDefinedLangName) + _userDefinedLangName = userDefinedLangName; + else + _userDefinedLangName = TEXT(""); + }; }; class FunctionParsersManager { @@ -123,8 +134,7 @@ public: FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){}; ~FunctionParsersManager(); bool init(generic_string xmlPath, ScintillaEditView ** ppEditView); - bool parse(std::vector & foundInfos, int langID); - bool parse(std::vector & foundInfos, generic_string ext); + bool parse(std::vector & foundInfos, const AssociationInfo & assoInfo); private: ScintillaEditView **_ppEditView; @@ -135,8 +145,7 @@ private: bool getFuncListFromXmlTree(); bool getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector &classNameExprArray, generic_string &functionExprStr, std::vector &functionNameExprArray); bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector &functionNameExprArray, std::vector &classNameExprArray); - FunctionParser * getParser(generic_string ext); - FunctionParser * getParser(int langID); + FunctionParser * getParser(const AssociationInfo & assoInfo); }; #endif //FUNCTIONPARSER_H diff --git a/PowerEditor/src/functionList.xml b/PowerEditor/src/functionList.xml index 336e95f45..c6d664b86 100644 --- a/PowerEditor/src/functionList.xml +++ b/PowerEditor/src/functionList.xml @@ -14,17 +14,59 @@ L_CMAKE: 48 L_YAML: 49 L_COBOL 50 L_GUI4CLI: 51 L_D: 52 L_POWERSHELL: 53 L_R: 54 L_JSP: 55 --> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/src/langs.model.xml b/PowerEditor/src/langs.model.xml index cbf66ecab..43c67b023 100644 --- a/PowerEditor/src/langs.model.xml +++ b/PowerEditor/src/langs.model.xml @@ -158,7 +158,7 @@ cliprestore clipsave composefont currentsmoothness findcolorrendering setsmoothness shfill .begintransparencygroup .begintransparencymask .bytestring .charboxpath .currentaccuratecurves .currentblendmode .currentcurvejoin .currentdashadapt .currentdotlength .currentfilladjust2 .currentlimitclamp .currentopacityalpha .currentoverprintmode .currentrasterop .currentshapealpha .currentsourcetransparent .currenttextknockout .currenttexturetransparent .dashpath .dicttomark .discardtransparencygroup .discardtransparencymask .endtransparencygroup .endtransparencymask .execn .filename .filename .fileposition .forceput .forceundef .forgetsave .getbitsrect .getdevice .inittransparencymask .knownget .locksafe .makeoperator .namestring .oserrno .oserrorstring .peekstring .rectappend .runandhide .setaccuratecurves .setblendmode .setcurvejoin .setdashadapt .setdebug .setdefaultmatrix .setdotlength .setfilladjust2 .setlimitclamp .setmaxlength .setopacityalpha .setoverprintmode .setrasterop .setsafe .setshapealpha .setsourcetransparent .settextknockout .settexturetransparent .stringbreak .stringmatch .tempfile .type1decrypt .type1encrypt .type1execchar .unread arccos arcsin copydevice copyscanlines currentdevice finddevice findlibfile findprotodevice flushpage getdeviceprops getenv makeimagedevice makewordimagedevice max min putdeviceprops setdevice - + break continue do else elseif filter for foreach function if in return switch until where while add-content add-history add-member add-pssnapin clear-content clear-item clear-itemproperty clear-variable compare-object convertfrom-securestring convert-path convertto-html convertto-securestring copy-item copy-itemproperty export-alias export-clixml export-console export-csv foreach-object format-custom format-list format-table format-wide get-acl get-alias get-authenticodesignature get-childitem get-command get-content get-credential get-culture get-date get-eventlog get-executionpolicy get-help get-history get-host get-item get-itemproperty get-location get-member get-pfxcertificate get-process get-psdrive get-psprovider get-pssnapin get-service get-tracesource get-uiculture get-unique get-variable get-wmiobject group-object import-alias import-clixml import-csv invoke-expression invoke-history invoke-item join-path measure-command measure-object move-item move-itemproperty new-alias new-item new-itemproperty new-object new-psdrive new-service new-timespan new-variable out-default out-file out-host out-null out-printer out-string pop-location push-location read-host remove-item remove-itemproperty remove-psdrive remove-pssnapin remove-variable rename-item rename-itemproperty resolve-path restart-service resume-service select-object select-string set-acl set-alias set-authenticodesignature set-content set-date set-executionpolicy set-item set-itemproperty set-location set-psdebug set-service set-tracesource set-variable sort-object split-path start-service start-sleep start-transcript stop-process stop-service stop-transcript suspend-service tee-object test-path trace-command update-formatdata update-typedata where-object write-debug write-error write-host write-output write-progress write-verbose write-warning ac asnp clc cli clp clv cpi cpp cvpa diff epal epcsv fc fl foreach ft fw gal gc gci gcm gdr ghy gi gl gm gp gps group gsv gsnp gu gv gwmi iex ihy ii ipal ipcsv mi mp nal ndr ni nv oh rdr ri rni rnp rp rsnp rv rvpa sal sasv sc select si sl sleep sort sp spps spsv sv tee where write cat cd clear cp h history kill lp ls mount mv popd ps pushd pwd r rm rmdir echo cls chdir copy del dir erase move rd ren set type