mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-08 22:44:39 +02:00
[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)
|
void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView)
|
||||||
{
|
{
|
||||||
DockingDlgInterface::init(hInst, hPere);
|
DockingDlgInterface::init(hInst, hPere);
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
#include "functionParser.h"
|
#include "functionParser.h"
|
||||||
#include "boostregexsearch.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)
|
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
|
||||||
{
|
{
|
||||||
_ppEditView = ppEditView;
|
_ppEditView = ppEditView;
|
||||||
@ -48,60 +56,33 @@ bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** p
|
|||||||
return loadOkay;
|
return loadOkay;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionParsersManager::getFuncListFromXmlTree()
|
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)
|
||||||
{
|
{
|
||||||
if (!_pXmlFuncListDoc)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TiXmlNode *root = _pXmlFuncListDoc->FirstChild(TEXT("NotepadPlus"));
|
|
||||||
if (!root)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
root = root->FirstChild(TEXT("functionList"));
|
|
||||||
if (!root)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TiXmlNode *parserRoot = root->FirstChild(TEXT("parsers"));
|
|
||||||
if (!parserRoot)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
for (TiXmlNode *childNode = parserRoot->FirstChildElement(TEXT("parser"));
|
|
||||||
childNode;
|
|
||||||
childNode = childNode->NextSibling(TEXT("parser")) )
|
|
||||||
{
|
|
||||||
const TCHAR *id = (childNode->ToElement())->Attribute(TEXT("id"));
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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;
|
||||||
|
|
||||||
mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr"));
|
mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||||
if (!mainExpr)
|
if (!mainExpr || !mainExpr[0])
|
||||||
continue;
|
return false;
|
||||||
|
mainExprStr = mainExpr;
|
||||||
|
|
||||||
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
||||||
|
if (openSymbole && openSymbole[0])
|
||||||
|
openSymboleStr = openSymbole;
|
||||||
|
|
||||||
closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole"));
|
closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole"));
|
||||||
|
if (closeSymbole && closeSymbole[0])
|
||||||
|
closeSymboleStr = closeSymbole;
|
||||||
|
|
||||||
TiXmlNode *commentSymbols = classRangeParser->FirstChild(TEXT("comment"));
|
TiXmlNode *commentSymbols = classRangeParser->FirstChild(TEXT("comment"));
|
||||||
if (commentSymbols)
|
if (commentSymbols)
|
||||||
{
|
{
|
||||||
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
||||||
|
if (commentExpr)
|
||||||
|
commentExprStr = commentExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className"));
|
TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className"));
|
||||||
@ -119,11 +100,12 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
|
|
||||||
TiXmlNode *functionParser = classRangeParser->FirstChild(TEXT("function"));
|
TiXmlNode *functionParser = classRangeParser->FirstChild(TEXT("function"));
|
||||||
if (!functionParser)
|
if (!functionParser)
|
||||||
continue;
|
return false;
|
||||||
|
|
||||||
functionExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
functionExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||||
if (!functionExpr)
|
if (!functionExpr || !functionExpr[0])
|
||||||
continue;
|
return false;
|
||||||
|
functionExprStr = functionExpr;
|
||||||
|
|
||||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||||
if (functionNameParser)
|
if (functionNameParser)
|
||||||
@ -138,25 +120,23 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_parsers.push_back(new FunctionZoneParser(id, displayName, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray));
|
bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &commentExprStr, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray)
|
||||||
}
|
{
|
||||||
else
|
const TCHAR *commentExpr = NULL;
|
||||||
{
|
|
||||||
TiXmlNode *functionParser = childNode->FirstChild(TEXT("function"));
|
|
||||||
if (!functionParser)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr"));
|
||||||
if (!mainExpr)
|
if (!mainExpr || !mainExpr[0])
|
||||||
continue;
|
return false;
|
||||||
|
mainExprStr = mainExpr;
|
||||||
|
|
||||||
TiXmlNode *commentSymbols = functionParser->FirstChild(TEXT("comment"));
|
TiXmlNode *commentSymbols = functionParser->FirstChild(TEXT("comment"));
|
||||||
if (commentSymbols)
|
if (commentSymbols)
|
||||||
{
|
{
|
||||||
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
||||||
|
if (commentExpr && commentExpr[0])
|
||||||
|
commentExprStr = commentExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||||
@ -184,7 +164,69 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
classNameExprArray.push_back(expr);
|
classNameExprArray.push_back(expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray));
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FunctionParsersManager::getFuncListFromXmlTree()
|
||||||
|
{
|
||||||
|
if (!_pXmlFuncListDoc)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TiXmlNode *root = _pXmlFuncListDoc->FirstChild(TEXT("NotepadPlus"));
|
||||||
|
if (!root)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
root = root->FirstChild(TEXT("functionList"));
|
||||||
|
if (!root)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TiXmlNode *parserRoot = root->FirstChild(TEXT("parsers"));
|
||||||
|
if (!parserRoot)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
for (TiXmlNode *childNode = parserRoot->FirstChildElement(TEXT("parser"));
|
||||||
|
childNode;
|
||||||
|
childNode = childNode->NextSibling(TEXT("parser")) )
|
||||||
|
{
|
||||||
|
const TCHAR *id = (childNode->ToElement())->Attribute(TEXT("id"));
|
||||||
|
if (!id || !id[0])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::vector<generic_string> classNameExprArray;
|
||||||
|
std::vector<generic_string> functionNameExprArray;
|
||||||
|
|
||||||
|
const TCHAR *displayName = (childNode->ToElement())->Attribute(TEXT("displayName"));
|
||||||
|
if (!displayName || !displayName[0])
|
||||||
|
displayName = id;
|
||||||
|
|
||||||
|
TiXmlNode *classRangeParser = childNode->FirstChild(TEXT("classRange"));
|
||||||
|
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 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);
|
||||||
|
|
||||||
|
_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);
|
||||||
|
_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)
|
FunctionParser * FunctionParsersManager::getParser(generic_string ext)
|
||||||
{
|
{
|
||||||
|
if (ext == TEXT(""))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < _associationMap.size(); i++)
|
for (size_t i = 0; i < _associationMap.size(); i++)
|
||||||
{
|
{
|
||||||
if (ext == _associationMap[i]._ext)
|
if (ext == _associationMap[i]._ext)
|
||||||
@ -241,6 +286,9 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
|||||||
if (begin >= end)
|
if (begin >= end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_functionExpr.length() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
@ -281,16 +329,16 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
|||||||
fi._pos = foundPos;
|
fi._pos = foundPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_classNameExprArray.size())
|
if (classStructName != TEXT(""))
|
||||||
{
|
|
||||||
fi._data2 = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView);
|
|
||||||
fi._pos2 = foundPos;
|
|
||||||
}
|
|
||||||
else if (classStructName != TEXT(""))
|
|
||||||
{
|
{
|
||||||
fi._data2 = classStructName;
|
fi._data2 = classStructName;
|
||||||
fi._pos2 = 0; // change -1 valeur for validated data2
|
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
|
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;
|
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)
|
if (begin >= end)
|
||||||
return;
|
return;
|
||||||
@ -439,12 +487,12 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
|||||||
|
|
||||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
int targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
int targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
||||||
|
|
||||||
int targetEnd = 0;
|
int targetEnd = 0;
|
||||||
|
|
||||||
while (targetStart != -1 && targetStart != -2)
|
while (targetStart != -1 && targetStart != -2)
|
||||||
{
|
{
|
||||||
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||||
scannedZone.push_back(pair<int, int>(targetStart, targetEnd));
|
|
||||||
|
|
||||||
// Get class name
|
// Get class name
|
||||||
int foundPos = 0;
|
int foundPos = 0;
|
||||||
@ -460,14 +508,19 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scannedZones.push_back(pair<int, int>(targetStart, targetEnd));
|
||||||
|
|
||||||
int foundTextLen = targetEnd - targetStart;
|
int foundTextLen = targetEnd - targetStart;
|
||||||
if (targetStart + foundTextLen == int(end))
|
if (targetStart + foundTextLen == int(end))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Begin to search all method inside
|
// Begin to search all method inside
|
||||||
vector< generic_string > emptyArray;
|
//vector< generic_string > emptyArray;
|
||||||
|
if (!isInZones(targetStart, commentZones))
|
||||||
|
{
|
||||||
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName);
|
funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName);
|
||||||
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -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)
|
void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vector< pair<int, int> > & sourceZones, size_t begin, size_t end)
|
||||||
{
|
{
|
||||||
if (sourceZones.size() == 0)
|
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)
|
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);
|
getCommentZones(commentZones, begin, end, ppEditView);
|
||||||
getInvertZones(nonCommentZones, commentZones, begin, end);
|
getInvertZones(nonCommentZones, commentZones, begin, end);
|
||||||
for (size_t i = 0; i < nonCommentZones.size(); i++)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,3 +620,32 @@ void FunctionUnitParser::parse(std::vector<foundInfo> & foundInfos, size_t begin
|
|||||||
funcParse(foundInfos, nonCommentZones[i].first, nonCommentZones[i].second, ppEditView, classStructName);
|
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 ScintillaEditView;
|
||||||
class TiXmlDocument;
|
class TiXmlDocument;
|
||||||
|
class TiXmlNode;
|
||||||
|
|
||||||
struct foundInfo {
|
struct foundInfo {
|
||||||
generic_string _data;
|
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;
|
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(""));
|
||||||
|
bool isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones);
|
||||||
protected:
|
protected:
|
||||||
generic_string _id;
|
generic_string _id;
|
||||||
generic_string _displayName;
|
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(""));
|
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:
|
private:
|
||||||
generic_string _rangeExpr;
|
generic_string _rangeExpr;
|
||||||
generic_string _openSymbole;
|
generic_string _openSymbole;
|
||||||
generic_string _closeSymbole;
|
generic_string _closeSymbole;
|
||||||
//std::vector<generic_string> _classNameExprArray;
|
|
||||||
generic_string _functionExpr;
|
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);
|
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, ScintillaEditView **ppEditView);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionUnitParser : public FunctionParser {
|
class FunctionUnitParser : public FunctionParser {
|
||||||
public:
|
public:
|
||||||
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
|
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 {
|
struct AssociationInfo {
|
||||||
int _id;
|
int _id;
|
||||||
int _langID;
|
int _langID;
|
||||||
@ -102,6 +121,7 @@ struct AssociationInfo {
|
|||||||
class FunctionParsersManager {
|
class FunctionParsersManager {
|
||||||
public:
|
public:
|
||||||
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
||||||
|
~FunctionParsersManager();
|
||||||
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
||||||
bool parse(std::vector<foundInfo> & foundInfos, int langID);
|
bool parse(std::vector<foundInfo> & foundInfos, int langID);
|
||||||
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
||||||
@ -113,6 +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 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(generic_string ext);
|
||||||
FunctionParser * getParser(int langID);
|
FunctionParser * getParser(int langID);
|
||||||
};
|
};
|
||||||
|
@ -2,12 +2,26 @@
|
|||||||
<NotepadPlus>
|
<NotepadPlus>
|
||||||
<functionList>
|
<functionList>
|
||||||
<associationMap>
|
<associationMap>
|
||||||
<association ext=".h" id="cpp_class"/>
|
<!-- langID:
|
||||||
<association ext=".hpp" id="cpp_class"/>
|
L_TEXT: 0 L_PHP: 1 L_C: 2 L_CPP: 3 L_CS: 4 L_OBJC: 5
|
||||||
<association ext=".hxx" id="cpp_class"/>
|
L_JAVA: 6 L_RC: 7 L_HTML: 8 L_XML: 9 L_MAKEFILE: 10 L_PASCAL: 11
|
||||||
<association ext=".c" id="c_cpp_function"/>
|
L_BATCH:12 L_INI: 13 L_ASCII: 14 L_USER: 15 L_ASP: 16 L_SQL: 17
|
||||||
<association ext=".cpp" id="c_cpp_function"/>
|
L_VB: 18 L_JS: 19 L_CSS: 20 L_PERL: 21 L_PYTHON: 22 L_LUA: 23
|
||||||
<association ext=".cxx" id="c_cpp_function"/>
|
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>
|
</associationMap>
|
||||||
<parsers>
|
<parsers>
|
||||||
<parser id="cpp_class" displayName="C++ Class">
|
<parser id="cpp_class" displayName="C++ Class">
|
||||||
@ -23,19 +37,17 @@
|
|||||||
<nameExpr expr="[\w]+"/>
|
<nameExpr expr="[\w]+"/>
|
||||||
</className>
|
</className>
|
||||||
<function
|
<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>
|
<functionName>
|
||||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
<funcNameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||||
<funcNameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
<funcNameExpr expr="(?!(if|whil|for))[\w_]+"/>
|
||||||
</functionName>
|
</functionName>
|
||||||
</function>
|
</function>
|
||||||
</classRange>
|
</classRange>
|
||||||
|
|
||||||
</parser>
|
</parser>
|
||||||
<parser id="c_cpp_function" displayName="C++/C source">
|
<parser id="c_function" displayName="C source">
|
||||||
<function
|
<function
|
||||||
mainExpr="^[\t ]*((static|const)[\s]+)?[\w]+([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|whil|for))[\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]*\{"
|
||||||
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]*\{"
|
|
||||||
displayMode="$className->$functionName">
|
displayMode="$className->$functionName">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||||
<functionName>
|
<functionName>
|
||||||
@ -51,7 +63,41 @@
|
|||||||
|
|
||||||
<parser id="js_function" displayName="Javascript">
|
<parser id="js_function" displayName="Javascript">
|
||||||
<function
|
<function
|
||||||
mainExpr="function([\s]+[\w]*[\s]*|[\s]*)\([^\)\(]*\)[\n\s]*\{"
|
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">
|
displayMode="$className->$functionName">
|
||||||
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
<comment expr="((/\*.*?\*)/|(//.*?$))" />
|
||||||
<functionName>
|
<functionName>
|
||||||
@ -63,6 +109,7 @@
|
|||||||
</className>
|
</className>
|
||||||
</function>
|
</function>
|
||||||
</parser>
|
</parser>
|
||||||
|
|
||||||
</parsers>
|
</parsers>
|
||||||
</functionList>
|
</functionList>
|
||||||
</NotepadPlus>
|
</NotepadPlus>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user