From 896c705979398b8ab88e98e96194ba61f5245a5b Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 12 Jun 2013 23:36:34 +0000 Subject: [PATCH] [UPDATE] Change function list xml structure (minor). [BUG_FIXED] Fix a function list bug about comment. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1058 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../FunctionList/functionParser.cpp | 60 +++++++++---------- .../WinControls/FunctionList/functionParser.h | 6 +- PowerEditor/src/functionList.xml | 22 +++---- 3 files changed, 40 insertions(+), 48 deletions(-) diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp index 448ab6ef..36a53417 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp @@ -56,12 +56,11 @@ bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** p return loadOkay; } -bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &commentExprStr, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector &classNameExprArray, generic_string &functionExprStr, std::vector &functionNameExprArray) +bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector &classNameExprArray, generic_string &functionExprStr, std::vector &functionNameExprArray) { const TCHAR *mainExpr = NULL; const TCHAR *openSymbole = NULL; const TCHAR *closeSymbole = NULL; - const TCHAR *commentExpr = NULL; const TCHAR *functionExpr = NULL; mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr")); @@ -77,14 +76,6 @@ bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, if (closeSymbole && closeSymbole[0]) closeSymboleStr = closeSymbole; - TiXmlNode *commentSymbols = classRangeParser->FirstChild(TEXT("comment")); - if (commentSymbols) - { - commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr")); - if (commentExpr) - commentExprStr = commentExpr; - } - TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className")); if (classNameParser) { @@ -123,22 +114,13 @@ bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, return true; } -bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &commentExprStr, generic_string &mainExprStr, std::vector &functionNameExprArray, std::vector &classNameExprArray) +bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector &functionNameExprArray, std::vector &classNameExprArray) { - const TCHAR *commentExpr = NULL; const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr")); if (!mainExpr || !mainExpr[0]) return false; mainExprStr = mainExpr; - TiXmlNode *commentSymbols = functionParser->FirstChild(TEXT("comment")); - if (commentSymbols) - { - commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr")); - if (commentExpr && commentExpr[0]) - commentExprStr = commentExpr; - } - TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName")); if (functionNameParser) { @@ -194,6 +176,12 @@ bool FunctionParsersManager::getFuncListFromXmlTree() if (!id || !id[0]) continue; + generic_string commentExpr(TEXT("")); + const TCHAR *pCommentExpr = (childNode->ToElement())->Attribute(TEXT("commentExpr")); + if (pCommentExpr && pCommentExpr[0]) + commentExpr = pCommentExpr; + + std::vector classNameExprArray; std::vector functionNameExprArray; @@ -205,27 +193,27 @@ bool FunctionParsersManager::getFuncListFromXmlTree() TiXmlNode *functionParser = childNode->FirstChild(TEXT("function")); if (classRangeParser && functionParser) { - generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr; - getZonePaserParameters(classRangeParser, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray); + generic_string mainExpr, openSymbole, closeSymbole, functionExpr; + getZonePaserParameters(classRangeParser, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray); - generic_string commentExpr2, mainExpr2; + generic_string mainExpr2; std::vector classNameExprArray2; std::vector functionNameExprArray2; - getUnitPaserParameters(functionParser, commentExpr2, mainExpr2, functionNameExprArray2, classNameExprArray2); - FunctionUnitParser *funcUnitPaser = new FunctionUnitParser(id, displayName, commentExpr2.c_str(), mainExpr2.c_str(), functionNameExprArray2, classNameExprArray2); + getUnitPaserParameters(functionParser, mainExpr2, functionNameExprArray2, classNameExprArray2); + FunctionUnitParser *funcUnitPaser = new FunctionUnitParser(id, displayName, commentExpr.c_str(), mainExpr2.c_str(), functionNameExprArray2, classNameExprArray2); _parsers.push_back(new FunctionMixParser(id, displayName, commentExpr.c_str(), mainExpr.c_str(), openSymbole.c_str(), closeSymbole.c_str(), classNameExprArray, functionExpr.c_str(), functionNameExprArray, funcUnitPaser)); } else if (classRangeParser) { - generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr; - getZonePaserParameters(classRangeParser, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray); + generic_string mainExpr, openSymbole, closeSymbole, functionExpr; + getZonePaserParameters(classRangeParser, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray); _parsers.push_back(new FunctionZoneParser(id, displayName, commentExpr.c_str(), mainExpr.c_str(), openSymbole.c_str(), closeSymbole.c_str(), classNameExprArray, functionExpr.c_str(), functionNameExprArray)); } else if (functionParser) { - generic_string commentExpr, mainExpr; - getUnitPaserParameters(functionParser, commentExpr, mainExpr, functionNameExprArray, classNameExprArray); + generic_string mainExpr; + getUnitPaserParameters(functionParser, mainExpr, functionNameExprArray, classNameExprArray); _parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr.c_str(), mainExpr.c_str(), functionNameExprArray, classNameExprArray)); } } @@ -281,7 +269,7 @@ FunctionParser * FunctionParsersManager::getParser(generic_string ext) return NULL; } -void FunctionParser::funcParse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName) +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) return; @@ -343,7 +331,15 @@ void FunctionParser::funcParse(std::vector & foundInfos, size_t begi if (fi._pos != -1 || fi._pos2 != -1) // at least one should be found { - foundInfos.push_back(fi); + if (commentZones != NULL) + { + if (!isInZones(fi._pos, *commentZones) && !isInZones(fi._pos2, *commentZones)) + foundInfos.push_back(fi); + } + else + { + foundInfos.push_back(fi); + } } begin = targetStart + foundTextLen; @@ -519,7 +515,7 @@ void FunctionZoneParser::classParse(vector & foundInfos, vector< pair //vector< generic_string > emptyArray; if (!isInZones(targetStart, commentZones)) { - funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName); + funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName, &commentZones); } begin = targetStart + (targetEnd - targetStart); targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end); diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.h b/PowerEditor/src/WinControls/FunctionList/functionParser.h index 4f21fbe8..78f0ae23 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.h +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.h @@ -47,7 +47,7 @@ public: _id(id), _displayName(displayName), _commentExpr(commentExpr?commentExpr:TEXT("")), _functionExpr(functionExpr), _functionNameExprArray(functionNameExprArray), _classNameExprArray(classNameExprArray){}; virtual void parse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT("")) = 0; - void funcParse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT("")); + void funcParse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""), const std::vector< std::pair > * commentZones = NULL); bool isInZones(int pos2Test, const std::vector< std::pair > & zones); protected: generic_string _id; @@ -133,8 +133,8 @@ private: TiXmlDocument *_pXmlFuncListDoc; bool getFuncListFromXmlTree(); - bool getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &commentExprStr, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector &classNameExprArray, generic_string &functionExprStr, std::vector &functionNameExprArray); - bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &commentExprStr, generic_string &mainExprStr, std::vector &functionNameExprArray, std::vector &classNameExprArray); + 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); }; diff --git a/PowerEditor/src/functionList.xml b/PowerEditor/src/functionList.xml index 354dfbb3..2bd18707 100644 --- a/PowerEditor/src/functionList.xml +++ b/PowerEditor/src/functionList.xml @@ -24,13 +24,12 @@ - + - @@ -45,14 +44,13 @@ - + - - - + + @@ -76,13 +74,12 @@ - + - @@ -97,12 +94,11 @@ - - - + +