[UPDATE] Build-in FunctionList in progress.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1031 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
3b08109267
commit
45f9d6e13b
@ -237,6 +237,8 @@ void FunctionListPanel::reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView)
|
||||
{
|
||||
DockingDlgInterface::init(hInst, hPere);
|
||||
|
@ -30,6 +30,14 @@
|
||||
#include "functionParser.h"
|
||||
#include "boostregexsearch.h"
|
||||
|
||||
FunctionParsersManager::~FunctionParsersManager()
|
||||
{
|
||||
for (size_t i = 0; i < _parsers.size(); i++)
|
||||
{
|
||||
delete _parsers[i];
|
||||
}
|
||||
}
|
||||
|
||||
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
|
||||
{
|
||||
_ppEditView = ppEditView;
|
||||
@ -48,6 +56,118 @@ 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)
|
||||
{
|
||||
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"));
|
||||
if (!mainExpr || !mainExpr[0])
|
||||
return false;
|
||||
mainExprStr = mainExpr;
|
||||
|
||||
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
||||
if (openSymbole && openSymbole[0])
|
||||
openSymboleStr = openSymbole;
|
||||
|
||||
closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole"));
|
||||
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)
|
||||
{
|
||||
for (TiXmlNode *childNode2 = classNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode2;
|
||||
childNode2 = childNode2->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode2->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
classNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
|
||||
TiXmlNode *functionParser = classRangeParser->FirstChild(TEXT("function"));
|
||||
if (!functionParser)
|
||||
return false;
|
||||
|
||||
functionExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||
if (!functionExpr || !functionExpr[0])
|
||||
return false;
|
||||
functionExprStr = functionExpr;
|
||||
|
||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||
if (functionNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode3 = functionNameParser->FirstChildElement(TEXT("funcNameExpr"));
|
||||
childNode3;
|
||||
childNode3 = childNode3->NextSibling(TEXT("funcNameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode3->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
functionNameExprArray.push_back(expr);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &commentExprStr, 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)
|
||||
{
|
||||
for (TiXmlNode *childNode = functionNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode;
|
||||
childNode = childNode->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
functionNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
|
||||
TiXmlNode *classNameParser = functionParser->FirstChild(TEXT("className"));
|
||||
if (functionNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode = classNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode;
|
||||
childNode = childNode->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
classNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FunctionParsersManager::getFuncListFromXmlTree()
|
||||
{
|
||||
if (!_pXmlFuncListDoc)
|
||||
@ -74,117 +194,39 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
||||
if (!id || !id[0])
|
||||
continue;
|
||||
|
||||
|
||||
std::vector<generic_string> classNameExprArray;
|
||||
const TCHAR *functionExpr = NULL;
|
||||
std::vector<generic_string> functionNameExprArray;
|
||||
|
||||
const TCHAR *displayName = (childNode->ToElement())->Attribute(TEXT("displayName"));
|
||||
if (!displayName || !displayName[0])
|
||||
displayName = id;
|
||||
|
||||
const TCHAR *commentExpr = NULL;
|
||||
|
||||
TiXmlNode *classRangeParser = childNode->FirstChild(TEXT("classRange"));
|
||||
if (classRangeParser)
|
||||
TiXmlNode *functionParser = childNode->FirstChild(TEXT("function"));
|
||||
if (classRangeParser && functionParser)
|
||||
{
|
||||
const TCHAR *mainExpr = NULL;
|
||||
const TCHAR *openSymbole = NULL;
|
||||
const TCHAR *closeSymbole = NULL;
|
||||
generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr;
|
||||
getZonePaserParameters(classRangeParser, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray);
|
||||
|
||||
generic_string commentExpr2, 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);
|
||||
|
||||
mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||
if (!mainExpr)
|
||||
continue;
|
||||
|
||||
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
||||
closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole"));
|
||||
TiXmlNode *commentSymbols = classRangeParser->FirstChild(TEXT("comment"));
|
||||
if (commentSymbols)
|
||||
{
|
||||
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
||||
}
|
||||
|
||||
TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className"));
|
||||
if (classNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode2 = classNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode2;
|
||||
childNode2 = childNode2->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode2->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
classNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
|
||||
TiXmlNode *functionParser = classRangeParser->FirstChild(TEXT("function"));
|
||||
if (!functionParser)
|
||||
continue;
|
||||
|
||||
functionExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||
if (!functionExpr)
|
||||
continue;
|
||||
|
||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||
if (functionNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode3 = functionNameParser->FirstChildElement(TEXT("funcNameExpr"));
|
||||
childNode3;
|
||||
childNode3 = childNode3->NextSibling(TEXT("funcNameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode3->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
functionNameExprArray.push_back(expr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_parsers.push_back(new FunctionZoneParser(id, displayName, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray));
|
||||
_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
|
||||
else if (classRangeParser)
|
||||
{
|
||||
TiXmlNode *functionParser = childNode->FirstChild(TEXT("function"));
|
||||
if (!functionParser)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||
if (!mainExpr)
|
||||
continue;
|
||||
|
||||
TiXmlNode *commentSymbols = functionParser->FirstChild(TEXT("comment"));
|
||||
if (commentSymbols)
|
||||
{
|
||||
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
||||
}
|
||||
|
||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||
if (functionNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode = functionNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode;
|
||||
childNode = childNode->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
functionNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
|
||||
TiXmlNode *classNameParser = functionParser->FirstChild(TEXT("className"));
|
||||
if (functionNameParser)
|
||||
{
|
||||
for (TiXmlNode *childNode = classNameParser->FirstChildElement(TEXT("nameExpr"));
|
||||
childNode;
|
||||
childNode = childNode->NextSibling(TEXT("nameExpr")) )
|
||||
{
|
||||
const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr"));
|
||||
if (expr && expr[0])
|
||||
classNameExprArray.push_back(expr);
|
||||
}
|
||||
}
|
||||
_parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray));
|
||||
generic_string commentExpr, mainExpr, openSymbole, closeSymbole, functionExpr;
|
||||
getZonePaserParameters(classRangeParser, commentExpr, 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);
|
||||
_parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr.c_str(), mainExpr.c_str(), functionNameExprArray, classNameExprArray));
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +270,9 @@ FunctionParser * FunctionParsersManager::getParser(int langID)
|
||||
|
||||
FunctionParser * FunctionParsersManager::getParser(generic_string ext)
|
||||
{
|
||||
if (ext == TEXT(""))
|
||||
return NULL;
|
||||
|
||||
for (size_t i = 0; i < _associationMap.size(); i++)
|
||||
{
|
||||
if (ext == _associationMap[i]._ext)
|
||||
@ -241,6 +286,9 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
||||
if (begin >= end)
|
||||
return;
|
||||
|
||||
if (_functionExpr.length() == 0)
|
||||
return;
|
||||
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
@ -281,16 +329,16 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
||||
fi._pos = foundPos;
|
||||
}
|
||||
|
||||
if (_classNameExprArray.size())
|
||||
{
|
||||
fi._data2 = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView);
|
||||
fi._pos2 = foundPos;
|
||||
}
|
||||
else if (classStructName != TEXT(""))
|
||||
if (classStructName != TEXT(""))
|
||||
{
|
||||
fi._data2 = classStructName;
|
||||
fi._pos2 = 0; // change -1 valeur for validated data2
|
||||
}
|
||||
else if (_classNameExprArray.size())
|
||||
{
|
||||
fi._data2 = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView);
|
||||
fi._pos2 = foundPos;
|
||||
}
|
||||
}
|
||||
|
||||
if (fi._pos != -1 || fi._pos2 != -1) // at least one should be found
|
||||
@ -430,7 +478,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
||||
return targetEnd;
|
||||
}
|
||||
|
||||
void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair<int, int> > &scannedZone, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair<int, int> > &scannedZones, const std::vector< std::pair<int, int> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
if (begin >= end)
|
||||
return;
|
||||
@ -439,12 +487,12 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
||||
|
||||
int targetEnd = 0;
|
||||
|
||||
while (targetStart != -1 && targetStart != -2)
|
||||
{
|
||||
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||
scannedZone.push_back(pair<int, int>(targetStart, targetEnd));
|
||||
|
||||
// Get class name
|
||||
int foundPos = 0;
|
||||
@ -460,14 +508,19 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
scannedZones.push_back(pair<int, int>(targetStart, targetEnd));
|
||||
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == int(end))
|
||||
break;
|
||||
|
||||
// Begin to search all method inside
|
||||
vector< generic_string > emptyArray;
|
||||
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName);
|
||||
|
||||
//vector< generic_string > emptyArray;
|
||||
if (!isInZones(targetStart, commentZones))
|
||||
{
|
||||
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName);
|
||||
}
|
||||
begin = targetStart + (targetEnd - targetStart);
|
||||
targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
||||
}
|
||||
@ -506,6 +559,18 @@ void FunctionParser::getCommentZones(vector< pair<int, int> > & commentZone, siz
|
||||
}
|
||||
}
|
||||
|
||||
bool FunctionParser::isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones)
|
||||
{
|
||||
for (size_t i = 0; i < zones.size(); i++)
|
||||
{
|
||||
if (pos2Test >= zones[i].first && pos2Test < zones[i].second)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vector< pair<int, int> > & sourceZones, size_t begin, size_t end)
|
||||
{
|
||||
if (sourceZones.size() == 0)
|
||||
@ -536,12 +601,12 @@ void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vecto
|
||||
|
||||
void FunctionZoneParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
vector< pair<int, int> > commentZones, nonCommentZones;
|
||||
vector< pair<int, int> > classZones, commentZones, nonCommentZones;
|
||||
getCommentZones(commentZones, begin, end, ppEditView);
|
||||
getInvertZones(nonCommentZones, commentZones, begin, end);
|
||||
for (size_t i = 0; i < nonCommentZones.size(); i++)
|
||||
{
|
||||
classParse(foundInfos, commentZones, nonCommentZones[i].first, nonCommentZones[i].second, ppEditView, classStructName);
|
||||
classParse(foundInfos, classZones, commentZones, nonCommentZones[i].first, nonCommentZones[i].second, ppEditView, classStructName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,4 +619,33 @@ void FunctionUnitParser::parse(std::vector<foundInfo> & foundInfos, size_t begin
|
||||
{
|
||||
funcParse(foundInfos, nonCommentZones[i].first, nonCommentZones[i].second, ppEditView, classStructName);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SortClass for vector<pair<int, int>>
|
||||
// sort in _selLpos : increased order
|
||||
struct SortZones {
|
||||
bool operator() (pair<int, int> & l, pair<int, int> & r) {
|
||||
return (l.first < r.first);
|
||||
}
|
||||
};
|
||||
|
||||
void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
vector< pair<int, int> > commentZones, scannedZones, nonCommentZones, nonScannedZones;
|
||||
getCommentZones(commentZones, begin, end, ppEditView);
|
||||
|
||||
classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName);
|
||||
|
||||
// invert scannedZones
|
||||
getInvertZones(nonScannedZones, scannedZones, begin, end);
|
||||
|
||||
// for each nonScannedZones, search functions
|
||||
if (_funcUnitPaser)
|
||||
{
|
||||
for (size_t i = 0; i < nonScannedZones.size(); i++)
|
||||
{
|
||||
_funcUnitPaser->funcParse(foundInfos, nonScannedZones[i].first, nonScannedZones[i].second, ppEditView, classStructName);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@
|
||||
|
||||
class ScintillaEditView;
|
||||
class TiXmlDocument;
|
||||
class TiXmlNode;
|
||||
|
||||
struct foundInfo {
|
||||
generic_string _data;
|
||||
@ -47,6 +48,7 @@ public:
|
||||
|
||||
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(""));
|
||||
bool isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones);
|
||||
protected:
|
||||
generic_string _id;
|
||||
generic_string _displayName;
|
||||
@ -68,19 +70,20 @@ public:
|
||||
|
||||
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
|
||||
protected:
|
||||
void classParse(std::vector<foundInfo> & foundInfos, std::vector< std::pair<int, int> > & scannedZones, const std::vector< std::pair<int, int> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
|
||||
private:
|
||||
generic_string _rangeExpr;
|
||||
generic_string _openSymbole;
|
||||
generic_string _closeSymbole;
|
||||
//std::vector<generic_string> _classNameExprArray;
|
||||
generic_string _functionExpr;
|
||||
//std::vector<generic_string> _functionNameExprArray;
|
||||
|
||||
void classParse(std::vector<foundInfo> & foundInfos, std::vector< std::pair<int, int> > & scannedZone, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, ScintillaEditView **ppEditView);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FunctionUnitParser : public FunctionParser {
|
||||
public:
|
||||
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
|
||||
@ -91,6 +94,22 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class FunctionMixParser : public FunctionZoneParser {
|
||||
public:
|
||||
FunctionMixParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
|
||||
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, FunctionUnitParser *funcUnitPaser):
|
||||
FunctionZoneParser(id, displayName, commentExpr, rangeExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray), _funcUnitPaser(funcUnitPaser){};
|
||||
|
||||
~FunctionMixParser() {
|
||||
if (_funcUnitPaser)
|
||||
delete _funcUnitPaser;
|
||||
}
|
||||
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
|
||||
private:
|
||||
FunctionUnitParser *_funcUnitPaser;
|
||||
};
|
||||
|
||||
struct AssociationInfo {
|
||||
int _id;
|
||||
int _langID;
|
||||
@ -102,6 +121,7 @@ struct AssociationInfo {
|
||||
class FunctionParsersManager {
|
||||
public:
|
||||
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
||||
~FunctionParsersManager();
|
||||
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
||||
bool parse(std::vector<foundInfo> & foundInfos, int langID);
|
||||
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
||||
@ -113,6 +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);
|
||||
FunctionParser * getParser(generic_string ext);
|
||||
FunctionParser * getParser(int langID);
|
||||
};
|
||||
|
@ -2,12 +2,26 @@
|
||||
<NotepadPlus>
|
||||
<functionList>
|
||||
<associationMap>
|
||||
<association ext=".h" id="cpp_class"/>
|
||||
<association ext=".hpp" id="cpp_class"/>
|
||||
<association ext=".hxx" id="cpp_class"/>
|
||||
<association ext=".c" id="c_cpp_function"/>
|
||||
<association ext=".cpp" id="c_cpp_function"/>
|
||||
<association ext=".cxx" id="c_cpp_function"/>
|
||||
<!-- langID:
|
||||
L_TEXT: 0 L_PHP: 1 L_C: 2 L_CPP: 3 L_CS: 4 L_OBJC: 5
|
||||
L_JAVA: 6 L_RC: 7 L_HTML: 8 L_XML: 9 L_MAKEFILE: 10 L_PASCAL: 11
|
||||
L_BATCH:12 L_INI: 13 L_ASCII: 14 L_USER: 15 L_ASP: 16 L_SQL: 17
|
||||
L_VB: 18 L_JS: 19 L_CSS: 20 L_PERL: 21 L_PYTHON: 22 L_LUA: 23
|
||||
L_TEX: 24 L_FORTRAN: 25 L_BASH: 26 L_FLASH: 27 L_NSIS: 28 L_TCL: 29
|
||||
L_LISP: 30 L_SCHEME: 31 L_ASM: 32 L_DIFF: 33 L_PROPS: 34 L_PS: 35
|
||||
L_RUBY: 36 L_SMALLTALK:37 L_VHDL: 38 L_KIX: 39 L_AU3: 40 L_CAML: 41
|
||||
L_ADA: 42 L_VERILOG: 43 L_MATLAB: 44 L_HASKELL: 45 L_INNO: 46 L_SEARCHRESULT: 47
|
||||
L_CMAKE: 48 L_YAML: 49 L_COBOL 50 L_GUI4CLI: 51 L_D: 52 L_POWERSHELL: 53
|
||||
L_R: 54 L_JSP: 55
|
||||
-->
|
||||
<association langID = "2" id="cpp_class"/>
|
||||
<association langID = "3" id="c_cpp_function"/>
|
||||
<!--
|
||||
if langID cannot be found above, you can still set the file extensions
|
||||
<association ext="my_passer_ext1" id="my_passer_id"/>
|
||||
<association ext="my_passer_ext2" id="my_passer_id"/>
|
||||
-->
|
||||
|
||||
</associationMap>
|
||||
<parsers>
|
||||
<parser id="cpp_class" displayName="C++ Class">
|
||||
@ -23,19 +37,17 @@
|
||||
<nameExpr expr="[\w]+"/>
|
||||
</className>
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([\n\w_,*&\s]*\)([\s]*const[\s]*)?[\n\s]*\{">
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([\n\w_,*&\s]*\)([\s]*const[\s]*)?[\n\s]*\{">
|
||||
<functionName>
|
||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||
</functionName>
|
||||
</function>
|
||||
</classRange>
|
||||
|
||||
</parser>
|
||||
<parser id="c_cpp_function" displayName="C++/C source">
|
||||
<parser id="c_function" displayName="C source">
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
OmainExpr="^[\t ]*((static|const)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([\n\w_,*&\s]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<functionName>
|
||||
@ -49,20 +61,55 @@
|
||||
</parser>
|
||||
|
||||
|
||||
<parser id="js_function" displayName="Javascript">
|
||||
<function
|
||||
mainExpr="function([\s]+[\w]*[\s]*|[\s]*)\([^\)\(]*\)[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<functionName>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||
</className>
|
||||
</function>
|
||||
</parser>
|
||||
<parser id="js_function" displayName="Javascript">
|
||||
<function
|
||||
mainExpr="function[\s]+[\w]*[\s]+\([^\)\(]*\)[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<functionName>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||
</className>
|
||||
</function>
|
||||
</parser>
|
||||
|
||||
|
||||
<parser id="c_cpp_function" displayName="C++ Class">
|
||||
<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]+"/>
|
||||
<nameExpr expr="[\w]+"/>
|
||||
</className>
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{">
|
||||
<functionName>
|
||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||
</functionName>
|
||||
</function>
|
||||
</classRange>
|
||||
<function
|
||||
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
|
||||
displayMode="$className->$functionName">
|
||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||
<functionName>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||
<nameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
|
||||
</className>
|
||||
</function>
|
||||
</parser>
|
||||
|
||||
</parsers>
|
||||
</functionList>
|
||||
</NotepadPlus>
|
||||
|
Loading…
Reference in New Issue
Block a user