mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-29 08:44:40 +02:00
[UPDATE] Build-in FunctionList in progress.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1025 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
0180d012cb
commit
49128550d4
@ -32,11 +32,6 @@
|
|||||||
|
|
||||||
void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
|
void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0);
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_INSERTSTRING, index, (LPARAM)displayText);
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_SETITEMDATA, index, (LPARAM)pos);
|
|
||||||
*/
|
|
||||||
HTREEITEM itemParent = NULL;
|
HTREEITEM itemParent = NULL;
|
||||||
TCHAR posStr[32];
|
TCHAR posStr[32];
|
||||||
generic_itoa(pos, posStr, 10);
|
generic_itoa(pos, posStr, 10);
|
||||||
@ -58,10 +53,6 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText
|
|||||||
|
|
||||||
void FunctionListPanel::removeAllEntries()
|
void FunctionListPanel::removeAllEntries()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
while (::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0))
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_DELETESTRING, 0, 0);
|
|
||||||
*/
|
|
||||||
_treeView.removeAllItems();
|
_treeView.removeAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,118 +109,6 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
|
|||||||
return targetEnd;
|
return targetEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will
|
|
||||||
void FunctionListPanel::parse2(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *block, std::vector< generic_string > blockNameToSearch, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const TCHAR *function, std::vector< generic_string > functionToSearch)
|
|
||||||
{
|
|
||||||
if (begin >= end)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
|
||||||
|
|
||||||
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
|
||||||
int targetStart = (*_ppEditView)->searchInTarget(block, lstrlen(block), begin, end);
|
|
||||||
int targetEnd = 0;
|
|
||||||
|
|
||||||
//foundInfos.clear();
|
|
||||||
while (targetStart != -1 && targetStart != -2)
|
|
||||||
{
|
|
||||||
targetEnd = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
|
||||||
|
|
||||||
// Get class name
|
|
||||||
int foundPos = 0;
|
|
||||||
generic_string classStructName = parseSubLevel(targetStart, targetEnd, blockNameToSearch, foundPos);
|
|
||||||
|
|
||||||
|
|
||||||
if (lstrcmp(bodyOpenSymbol, TEXT("")) != 0 && lstrcmp(bodyCloseSymbol, TEXT("")) != 0)
|
|
||||||
{
|
|
||||||
targetEnd = getBodyClosePos(targetEnd, bodyOpenSymbol, bodyCloseSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int foundTextLen = targetEnd - targetStart;
|
|
||||||
if (targetStart + foundTextLen == int(end))
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Begin to search all method inside
|
|
||||||
vector< generic_string > emptyArray;
|
|
||||||
parse(foundInfos, targetStart, targetEnd, function, functionToSearch, emptyArray, classStructName);
|
|
||||||
|
|
||||||
begin = targetStart + (targetEnd - targetStart);
|
|
||||||
targetStart = (*_ppEditView)->searchInTarget(block, lstrlen(block), begin, end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FunctionListPanel::parse(vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *regExpr2search, vector< generic_string > dataToSearch, vector< generic_string > data2ToSearch, generic_string classStructName)
|
|
||||||
{
|
|
||||||
if (begin >= end)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
|
||||||
|
|
||||||
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
|
||||||
int targetStart = (*_ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
|
||||||
int targetEnd = 0;
|
|
||||||
|
|
||||||
//foundInfos.clear();
|
|
||||||
while (targetStart != -1 && targetStart != -2)
|
|
||||||
{
|
|
||||||
targetStart = int((*_ppEditView)->execute(SCI_GETTARGETSTART));
|
|
||||||
targetEnd = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
|
||||||
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int foundTextLen = targetEnd - targetStart;
|
|
||||||
if (targetStart + foundTextLen == int(end))
|
|
||||||
break;
|
|
||||||
|
|
||||||
foundInfo fi;
|
|
||||||
|
|
||||||
// dataToSearch & data2ToSearch are optional
|
|
||||||
if (!dataToSearch.size() && !data2ToSearch.size())
|
|
||||||
{
|
|
||||||
TCHAR foundData[1024];
|
|
||||||
(*_ppEditView)->getGenericText(foundData, 1024, targetStart, targetEnd);
|
|
||||||
|
|
||||||
fi._data = foundData; // whole found data
|
|
||||||
fi._pos = targetStart;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int foundPos;
|
|
||||||
if (dataToSearch.size())
|
|
||||||
{
|
|
||||||
fi._data = parseSubLevel(targetStart, targetEnd, dataToSearch, foundPos);
|
|
||||||
fi._pos = foundPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data2ToSearch.size())
|
|
||||||
{
|
|
||||||
fi._data2 = parseSubLevel(targetStart, targetEnd, data2ToSearch, foundPos);
|
|
||||||
fi._pos2 = foundPos;
|
|
||||||
}
|
|
||||||
else if (classStructName != TEXT(""))
|
|
||||||
{
|
|
||||||
fi._data2 = classStructName;
|
|
||||||
fi._pos2 = 0; // change -1 valeur for validated data2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fi._pos != -1 || fi._pos2 != -1) // at least one should be found
|
|
||||||
{
|
|
||||||
foundInfos.push_back(fi);
|
|
||||||
}
|
|
||||||
|
|
||||||
begin = targetStart + foundTextLen;
|
|
||||||
targetStart = (*_ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos)
|
generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos)
|
||||||
{
|
{
|
||||||
if (begin >= end)
|
if (begin >= end)
|
||||||
|
@ -88,14 +88,10 @@ public:
|
|||||||
void removeEntry();
|
void removeEntry();
|
||||||
void modifyEntry();
|
void modifyEntry();
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *regExpr2search, std::vector< generic_string > dataToSearch, std::vector< generic_string > data2ToSearch, generic_string classStructName = TEXT(""));
|
|
||||||
/*
|
/*
|
||||||
void parse(size_t begin, size_t end, const TCHAR *wordToExclude, const TCHAR *regExpr2search, ...);
|
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *regExpr2search, std::vector< generic_string > dataToSearch, std::vector< generic_string > data2ToSearch, generic_string classStructName = TEXT(""));
|
||||||
bool parseSubLevel(size_t begin, size_t end, const TCHAR *wordToExclude, const TCHAR *regExpr2search, ...);
|
|
||||||
*/
|
|
||||||
void parse2(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *block, std::vector< generic_string > blockNameToSearch, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const TCHAR *function, std::vector< generic_string > functionToSearch);
|
void parse2(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, const TCHAR *block, std::vector< generic_string > blockNameToSearch, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const TCHAR *function, std::vector< generic_string > functionToSearch);
|
||||||
|
*/
|
||||||
protected:
|
protected:
|
||||||
virtual BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "precompiledHeaders.h"
|
#include "precompiledHeaders.h"
|
||||||
#include "ScintillaEditView.h"
|
#include "ScintillaEditView.h"
|
||||||
#include "functionParser.h"
|
#include "functionParser.h"
|
||||||
|
#include "boostregexsearch.h"
|
||||||
|
|
||||||
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
|
bool FunctionParsersManager::init(generic_string xmlPath, ScintillaEditView ** ppEditView)
|
||||||
{
|
{
|
||||||
@ -82,6 +83,8 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
if (!displayName || !displayName[0])
|
if (!displayName || !displayName[0])
|
||||||
displayName = id;
|
displayName = id;
|
||||||
|
|
||||||
|
const TCHAR *commentExpr = NULL;
|
||||||
|
|
||||||
TiXmlNode *classRangeParser = childNode->FirstChild(TEXT("classRange"));
|
TiXmlNode *classRangeParser = childNode->FirstChild(TEXT("classRange"));
|
||||||
if (classRangeParser)
|
if (classRangeParser)
|
||||||
{
|
{
|
||||||
@ -95,6 +98,12 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
|
|
||||||
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole"));
|
||||||
closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole"));
|
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"));
|
TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className"));
|
||||||
if (classNameParser)
|
if (classNameParser)
|
||||||
{
|
{
|
||||||
@ -130,7 +139,7 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parsers.push_back(new FunctionZoneParser(id, displayName, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray));
|
_parsers.push_back(new FunctionZoneParser(id, displayName, commentExpr, mainExpr, openSymbole, closeSymbole, classNameExprArray, functionExpr, functionNameExprArray));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -144,6 +153,12 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
if (!mainExpr)
|
if (!mainExpr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
TiXmlNode *commentSymbols = functionParser->FirstChild(TEXT("comment"));
|
||||||
|
if (commentSymbols)
|
||||||
|
{
|
||||||
|
commentExpr = (commentSymbols->ToElement())->Attribute(TEXT("expr"));
|
||||||
|
}
|
||||||
|
|
||||||
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName"));
|
||||||
if (functionNameParser)
|
if (functionNameParser)
|
||||||
{
|
{
|
||||||
@ -169,7 +184,7 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
classNameExprArray.push_back(expr);
|
classNameExprArray.push_back(expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_parsers.push_back(new FunctionUnitParser(id, displayName, mainExpr, functionNameExprArray, classNameExprArray));
|
_parsers.push_back(new FunctionUnitParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +229,7 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begi
|
|||||||
if (begin >= end)
|
if (begin >= end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
int targetStart = (*ppEditView)->searchInTarget(_functionExpr.c_str(), _functionExpr.length(), begin, end);
|
int targetStart = (*ppEditView)->searchInTarget(_functionExpr.c_str(), _functionExpr.length(), begin, end);
|
||||||
@ -287,7 +302,7 @@ generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vect
|
|||||||
if (!dataToSearch.size())
|
if (!dataToSearch.size())
|
||||||
return TEXT("");
|
return TEXT("");
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
const TCHAR *regExpr2search = dataToSearch[0].c_str();
|
const TCHAR *regExpr2search = dataToSearch[0].c_str();
|
||||||
@ -350,7 +365,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
|||||||
exprToSearch += TEXT(")");
|
exprToSearch += TEXT(")");
|
||||||
|
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
int targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
int targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
||||||
@ -386,21 +401,21 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
|||||||
return targetEnd;
|
return targetEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionZoneParser::classParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair<int, int> > &scannedZone, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||||
{
|
{
|
||||||
if (begin >= end)
|
if (begin >= end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
(*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;
|
||||||
|
|
||||||
//foundInfos.clear();
|
|
||||||
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;
|
||||||
@ -429,12 +444,80 @@ void FunctionZoneParser::classParse(std::vector<foundInfo> & foundInfos, size_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FunctionParser::getCommentZones(vector< pair<int, int> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView)
|
||||||
|
{
|
||||||
|
if ((begin >= end) || (_commentExpr == TEXT("")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||||
|
|
||||||
|
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
|
int targetStart = (*ppEditView)->searchInTarget(_commentExpr.c_str(), _commentExpr.length(), begin, end);
|
||||||
|
int targetEnd = 0;
|
||||||
|
|
||||||
|
while (targetStart != -1 && targetStart != -2)
|
||||||
|
{
|
||||||
|
targetStart = int((*ppEditView)->execute(SCI_GETTARGETSTART));
|
||||||
|
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||||
|
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
commentZone.push_back(pair<int, int>(targetStart, targetEnd));
|
||||||
|
|
||||||
|
int foundTextLen = targetEnd - targetStart;
|
||||||
|
if (targetStart + foundTextLen == int(end))
|
||||||
|
break;
|
||||||
|
|
||||||
|
begin = targetStart + foundTextLen;
|
||||||
|
targetStart = (*ppEditView)->searchInTarget(_commentExpr.c_str(), _commentExpr.length(), begin, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vector< pair<int, int> > & sourceZones, size_t begin, size_t end)
|
||||||
|
{
|
||||||
|
if (sourceZones.size() == 0)
|
||||||
|
{
|
||||||
|
destZones.push_back(pair<int, int>(begin, end));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// todo : check the begin
|
||||||
|
size_t i = 0;
|
||||||
|
for (; i < sourceZones.size() - 1; i++)
|
||||||
|
{
|
||||||
|
int newBegin = sourceZones[i].second + 1;
|
||||||
|
int newEnd = sourceZones[i+1].first - 1;
|
||||||
|
if (newBegin < newEnd)
|
||||||
|
destZones.push_back(pair<int, int>(newBegin, newEnd));
|
||||||
|
}
|
||||||
|
int lastBegin = sourceZones[i].second + 1;
|
||||||
|
if (lastBegin < int(end))
|
||||||
|
destZones.push_back(pair<int, int>(lastBegin, end));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
classParse(foundInfos, begin, end, ppEditView, classStructName);
|
vector< pair<int, int> > 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionUnitParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
void FunctionUnitParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||||
{
|
{
|
||||||
funcParse(foundInfos, begin, end, ppEditView, classStructName);
|
vector< pair<int, int> > commentZones, nonCommentZones;
|
||||||
|
getCommentZones(commentZones, begin, end, ppEditView);
|
||||||
|
getInvertZones(nonCommentZones, commentZones, begin, end);
|
||||||
|
for (size_t i = 0; i < nonCommentZones.size(); i++)
|
||||||
|
{
|
||||||
|
funcParse(foundInfos, nonCommentZones[i].first, nonCommentZones[i].second, ppEditView, classStructName);
|
||||||
|
}
|
||||||
}
|
}
|
@ -42,26 +42,29 @@ struct foundInfo {
|
|||||||
class FunctionParser {
|
class FunctionParser {
|
||||||
friend class FunctionParsersManager;
|
friend class FunctionParsersManager;
|
||||||
public:
|
public:
|
||||||
FunctionParser(const TCHAR *id, const TCHAR *displayName, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, std::vector<generic_string> classNameExprArray):
|
FunctionParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr, generic_string functionExpr, std::vector<generic_string> functionNameExprArray, std::vector<generic_string> classNameExprArray):
|
||||||
_id(id), _displayName(displayName), _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(""));
|
||||||
protected:
|
protected:
|
||||||
generic_string _id;
|
generic_string _id;
|
||||||
generic_string _displayName;
|
generic_string _displayName;
|
||||||
|
generic_string _commentExpr;
|
||||||
generic_string _functionExpr;
|
generic_string _functionExpr;
|
||||||
std::vector<generic_string> _functionNameExprArray;
|
std::vector<generic_string> _functionNameExprArray;
|
||||||
std::vector<generic_string> _classNameExprArray;
|
std::vector<generic_string> _classNameExprArray;
|
||||||
|
void getCommentZones(std::vector< std::pair<int, int> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView);
|
||||||
|
void getInvertZones(std::vector< std::pair<int, int> > & destZones, std::vector< std::pair<int, int> > & sourceZones, size_t begin, size_t end);
|
||||||
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos, ScintillaEditView **ppEditView);
|
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos, ScintillaEditView **ppEditView);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class FunctionZoneParser : public FunctionParser {
|
class FunctionZoneParser : public FunctionParser {
|
||||||
public:
|
public:
|
||||||
FunctionZoneParser(const TCHAR *id, const TCHAR *displayName, generic_string rangeExpr, generic_string openSymbole, generic_string closeSymbole,
|
FunctionZoneParser(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):
|
std::vector<generic_string> classNameExprArray, generic_string functionExpr, std::vector<generic_string> functionNameExprArray):
|
||||||
FunctionParser(id, displayName, functionExpr, functionNameExprArray, classNameExprArray), _rangeExpr(rangeExpr), _openSymbole(openSymbole), _closeSymbole(closeSymbole) {};
|
FunctionParser(id, displayName, commentExpr, functionExpr, functionNameExprArray, classNameExprArray), _rangeExpr(rangeExpr), _openSymbole(openSymbole), _closeSymbole(closeSymbole) {};
|
||||||
|
|
||||||
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(""));
|
||||||
|
|
||||||
@ -74,15 +77,15 @@ private:
|
|||||||
generic_string _functionExpr;
|
generic_string _functionExpr;
|
||||||
//std::vector<generic_string> _functionNameExprArray;
|
//std::vector<generic_string> _functionNameExprArray;
|
||||||
|
|
||||||
void classParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
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,
|
FunctionUnitParser(const TCHAR *id, const TCHAR *displayName, const TCHAR *commentExpr,
|
||||||
generic_string mainExpr, std::vector<generic_string> functionNameExprArray,
|
generic_string mainExpr, std::vector<generic_string> functionNameExprArray,
|
||||||
std::vector<generic_string> classNameExprArray): FunctionParser(id, displayName, mainExpr, functionNameExprArray, classNameExprArray){};
|
std::vector<generic_string> classNameExprArray): FunctionParser(id, displayName, commentExpr, mainExpr, functionNameExprArray, classNameExprArray){};
|
||||||
|
|
||||||
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(""));
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
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]+"/>
|
||||||
@ -33,7 +34,24 @@
|
|||||||
</parser>
|
</parser>
|
||||||
<parser id="c_cpp_function" displayName="C++/C source">
|
<parser id="c_cpp_function" displayName="C++/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)[\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">
|
||||||
|
<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">
|
displayMode="$className->$functionName">
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
<nameExpr expr="(?!(if|whil|for))[\w_]+[\s]*\("/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user