[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
This commit is contained in:
parent
874d5605c4
commit
896c705979
@ -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<generic_string> &classNameExprArray, generic_string &functionExprStr, std::vector<generic_string> &functionNameExprArray)
|
||||
bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector<generic_string> &classNameExprArray, generic_string &functionExprStr, std::vector<generic_string> &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<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray)
|
||||
bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &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<generic_string> classNameExprArray;
|
||||
std::vector<generic_string> 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<generic_string> classNameExprArray2;
|
||||
std::vector<generic_string> 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<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName, const std::vector< std::pair<int, int> > * commentZones)
|
||||
{
|
||||
if (begin >= end)
|
||||
return;
|
||||
@ -343,8 +331,16 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
||||
|
||||
if (fi._pos != -1 || fi._pos2 != -1) // at least one should be found
|
||||
{
|
||||
if (commentZones != NULL)
|
||||
{
|
||||
if (!isInZones(fi._pos, *commentZones) && !isInZones(fi._pos2, *commentZones))
|
||||
foundInfos.push_back(fi);
|
||||
}
|
||||
else
|
||||
{
|
||||
foundInfos.push_back(fi);
|
||||
}
|
||||
}
|
||||
|
||||
begin = targetStart + foundTextLen;
|
||||
targetStart = (*ppEditView)->searchInTarget(_functionExpr.c_str(), _functionExpr.length(), begin, end);
|
||||
@ -519,7 +515,7 @@ void FunctionZoneParser::classParse(vector<foundInfo> & 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);
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
_id(id), _displayName(displayName), _commentExpr(commentExpr?commentExpr:TEXT("")), _functionExpr(functionExpr), _functionNameExprArray(functionNameExprArray), _classNameExprArray(classNameExprArray){};
|
||||
|
||||
virtual void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT("")) = 0;
|
||||
void funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
void funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""), const std::vector< std::pair<int, int> > * commentZones = NULL);
|
||||
bool isInZones(int pos2Test, const std::vector< std::pair<int, int> > & 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<generic_string> &classNameExprArray, generic_string &functionExprStr, std::vector<generic_string> &functionNameExprArray);
|
||||
bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &commentExprStr, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray);
|
||||
bool getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector<generic_string> &classNameExprArray, generic_string &functionExprStr, std::vector<generic_string> &functionNameExprArray);
|
||||
bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray);
|
||||
FunctionParser * getParser(generic_string ext);
|
||||
FunctionParser * getParser(int langID);
|
||||
};
|
||||
|
@ -24,13 +24,12 @@
|
||||
|
||||
</associationMap>
|
||||
<parsers>
|
||||
<parser id="cpp_class" displayName="C++ Class">
|
||||
<parser id="cpp_class" displayName="C++ Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||
<classRange
|
||||
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
||||
openSymbole = "\{"
|
||||
closeSymbole = "\}"
|
||||
displayMode="node">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<className>
|
||||
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
||||
<nameExpr expr="[\t ]+[\w]+"/>
|
||||
@ -45,14 +44,13 @@
|
||||
</function>
|
||||
</classRange>
|
||||
</parser>
|
||||
<parser id="c_function" displayName="C source">
|
||||
<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_~]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<functionName>
|
||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~]+"/>
|
||||
<nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|while|for))[\w_~]+"/>
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||
@ -76,13 +74,12 @@
|
||||
</parser>
|
||||
|
||||
|
||||
<parser id="c_cpp_function" displayName="C++ Class">
|
||||
<parser id="c_cpp_function" displayName="C++ Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||
<classRange
|
||||
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
||||
openSymbole = "\{"
|
||||
closeSymbole = "\}"
|
||||
displayMode="node">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<className>
|
||||
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
||||
<nameExpr expr="[\t ]+[\w]+"/>
|
||||
@ -97,12 +94,11 @@
|
||||
</function>
|
||||
</classRange>
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?([\w]+([\s]+|(\*|&)[\s]+|[\s]+(\*|&)|[\s]+(\*|&)[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~\+\*\-=\!]+[\s]*\([^\)\(]*\)([\s]*(const|(:[^\{]+))[\s]*)?[\n\s]*\{"
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<functionName>
|
||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~\+\*\-=\!]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~\+\*\-=\!]+"/>
|
||||
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||
|
Loading…
Reference in New Issue
Block a user