[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;
|
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 *mainExpr = NULL;
|
||||||
const TCHAR *openSymbole = NULL;
|
const TCHAR *openSymbole = NULL;
|
||||||
const TCHAR *closeSymbole = NULL;
|
const TCHAR *closeSymbole = NULL;
|
||||||
const TCHAR *commentExpr = NULL;
|
|
||||||
const TCHAR *functionExpr = NULL;
|
const TCHAR *functionExpr = NULL;
|
||||||
|
|
||||||
mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr"));
|
mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||||
@ -77,14 +76,6 @@ bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser,
|
|||||||
if (closeSymbole && closeSymbole[0])
|
if (closeSymbole && closeSymbole[0])
|
||||||
closeSymboleStr = closeSymbole;
|
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"));
|
TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className"));
|
||||||
if (classNameParser)
|
if (classNameParser)
|
||||||
{
|
{
|
||||||
@ -123,22 +114,13 @@ bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser,
|
|||||||
return true;
|
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"));
|
const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||||
if (!mainExpr || !mainExpr[0])
|
if (!mainExpr || !mainExpr[0])
|
||||||
return false;
|
return false;
|
||||||
mainExprStr = mainExpr;
|
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"));
|
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||||
if (functionNameParser)
|
if (functionNameParser)
|
||||||
{
|
{
|
||||||
@ -194,6 +176,12 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
if (!id || !id[0])
|
if (!id || !id[0])
|
||||||
continue;
|
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> classNameExprArray;
|
||||||
std::vector<generic_string> functionNameExprArray;
|
std::vector<generic_string> functionNameExprArray;
|
||||||
|
|
||||||
@ -205,27 +193,27 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
TiXmlNode *functionParser = childNode->FirstChild(TEXT("function"));
|
TiXmlNode *functionParser = childNode->FirstChild(TEXT("function"));
|
||||||
if (classRangeParser && functionParser)
|
if (classRangeParser && functionParser)
|
||||||
{
|
{
|
||||||
generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr;
|
generic_string mainExpr, openSymbole, closeSymbole, functionExpr;
|
||||||
getZonePaserParameters(classRangeParser, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray);
|
getZonePaserParameters(classRangeParser, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray);
|
||||||
|
|
||||||
generic_string commentExpr2, mainExpr2;
|
generic_string mainExpr2;
|
||||||
std::vector<generic_string> classNameExprArray2;
|
std::vector<generic_string> classNameExprArray2;
|
||||||
std::vector<generic_string> functionNameExprArray2;
|
std::vector<generic_string> functionNameExprArray2;
|
||||||
getUnitPaserParameters(functionParser, commentExpr2, mainExpr2, functionNameExprArray2, classNameExprArray2);
|
getUnitPaserParameters(functionParser, mainExpr2, functionNameExprArray2, classNameExprArray2);
|
||||||
FunctionUnitParser *funcUnitPaser = new FunctionUnitParser(id, displayName, commentExpr2.c_str(), mainExpr2.c_str(), 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));
|
_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)
|
else if (classRangeParser)
|
||||||
{
|
{
|
||||||
generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr;
|
generic_string mainExpr, openSymbole, closeSymbole, functionExpr;
|
||||||
getZonePaserParameters(classRangeParser, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray);
|
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));
|
_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)
|
else if (functionParser)
|
||||||
{
|
{
|
||||||
generic_string commentExpr, mainExpr;
|
generic_string mainExpr;
|
||||||
getUnitPaserParameters(functionParser, commentExpr, mainExpr, functionNameExprArray, classNameExprArray);
|
getUnitPaserParameters(functionParser, mainExpr, functionNameExprArray, classNameExprArray);
|
||||||
_parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr.c_str(), mainExpr.c_str(), 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;
|
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)
|
if (begin >= end)
|
||||||
return;
|
return;
|
||||||
@ -343,7 +331,15 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
|||||||
|
|
||||||
if (fi._pos != -1 || fi._pos2 != -1) // at least one should be found
|
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;
|
begin = targetStart + foundTextLen;
|
||||||
@ -519,7 +515,7 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
|||||||
//vector< generic_string > emptyArray;
|
//vector< generic_string > emptyArray;
|
||||||
if (!isInZones(targetStart, commentZones))
|
if (!isInZones(targetStart, commentZones))
|
||||||
{
|
{
|
||||||
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName);
|
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName, &commentZones);
|
||||||
}
|
}
|
||||||
begin = targetStart + (targetEnd - targetStart);
|
begin = targetStart + (targetEnd - targetStart);
|
||||||
targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
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){};
|
_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;
|
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);
|
bool isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones);
|
||||||
protected:
|
protected:
|
||||||
generic_string _id;
|
generic_string _id;
|
||||||
@ -133,8 +133,8 @@ private:
|
|||||||
TiXmlDocument *_pXmlFuncListDoc;
|
TiXmlDocument *_pXmlFuncListDoc;
|
||||||
|
|
||||||
bool getFuncListFromXmlTree();
|
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 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 &commentExprStr, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray);
|
bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray);
|
||||||
FunctionParser * getParser(generic_string ext);
|
FunctionParser * getParser(generic_string ext);
|
||||||
FunctionParser * getParser(int langID);
|
FunctionParser * getParser(int langID);
|
||||||
};
|
};
|
||||||
|
@ -24,13 +24,12 @@
|
|||||||
|
|
||||||
</associationMap>
|
</associationMap>
|
||||||
<parsers>
|
<parsers>
|
||||||
<parser id="cpp_class" displayName="C++ Class">
|
<parser id="cpp_class" displayName="C++ Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||||
<classRange
|
<classRange
|
||||||
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
||||||
openSymbole = "\{"
|
openSymbole = "\{"
|
||||||
closeSymbole = "\}"
|
closeSymbole = "\}"
|
||||||
displayMode="node">
|
displayMode="node">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
||||||
<nameExpr expr="[\t ]+[\w]+"/>
|
<nameExpr expr="[\t ]+[\w]+"/>
|
||||||
@ -45,14 +44,13 @@
|
|||||||
</function>
|
</function>
|
||||||
</classRange>
|
</classRange>
|
||||||
</parser>
|
</parser>
|
||||||
<parser id="c_function" displayName="C source">
|
<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||||
<function
|
<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">
|
displayMode="$className->$functionName">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~]+[\s]*\("/>
|
<nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
|
||||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~]+"/>
|
<nameExpr expr="(?!(if|while|for))[\w_~]+"/>
|
||||||
</functionName>
|
</functionName>
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||||
@ -76,13 +74,12 @@
|
|||||||
</parser>
|
</parser>
|
||||||
|
|
||||||
|
|
||||||
<parser id="c_cpp_function" displayName="C++ Class">
|
<parser id="c_cpp_function" displayName="C++ Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
|
||||||
<classRange
|
<classRange
|
||||||
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
mainExpr="^[\t ]*(class|struct)[\t ]+[\w]+[\s]*(:[\s]*(public|protected|private)[\s]+[\w]+[\s]*)?\{"
|
||||||
openSymbole = "\{"
|
openSymbole = "\{"
|
||||||
closeSymbole = "\}"
|
closeSymbole = "\}"
|
||||||
displayMode="node">
|
displayMode="node">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
<nameExpr expr="(class|struct)[\t ]+[\w]+"/>
|
||||||
<nameExpr expr="[\t ]+[\w]+"/>
|
<nameExpr expr="[\t ]+[\w]+"/>
|
||||||
@ -97,12 +94,11 @@
|
|||||||
</function>
|
</function>
|
||||||
</classRange>
|
</classRange>
|
||||||
<function
|
<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">
|
displayMode="$className->$functionName">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~\+\*\-=\!]+[\s]*\("/>
|
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
|
||||||
<nameExpr expr="(?!(if|while|for|switch))[\w_~\+\*\-=\!]+"/>
|
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
|
||||||
</functionName>
|
</functionName>
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user