work save
This commit is contained in:
parent
f78a4953ef
commit
ab9aa75d1f
|
@ -296,18 +296,18 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement)
|
|||
case StatementKind::skFunction:
|
||||
case StatementKind::skConstructor:
|
||||
case StatementKind::skDestructor:
|
||||
if (statement->scope == StatementScope::ssGlobal)
|
||||
if (statement->scope == StatementScope::Global)
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_GLOBAL_METHOD));
|
||||
if (statement->isInherited) {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
if (statement->classScope == StatementClassScope::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTED_METHOD));
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
} else if (statement->classScope == StatementClassScope::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_METHOD));
|
||||
}
|
||||
} else {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
if (statement->classScope == StatementClassScope::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PROTECTED_METHOD));
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
} else if (statement->classScope == StatementClassScope::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PUBLIC_METHOD));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_METHOD));
|
||||
|
@ -320,15 +320,15 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement)
|
|||
return *(pIconsManager->getPixmap(IconsManager::PARSER_LOCAL_VAR));
|
||||
case StatementKind::skVariable:
|
||||
if (statement->isInherited) {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
if (statement->classScope == StatementClassScope::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTD_VAR));
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
} else if (statement->classScope == StatementClassScope::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_VAR));
|
||||
}
|
||||
} else {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
if (statement->classScope == StatementClassScope::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PROTECTED_VAR));
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
} else if (statement->classScope == StatementClassScope::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PUBLIC_VAR));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_VAR));
|
||||
|
|
|
@ -913,8 +913,8 @@ void CppParser::parseHardDefines()
|
|||
define->value,
|
||||
-1,
|
||||
StatementKind::skPreprocessor,
|
||||
StatementScope::ssGlobal,
|
||||
StatementClassScope::scsNone,
|
||||
StatementScope::Global,
|
||||
StatementClassScope::None,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
|
@ -992,11 +992,11 @@ bool CppParser::isFileParsed(const QString &filename)
|
|||
|
||||
QString CppParser::getScopePrefix(const PStatement& statement){
|
||||
switch (statement->classScope) {
|
||||
case StatementClassScope::scsPublic:
|
||||
case StatementClassScope::Public:
|
||||
return "public";
|
||||
case StatementClassScope::scsPrivate:
|
||||
case StatementClassScope::Private:
|
||||
return "private";
|
||||
case StatementClassScope::scsProtected:
|
||||
case StatementClassScope::Protected:
|
||||
return "protected";
|
||||
default:
|
||||
return "";
|
||||
|
@ -1048,7 +1048,7 @@ QString CppParser::prettyPrintStatement(const PStatement& statement, const QStri
|
|||
case StatementKind::skVariable:
|
||||
case StatementKind::skParameter:
|
||||
case StatementKind::skClass:
|
||||
if (statement->scope!= StatementScope::ssLocal)
|
||||
if (statement->scope!= StatementScope::Local)
|
||||
result = getScopePrefix(statement)+ ' '; // public
|
||||
result += statement->type + ' '; // void
|
||||
result += statement->fullName; // A::B::C::Bar
|
||||
|
@ -1249,7 +1249,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
|
|||
//result->friends;
|
||||
result->isStatic = isStatic;
|
||||
result->isInherited = false;
|
||||
if (scope == StatementScope::ssLocal)
|
||||
if (scope == StatementScope::Local)
|
||||
result->fullName = newCommand;
|
||||
else
|
||||
result->fullName = getFullStatementName(newCommand, parent);
|
||||
|
@ -1351,7 +1351,7 @@ PStatement CppParser::addStatement(const PStatement &parent, const QString &file
|
|||
void CppParser::setInheritance(int index, const PStatement& classStatement, bool isStruct)
|
||||
{
|
||||
// Clear it. Assume it is assigned
|
||||
StatementClassScope lastInheritScopeType = StatementClassScope::scsNone;
|
||||
StatementClassScope lastInheritScopeType = StatementClassScope::None;
|
||||
// Assemble a list of statements in text form we inherit from
|
||||
while (true) {
|
||||
StatementClassScope inheritScopeType = getClassScope(mTokenizer[index]->text);
|
||||
|
@ -1359,7 +1359,7 @@ void CppParser::setInheritance(int index, const PStatement& classStatement, bool
|
|||
if (currentText=='(') {
|
||||
//skip to matching ')'
|
||||
index=mTokenizer[index]->matchIndex;
|
||||
} else if (inheritScopeType == StatementClassScope::scsNone) {
|
||||
} else if (inheritScopeType == StatementClassScope::None) {
|
||||
if (currentText.front()!=','
|
||||
&& currentText.front()!=':') {
|
||||
QString basename = currentText;
|
||||
|
@ -1429,13 +1429,13 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe
|
|||
|
||||
// Set new scope
|
||||
if (!statement)
|
||||
mClassScope = StatementClassScope::scsNone; // {}, namespace or class that doesn't exist
|
||||
mClassScope = StatementClassScope::None; // {}, namespace or class that doesn't exist
|
||||
else if (statement->kind == StatementKind::skNamespace)
|
||||
mClassScope = StatementClassScope::scsNone;
|
||||
mClassScope = StatementClassScope::None;
|
||||
else if (statement->type == "class")
|
||||
mClassScope = StatementClassScope::scsPrivate; // classes are private by default
|
||||
mClassScope = StatementClassScope::Private; // classes are private by default
|
||||
else
|
||||
mClassScope = StatementClassScope::scsPublic; // structs are public by default
|
||||
mClassScope = StatementClassScope::Public; // structs are public by default
|
||||
mCurrentClassScope.append(mClassScope);
|
||||
}
|
||||
|
||||
|
@ -1468,7 +1468,7 @@ void CppParser::removeScopeLevel(int line)
|
|||
}
|
||||
|
||||
if (!currentScope) {
|
||||
mClassScope = StatementClassScope::scsNone;
|
||||
mClassScope = StatementClassScope::None;
|
||||
} else {
|
||||
mClassScope = mCurrentClassScope.back();
|
||||
}
|
||||
|
@ -1479,7 +1479,7 @@ void CppParser::internalClear()
|
|||
mCurrentScope.clear();
|
||||
mCurrentClassScope.clear();
|
||||
mIndex = 0;
|
||||
mClassScope = StatementClassScope::scsNone;
|
||||
mClassScope = StatementClassScope::None;
|
||||
mSkipList.clear();
|
||||
mBlockBeginSkips.clear();
|
||||
mBlockEndSkips.clear();
|
||||
|
@ -1543,21 +1543,22 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet<QString> &files)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool CppParser::checkForKeyword(SkipType& skipType)
|
||||
bool CppParser::checkForKeyword(KeywordType& keywordType)
|
||||
{
|
||||
skipType = mCppKeywords.value(mTokenizer[mIndex]->text,SkipType::skNone);
|
||||
switch(skipType) {
|
||||
case SkipType::skCatch:
|
||||
case SkipType::skFor:
|
||||
case SkipType::skNone:
|
||||
case SkipType::skScope:
|
||||
case SkipType::skEnum:
|
||||
case SkipType::skInline:
|
||||
case SkipType::skNamespace:
|
||||
case SkipType::skTypedef:
|
||||
case SkipType::skUsing:
|
||||
case SkipType::skFriend:
|
||||
case SkipType::skProtected:
|
||||
keywordType = mCppKeywords.value(mTokenizer[mIndex]->text,KeywordType::None);
|
||||
switch(keywordType) {
|
||||
case KeywordType::Catch:
|
||||
case KeywordType::For:
|
||||
case KeywordType::None:
|
||||
case KeywordType::Public:
|
||||
case KeywordType::Private:
|
||||
case KeywordType::Enum:
|
||||
case KeywordType::Inline:
|
||||
case KeywordType::Namespace:
|
||||
case KeywordType::Typedef:
|
||||
case KeywordType::Using:
|
||||
case KeywordType::Friend:
|
||||
case KeywordType::Protected:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -1565,7 +1566,7 @@ bool CppParser::checkForKeyword(SkipType& skipType)
|
|||
}
|
||||
|
||||
bool CppParser::checkForMethod(QString &sType, QString &sName, int &argStartIndex,
|
||||
int &argEndIndex, , bool &isStatic, bool &isFriend)
|
||||
int &argEndIndex, bool &isStatic, bool &isFriend)
|
||||
{
|
||||
PStatement scope = getCurrentScope();
|
||||
|
||||
|
@ -1624,7 +1625,7 @@ bool CppParser::checkForMethod(QString &sType, QString &sName, int &argStartInde
|
|||
bTypeOK = !sType.isEmpty();
|
||||
bNameOK = !sName.isEmpty();
|
||||
bArgsOK = true;
|
||||
mIndex = argEndIndex;
|
||||
mIndex = argEndIndex+1;
|
||||
|
||||
// Allow constructor/destructor too
|
||||
if (!bTypeOK) {
|
||||
|
@ -1654,7 +1655,7 @@ bool CppParser::checkForMethod(QString &sType, QString &sName, int &argStartInde
|
|||
} else {
|
||||
//if IsValidIdentifier(mTokenizer[mIndex]->text) then
|
||||
// Still walking through type
|
||||
QString s = mTokenizer[mIndex]->text; //todo: do we really need expand macro? it should be done in preprocessor
|
||||
QString s = mTokenizer[mIndex]->text;
|
||||
if (s == "static")
|
||||
isStatic = true;
|
||||
if (s == "friend")
|
||||
|
@ -1666,22 +1667,22 @@ bool CppParser::checkForMethod(QString &sType, QString &sName, int &argStartInde
|
|||
mIndex++;
|
||||
}
|
||||
|
||||
mIndex = indexBackup;
|
||||
|
||||
// Correct function, don't jump over
|
||||
if (bTypeOK && bNameOK && bArgsOK) {
|
||||
sType = sType.trimmed(); // should contain type "int"
|
||||
sName = sName.trimmed(); // should contain function name "foo::function"
|
||||
return true;
|
||||
} else
|
||||
} else {
|
||||
mIndex = indexBackup;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CppParser::checkForNamespace(SkipType skipType)
|
||||
bool CppParser::checkForNamespace(KeywordType keywordType)
|
||||
{
|
||||
return (skipType==SkipType::skNamespace &&(mIndex < mTokenizer.tokenCount()-1))
|
||||
return (keywordType==KeywordType::Namespace &&(mIndex < mTokenizer.tokenCount()-1))
|
||||
|| (
|
||||
skipType==SkipType::skInline
|
||||
keywordType==KeywordType::Inline
|
||||
&& (mIndex+1 < mTokenizer.tokenCount()-1)
|
||||
&&mTokenizer[mIndex+1]->text == "namespace"
|
||||
);
|
||||
|
@ -1689,14 +1690,13 @@ bool CppParser::checkForNamespace(SkipType skipType)
|
|||
|
||||
bool CppParser::checkForPreprocessor()
|
||||
{
|
||||
// return (mIndex < mTokenizer.tokenCount())
|
||||
// && ( "#" == mTokenizer[mIndex]->text);
|
||||
return (mTokenizer[mIndex]->text.startsWith('#'));
|
||||
}
|
||||
|
||||
bool CppParser::checkForScope(SkipType skipType)
|
||||
bool CppParser::checkForScope(KeywordType keywordType)
|
||||
{
|
||||
return ( (skipType == SkipType::skScope || skipType == SkipType::skProtected)
|
||||
return ( (keywordType == KeywordType::Public || keywordType == KeywordType::Protected
|
||||
|| keywordType == KeywordType::Private)
|
||||
&& mIndex+1 < mTokenizer.tokenCount()
|
||||
&& mTokenizer[mIndex + 1]->text == ':'
|
||||
);
|
||||
|
@ -1706,18 +1706,21 @@ void CppParser::checkForSkipStatement()
|
|||
{
|
||||
if ((mSkipList.count()>0) && (mIndex == mSkipList.back())) { // skip to next ';'
|
||||
do {
|
||||
mIndex++;
|
||||
if (isLeftParenthesis(mTokenizer[mIndex]->text))
|
||||
mIndex=mTokenizer[mIndex]->matchIndex+1;
|
||||
else
|
||||
mIndex++;
|
||||
} while ((mIndex < mTokenizer.tokenCount()) && (mTokenizer[mIndex]->text[0] != ';'));
|
||||
mIndex++; //skip ';'
|
||||
mSkipList.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
bool CppParser::checkForStructs(SkipType skipType)
|
||||
bool CppParser::checkForStructs(KeywordType keywordType)
|
||||
{
|
||||
int dis = 0;
|
||||
if (skipType == SkipType::skFriend
|
||||
|| skipType == SkipType::skScope)
|
||||
if (keywordType == KeywordType::Friend
|
||||
|| keywordType == KeywordType::Scope)
|
||||
dis = 1;
|
||||
if (mIndex >= mTokenizer.tokenCount() - 2 - dis)
|
||||
return false;
|
||||
|
@ -1787,9 +1790,9 @@ bool CppParser::checkForTypedefStruct()
|
|||
return (word.length() == keyLen) || isSpaceChar(word[keyLen]) || word[keyLen]=='[';
|
||||
}
|
||||
|
||||
bool CppParser::checkForUsing(SkipType skipType)
|
||||
bool CppParser::checkForUsing(KeywordType keywordType)
|
||||
{
|
||||
return skipType==SkipType::skUsing == (mIndex < mTokenizer.tokenCount()-1);
|
||||
return keywordType==KeywordType::Using && (mIndex < mTokenizer.tokenCount()-1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1801,13 +1804,13 @@ bool CppParser::checkForVar(bool& isFunctionPointer)
|
|||
|
||||
// Store old index
|
||||
int indexBackup = mIndex;
|
||||
SkipType skipType;
|
||||
KeywordType keywordType;
|
||||
|
||||
// Use mIndex so we can reuse checking functions
|
||||
if (mIndex + 1 < mTokenizer.tokenCount()) {
|
||||
// Check the current and the next token
|
||||
for (int i = 0; i<=1; i++) {
|
||||
if (checkForKeyword(skipType)
|
||||
if (checkForKeyword(keywordType)
|
||||
|| isInvalidVarPrefixChar(mTokenizer[mIndex]->text.front())
|
||||
|| (mTokenizer[mIndex]->text.back() == '.')
|
||||
|| (
|
||||
|
@ -1846,7 +1849,7 @@ bool CppParser::checkForVar(bool& isFunctionPointer)
|
|||
while (mIndex < mTokenizer.tokenCount()) {
|
||||
if (mTokenizer[mIndex]->text.front() == '#'
|
||||
|| mTokenizer[mIndex]->text == '}'
|
||||
|| checkForKeyword(skipType)) {
|
||||
|| checkForKeyword(keywordType)) {
|
||||
break; // fail
|
||||
} else if (mTokenizer[mIndex]->text.front() == ','
|
||||
|| mTokenizer[mIndex]->text.front() == ';'
|
||||
|
@ -1963,11 +1966,11 @@ StatementScope CppParser::getScope()
|
|||
|
||||
// Invalid class or namespace/extern
|
||||
if (!currentScope || (currentScope->kind == StatementKind::skNamespace))
|
||||
return StatementScope::ssGlobal;
|
||||
return StatementScope::Global;
|
||||
else if (currentScope->kind == StatementKind::skClass)
|
||||
return StatementScope::ssClassLocal;
|
||||
return StatementScope::ClassLocal;
|
||||
else
|
||||
return StatementScope::ssLocal;
|
||||
return StatementScope::Local;
|
||||
}
|
||||
|
||||
QString CppParser::getStatementKey(const QString &sName, const QString &sType, const QString &sNoNameArgs)
|
||||
|
@ -2008,21 +2011,18 @@ void CppParser::handleCatchBlock()
|
|||
if (!((mIndex < mTokenizer.tokenCount()) && (mTokenizer[mIndex]->text.startsWith('('))))
|
||||
return;
|
||||
//skip params
|
||||
int i2=mIndex+1;
|
||||
int i2=mTokenizer[mIndex]->matchIndex+1;
|
||||
if (i2>=mTokenizer.tokenCount())
|
||||
return;
|
||||
if (mTokenizer[i2]->text.startsWith('{')) {
|
||||
mBlockBeginSkips.append(i2);
|
||||
int i = skipBraces(i2);
|
||||
if (i==i2) {
|
||||
mBlockEndSkips.append(mTokenizer.tokenCount());
|
||||
} else {
|
||||
mBlockEndSkips.append(i);
|
||||
}
|
||||
int i = indexOfMatchingBrace(i2);
|
||||
// if (i==i2) {
|
||||
// mBlockEndSkips.append(mTokenizer.tokenCount());
|
||||
// } else {
|
||||
mBlockEndSkips.append(i);
|
||||
} else {
|
||||
int i=i2;
|
||||
while ((i<mTokenizer.tokenCount()) && !mTokenizer[i]->text.startsWith(';'))
|
||||
i++;
|
||||
int i=indexOfNextSemicolon(i2);
|
||||
mBlockEndSkips.append(i);
|
||||
}
|
||||
// add a block
|
||||
|
@ -2041,8 +2041,9 @@ void CppParser::handleCatchBlock()
|
|||
true,
|
||||
false);
|
||||
addSoloScopeLevel(block,startLine,false);
|
||||
if (!mTokenizer[mIndex]->text.contains("..."))
|
||||
scanMethodArgs(block,mTokenizer[mIndex]->text);
|
||||
if (!mTokenizer[mIndex+1]->text.contains("..."))
|
||||
scanMethodArgs(block,mIndex, mTokenizer[mIndex]->matchIndex);
|
||||
mIndex=mTokenizer[mIndex]->matchIndex+1;
|
||||
}
|
||||
|
||||
void CppParser::handleEnum()
|
||||
|
@ -2061,7 +2062,7 @@ void CppParser::handleEnum()
|
|||
}
|
||||
if ((mIndex< mTokenizer.tokenCount()) && mTokenizer[mIndex]->text.startsWith('{')) { // enum {...} NAME
|
||||
// Skip to the closing brace
|
||||
int i = skipBraces(mIndex);
|
||||
int i = indexOfMatchingBrace(mIndex);
|
||||
// Have we found the name?
|
||||
if ((i + 1 < mTokenizer.tokenCount()) && mTokenizer[i]->text.startsWith('}')) {
|
||||
if (!mTokenizer[i + 1]->text.startsWith(';'))
|
||||
|
@ -2212,25 +2213,20 @@ void CppParser::handleForBlock()
|
|||
mIndex++; // skip for/catch;
|
||||
if (!(mIndex < mTokenizer.tokenCount()))
|
||||
return;
|
||||
int i=mIndex;
|
||||
while ((i<mTokenizer.tokenCount()) && !mTokenizer[i]->text.startsWith(';'))
|
||||
i++;
|
||||
if (i>=mTokenizer.tokenCount())
|
||||
return;
|
||||
int i=indexOfNextSemicolon(mIndex);
|
||||
int i2 = i+1; //skip over ';' (tokenizer have change for(;;) to for(;)
|
||||
if (i2>=mTokenizer.tokenCount())
|
||||
return;
|
||||
if (mTokenizer[i2]->text.startsWith('{')) {
|
||||
mBlockBeginSkips.append(i2);
|
||||
i=skipBraces(i2);
|
||||
if (i==i2)
|
||||
mBlockEndSkips.append(mTokenizer.tokenCount());
|
||||
else
|
||||
mBlockEndSkips.append(i);
|
||||
i=indexOfMatchingBrace(i2);
|
||||
// tokenizer will handle unbalanced braces, no need check here
|
||||
// if (i==i2)
|
||||
// mBlockEndSkips.append(mTokenizer.tokenCount());
|
||||
// else
|
||||
mBlockEndSkips.append(i);
|
||||
} else {
|
||||
i=i2;
|
||||
while ((i<mTokenizer.tokenCount()) && !mTokenizer[i]->text.startsWith(';'))
|
||||
i++;
|
||||
i=indexOfNextSemicolon(i2);
|
||||
mBlockEndSkips.append(i);
|
||||
}
|
||||
// add a block
|
||||
|
@ -2252,41 +2248,33 @@ void CppParser::handleForBlock()
|
|||
addSoloScopeLevel(block,startLine);
|
||||
}
|
||||
|
||||
void CppParser::handleKeyword(SkipType skipType)
|
||||
void CppParser::handleKeyword(KeywordType skipType)
|
||||
{
|
||||
// Skip
|
||||
switch (skipType) {
|
||||
case SkipType::skItself:
|
||||
case KeywordType::SkipItself:
|
||||
// skip it;
|
||||
mIndex++;
|
||||
break;
|
||||
case SkipType::skToSemicolon:
|
||||
// Skip to ;
|
||||
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith(';'))
|
||||
mIndex++;
|
||||
mIndex++;// step over
|
||||
case KeywordType::SkipAfterSemicolon:
|
||||
// Skip to ; and over it
|
||||
mIndex = indexOfNextSemicolon(mIndex)+1;
|
||||
break;
|
||||
case SkipType::skToColon:
|
||||
// Skip to :
|
||||
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith(':'))
|
||||
mIndex++;
|
||||
case KeywordType::SkipAfterColon:
|
||||
// Skip to : and over it
|
||||
mIndex = indexOfNextColon(mIndex)+1;
|
||||
break;
|
||||
case SkipType::skToRightParenthesis:
|
||||
// skip to )
|
||||
while (mIndex < mTokenizer.tokenCount() && mTokenizer[mIndex]->text!=')')
|
||||
mIndex++;
|
||||
mIndex++; // step over
|
||||
case KeywordType::SkipAfterParenthesis:
|
||||
// skip pass ()
|
||||
mIndex = indexPassParenthesis(mIndex);
|
||||
break;
|
||||
case SkipType::skToLeftBrace:
|
||||
case KeywordType::SkipToLeftBrace:
|
||||
// Skip to {
|
||||
while (mIndex < mTokenizer.tokenCount() && mTokenizer[mIndex]->text!='{')
|
||||
mIndex++;
|
||||
mIndex = indexOfNextLeftBrace(mIndex);
|
||||
break;
|
||||
case SkipType::skToRightBrace:
|
||||
// Skip to }
|
||||
while (mIndex < mTokenizer.tokenCount() && mTokenizer[mIndex]->text!='}')
|
||||
mIndex++;
|
||||
mIndex++; // step over
|
||||
case KeywordType::SkipAfterBrace:
|
||||
// Skip pass {}
|
||||
mIndex = indexPassBraces(mIndex);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2300,12 +2288,6 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, int arg
|
|||
int i = mIndex;
|
||||
int startLine = mTokenizer[mIndex]->line;
|
||||
|
||||
// Skip over argument list
|
||||
while ((mIndex < mTokenizer.tokenCount()) && ! (
|
||||
isblockChar(mTokenizer[mIndex]->text.front())
|
||||
|| mTokenizer[mIndex]->text.startsWith(':')))
|
||||
mIndex++;
|
||||
|
||||
if (mIndex >= mTokenizer.tokenCount()) // not finished define, just skip it;
|
||||
return;
|
||||
|
||||
|
@ -2395,8 +2377,8 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, int arg
|
|||
"",
|
||||
startLine,
|
||||
StatementKind::skVariable,
|
||||
StatementScope::ssLocal,
|
||||
StatementClassScope::scsNone,
|
||||
StatementScope::Local,
|
||||
StatementClassScope::None,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
|
@ -2411,8 +2393,8 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, int arg
|
|||
"\""+scopelessName+"\"",
|
||||
startLine+1,
|
||||
StatementKind::skVariable,
|
||||
StatementScope::ssLocal,
|
||||
StatementClassScope::scsNone,
|
||||
StatementScope::Local,
|
||||
StatementClassScope::None,
|
||||
true,
|
||||
false);
|
||||
} else {
|
||||
|
@ -2448,20 +2430,14 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, int arg
|
|||
mIndex++;
|
||||
}
|
||||
|
||||
if (i == mIndex) { // if not moved ahead, something is wrong but don't get stuck ;)
|
||||
if ( (mIndex < mTokenizer.tokenCount()) &&
|
||||
! isBraceChar(mTokenizer[mIndex]->text.front())) {
|
||||
mIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CppParser::handleNamespace(SkipType skipType)
|
||||
void CppParser::handleNamespace(KeywordType skipType)
|
||||
{
|
||||
bool isInline=false;
|
||||
int startLine = mTokenizer[mIndex]->line;
|
||||
|
||||
if (skipType==SkipType::skInline) {
|
||||
if (skipType==KeywordType::Inline) {
|
||||
isInline = true;
|
||||
mIndex++; //skip 'inline'
|
||||
}
|
||||
|
@ -2510,7 +2486,7 @@ void CppParser::handleNamespace(SkipType skipType)
|
|||
// Skip to '{'
|
||||
while ((mIndex<mTokenizer.tokenCount()) && (mTokenizer[mIndex]->text.front() != '{'))
|
||||
mIndex++;
|
||||
int i =skipBraces(mIndex); //skip '}'
|
||||
int i =indexOfMatchingBrace(mIndex); //skip '}'
|
||||
if (i==mIndex)
|
||||
mInlineNamespaceEndSkips.append(mTokenizer.tokenCount());
|
||||
else
|
||||
|
@ -2720,8 +2696,8 @@ void CppParser::handlePreprocessor()
|
|||
value,
|
||||
mTokenizer[mIndex]->line,
|
||||
StatementKind::skPreprocessor,
|
||||
StatementScope::ssGlobal,
|
||||
StatementClassScope::scsNone,
|
||||
StatementScope::Global,
|
||||
StatementClassScope::None,
|
||||
true,
|
||||
false);
|
||||
} // TODO: undef ( define has limited scope)
|
||||
|
@ -2732,18 +2708,32 @@ handlePreprocessorEnd:
|
|||
StatementClassScope CppParser::getClassScope(const QString& text) {
|
||||
if (!text.isEmpty() && text[0]=='p') {
|
||||
if (text=="public")
|
||||
return StatementClassScope::scsPublic;
|
||||
return StatementClassScope::Public;
|
||||
else if (text=="private")
|
||||
return StatementClassScope::scsPrivate;
|
||||
return StatementClassScope::Private;
|
||||
else if (text=="protected")
|
||||
return StatementClassScope::scsProtected;
|
||||
return StatementClassScope::Protected;
|
||||
}
|
||||
return StatementClassScope::scsNone;
|
||||
return StatementClassScope::None;
|
||||
}
|
||||
|
||||
void CppParser::handleScope()
|
||||
StatementClassScope CppParser::getClassScope(KeywordType keywordType)
|
||||
{
|
||||
mClassScope = getClassScope(mTokenizer[mIndex]->text);
|
||||
switch(keywordType) {
|
||||
case KeywordType::Public:
|
||||
return StatementClassScope::Public;
|
||||
case KeywordType::Private:
|
||||
return StatementClassScope::Private;
|
||||
case KeywordType::Protected:
|
||||
return StatementClassScope::Protected;
|
||||
default:
|
||||
return StatementClassScope::None;
|
||||
}
|
||||
}
|
||||
|
||||
void CppParser::handleScope(KeywordType keywordType)
|
||||
{
|
||||
mClassScope = getClassScope(keywordType);
|
||||
mIndex+=2; // the scope is followed by a ':'
|
||||
}
|
||||
|
||||
|
@ -2755,7 +2745,7 @@ bool CppParser::handleStatement()
|
|||
int idx=getCurrentBlockEndSkip();
|
||||
int idx2=getCurrentBlockBeginSkip();
|
||||
int idx3=getCurrentInlineNamespaceEndSkip();
|
||||
SkipType skipType;
|
||||
KeywordType keywordType;
|
||||
bool isFunctionPointer;
|
||||
if (mIndex >= idx2) {
|
||||
//skip (previous handled) block begin
|
||||
|
@ -2799,17 +2789,17 @@ bool CppParser::handleStatement()
|
|||
mIndex++;
|
||||
} else if (checkForPreprocessor()) {
|
||||
handlePreprocessor();
|
||||
} else if (checkForKeyword(skipType)) { // includes template now
|
||||
handleKeyword(skipType);
|
||||
} else if (skipType==SkipType::skFor) { // (for/catch)
|
||||
} else if (checkForKeyword(keywordType)) { // includes template now
|
||||
handleKeyword(keywordType);
|
||||
} else if (keywordType==KeywordType::For) { // (for/catch)
|
||||
handleForBlock();
|
||||
} else if (skipType==SkipType::skCatch) { // (for/catch)
|
||||
} else if (keywordType==KeywordType::Catch) { // (for/catch)
|
||||
handleCatchBlock();
|
||||
} else if (checkForScope(skipType)) { // public /private/proteced
|
||||
handleScope();
|
||||
} else if (skipType==SkipType::skEnum) {
|
||||
} else if (checkForScope(keywordType)) { // public /private/proteced
|
||||
handleScope(keywordType);
|
||||
} else if (keywordType==KeywordType::Enum) {
|
||||
handleEnum();
|
||||
} else if (skipType==SkipType::skTypedef) {
|
||||
} else if (keywordType==KeywordType::Typedef) {
|
||||
if (mIndex+1 < mTokenizer.tokenCount()) {
|
||||
if (checkForTypedefStruct()) { // typedef struct something
|
||||
mIndex++; // skip 'typedef'
|
||||
|
@ -2821,11 +2811,11 @@ bool CppParser::handleStatement()
|
|||
handleOtherTypedefs(); // typedef Foo Bar
|
||||
} else
|
||||
mIndex++;
|
||||
} else if (checkForNamespace(skipType)) {
|
||||
handleNamespace(skipType);
|
||||
} else if (checkForUsing(skipType)) {
|
||||
} else if (checkForNamespace(keywordType)) {
|
||||
handleNamespace(keywordType);
|
||||
} else if (checkForUsing(keywordType)) {
|
||||
handleUsing();
|
||||
} else if (checkForStructs(skipType)) {
|
||||
} else if (checkForStructs(keywordType)) {
|
||||
handleStructs(false);
|
||||
} else if (checkForMethod(funcType, funcName, argStart,argEnd, isStatic, isFriend)) {
|
||||
handleMethod(funcType, funcName, argStart, argEnd, isStatic, isFriend); // don't recalculate parts
|
||||
|
@ -2989,7 +2979,7 @@ void CppParser::handleStructs(bool isTypedef)
|
|||
if (isStruct) {
|
||||
|
||||
// Walk to closing brace
|
||||
i = skipBraces(mIndex); // step onto closing brace
|
||||
i = indexOfMatchingBrace(mIndex); // step onto closing brace
|
||||
|
||||
if ((i + 1 < mTokenizer.tokenCount()) && !(
|
||||
mTokenizer[i + 1]->text.front() == ';'
|
||||
|
@ -3358,7 +3348,7 @@ void CppParser::handleVar(bool isFunctionPointer)
|
|||
if (varAdded && (mIndex < mTokenizer.tokenCount())
|
||||
&& (mTokenizer[mIndex]->text == '{')) {
|
||||
// skip { } like A x {new A};
|
||||
int i=skipBraces(mIndex);
|
||||
int i=indexOfMatchingBrace(mIndex);
|
||||
if (i!=mIndex)
|
||||
mIndex = i+1;
|
||||
}
|
||||
|
@ -3432,30 +3422,30 @@ void CppParser::inheritClassStatement(const PStatement& derived, bool isStruct,
|
|||
const PStatement& base, StatementClassScope access)
|
||||
{
|
||||
//differentiate class and struct
|
||||
if (access == StatementClassScope::scsNone) {
|
||||
if (access == StatementClassScope::None) {
|
||||
if (isStruct)
|
||||
access = StatementClassScope::scsPublic;
|
||||
access = StatementClassScope::Public;
|
||||
else
|
||||
access = StatementClassScope::scsPrivate;
|
||||
access = StatementClassScope::Private;
|
||||
}
|
||||
foreach (const PStatement& statement, base->children) {
|
||||
if (statement->classScope == StatementClassScope::scsPrivate
|
||||
if (statement->classScope == StatementClassScope::Private
|
||||
|| statement->kind == StatementKind::skConstructor
|
||||
|| statement->kind == StatementKind::skDestructor)
|
||||
continue;
|
||||
StatementClassScope m_acc;
|
||||
switch(access) {
|
||||
case StatementClassScope::scsPublic:
|
||||
case StatementClassScope::Public:
|
||||
m_acc = statement->classScope;
|
||||
break;
|
||||
case StatementClassScope::scsProtected:
|
||||
m_acc = StatementClassScope::scsProtected;
|
||||
case StatementClassScope::Protected:
|
||||
m_acc = StatementClassScope::Protected;
|
||||
break;
|
||||
case StatementClassScope::scsPrivate:
|
||||
m_acc = StatementClassScope::scsPrivate;
|
||||
case StatementClassScope::Private:
|
||||
m_acc = StatementClassScope::Private;
|
||||
break;
|
||||
default:
|
||||
m_acc = StatementClassScope::scsPrivate;
|
||||
m_acc = StatementClassScope::Private;
|
||||
}
|
||||
//inherit
|
||||
addInheritedStatement(derived,statement,m_acc);
|
||||
|
@ -4495,8 +4485,8 @@ void CppParser::scanMethodArgs(const PStatement& functionStatement, int argStart
|
|||
"",
|
||||
functionStatement->definitionLine,
|
||||
StatementKind::skParameter,
|
||||
StatementScope::ssLocal,
|
||||
StatementClassScope::scsNone,
|
||||
StatementScope::Local,
|
||||
StatementClassScope::None,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
|
@ -4658,7 +4648,7 @@ void CppParser::scanMethodArgs(const PStatement& functionStatement, int argStart
|
|||
if (varAdded && (mIndex < mTokenizer.tokenCount())
|
||||
&& (mTokenizer[mIndex]->text == '{')) {
|
||||
// skip { } like A x {new A};
|
||||
int i=skipBraces(mIndex);
|
||||
int i=indexOfMatchingBrace(mIndex);
|
||||
if (i!=mIndex)
|
||||
mIndex = i+1;
|
||||
}
|
||||
|
@ -4918,6 +4908,80 @@ void CppParser::updateSerialId()
|
|||
mSerialId = QString("%1 %2").arg(mParserId).arg(mSerialCount);
|
||||
}
|
||||
|
||||
int CppParser::indexOfNextSemicolon(int index)
|
||||
{
|
||||
while (index<mTokenizer.tokenCount()) {
|
||||
switch(mTokenizer[index]->text[0].unicode()) {
|
||||
case ';':
|
||||
return index;
|
||||
case '(':
|
||||
index = mTokenizer[index]->matchIndex+1;
|
||||
break;
|
||||
default:
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int CppParser::indexOfNextColon(int index)
|
||||
{
|
||||
while (index<mTokenizer.tokenCount()) {
|
||||
switch(mTokenizer[index]->text[0].unicode()) {
|
||||
case ':':
|
||||
return index;
|
||||
case '(':
|
||||
index = mTokenizer[index]->matchIndex+1;
|
||||
break;
|
||||
default:
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int CppParser::indexOfNextLeftBrace(int index)
|
||||
{
|
||||
while (index<mTokenizer.tokenCount()) {
|
||||
switch(mTokenizer[index]->text[0].unicode()) {
|
||||
case '{':
|
||||
return index;
|
||||
case '(':
|
||||
index = mTokenizer[index]->matchIndex+1;
|
||||
break;
|
||||
default:
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int CppParser::indexPassParenthesis(int index)
|
||||
{
|
||||
while (index<mTokenizer.tokenCount()) {
|
||||
if (mTokenizer[index]->text=='(') {
|
||||
return mTokenizer[index]->matchIndex+1;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int CppParser::indexPassBraces(int index)
|
||||
{
|
||||
while (index<mTokenizer.tokenCount()) {
|
||||
switch(mTokenizer[index]->text[0].unicode()) {
|
||||
case '{':
|
||||
return mTokenizer[index]->matchIndex+1;
|
||||
case '(':
|
||||
index = mTokenizer[index]->matchIndex+1;
|
||||
break;
|
||||
default:
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
ParserLanguage CppParser::language() const
|
||||
{
|
||||
return mLanguage;
|
||||
|
|
|
@ -200,7 +200,8 @@ private:
|
|||
bool isCurrentScope(const QString& command);
|
||||
void addSoloScopeLevel(PStatement& statement, int line, bool shouldResetBlock = true); // adds new solo level
|
||||
void removeScopeLevel(int line); // removes level
|
||||
int skipBraces(int startAt) {
|
||||
|
||||
int indexOfMatchingBrace(int startAt) {
|
||||
return mTokenizer[startAt]->matchIndex;
|
||||
}
|
||||
|
||||
|
@ -208,17 +209,17 @@ private:
|
|||
|
||||
QStringList sortFilesByIncludeRelations(const QSet<QString> &files);
|
||||
|
||||
bool checkForKeyword(SkipType &skipType);
|
||||
bool checkForKeyword(KeywordType &keywordType);
|
||||
bool checkForMethod(QString &sType, QString &sName, int &argStartIndex,
|
||||
int &argEndIndex, bool &isStatic, bool &isFriend); // caching of results
|
||||
bool checkForNamespace(SkipType skipType);
|
||||
bool checkForNamespace(KeywordType keywordType);
|
||||
bool checkForPreprocessor();
|
||||
bool checkForScope(SkipType skipType);
|
||||
bool checkForScope(KeywordType keywordType);
|
||||
void checkForSkipStatement();
|
||||
bool checkForStructs(SkipType skipType);
|
||||
bool checkForStructs(KeywordType keywordType);
|
||||
bool checkForTypedefEnum();
|
||||
bool checkForTypedefStruct();
|
||||
bool checkForUsing(SkipType skipType);
|
||||
bool checkForUsing(KeywordType keywordType);
|
||||
bool checkForVar(bool& isFunctionPointer);
|
||||
|
||||
void fillListOfFunctions(const QString& fileName, int line,
|
||||
|
@ -356,6 +357,7 @@ private:
|
|||
|
||||
int getBracketEnd(const QString& s, int startAt);
|
||||
StatementClassScope getClassScope(const QString& text);
|
||||
StatementClassScope getClassScope(KeywordType keywordType);
|
||||
int getCurrentBlockBeginSkip();
|
||||
int getCurrentBlockEndSkip();
|
||||
int getCurrentInlineNamespaceEndSkip();
|
||||
|
@ -384,7 +386,7 @@ private:
|
|||
void handleCatchBlock();
|
||||
void handleEnum();
|
||||
void handleForBlock();
|
||||
void handleKeyword(SkipType skipType);
|
||||
void handleKeyword(KeywordType skipType);
|
||||
void handleMethod(
|
||||
const QString& sType,
|
||||
const QString& sName,
|
||||
|
@ -392,10 +394,10 @@ private:
|
|||
int argEnd,
|
||||
bool isStatic,
|
||||
bool isFriend);
|
||||
void handleNamespace(SkipType skipType);
|
||||
void handleNamespace(KeywordType skipType);
|
||||
void handleOtherTypedefs();
|
||||
void handlePreprocessor();
|
||||
void handleScope();
|
||||
void handleScope(KeywordType keywordType);
|
||||
bool handleStatement();
|
||||
void handleStructs(bool isTypedef = false);
|
||||
void handleUsing();
|
||||
|
@ -465,6 +467,10 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
bool isLeftParenthesis(const QString& text) const {
|
||||
return text=="(";
|
||||
}
|
||||
|
||||
/*';', '{', '}'*/
|
||||
bool isblockChar(const QChar& ch) const {
|
||||
switch(ch.unicode()){
|
||||
|
@ -525,7 +531,11 @@ private:
|
|||
|
||||
void updateSerialId();
|
||||
|
||||
|
||||
int indexOfNextSemicolon(int index);
|
||||
int indexOfNextColon(int index);
|
||||
int indexOfNextLeftBrace(int index);
|
||||
int indexPassParenthesis(int index);
|
||||
int indexPassBraces(int index);
|
||||
private:
|
||||
int mParserId;
|
||||
ParserLanguage mLanguage;
|
||||
|
@ -568,7 +578,7 @@ private:
|
|||
|
||||
QMutex mMutex;
|
||||
GetFileStreamCallBack mOnGetFileStream;
|
||||
QMap<QString,SkipType> mCppKeywords;
|
||||
QMap<QString,KeywordType> mCppKeywords;
|
||||
QSet<QString> mCppTypeKeywords;
|
||||
};
|
||||
using PCppParser = std::shared_ptr<CppParser>;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
QStringList CppDirectives;
|
||||
QStringList JavadocTags;
|
||||
QMap<QString,SkipType> CppKeywords;
|
||||
QMap<QString,KeywordType> CppKeywords;
|
||||
QSet<QString> CppControlKeyWords;
|
||||
QSet<QString> CppTypeKeywords;
|
||||
QSet<QString> CKeywords;
|
||||
|
@ -55,107 +55,107 @@ void initParser()
|
|||
CppSourceExts->insert("c++");
|
||||
CppSourceExts->insert("cp");
|
||||
// skip itself
|
||||
CppKeywords.insert("and",SkipType::skItself);
|
||||
CppKeywords.insert("and_eq",SkipType::skItself);
|
||||
CppKeywords.insert("bitand",SkipType::skItself);
|
||||
CppKeywords.insert("bitor",SkipType::skItself);
|
||||
CppKeywords.insert("break",SkipType::skItself);
|
||||
CppKeywords.insert("compl",SkipType::skItself);
|
||||
CppKeywords.insert("constexpr",SkipType::skItself);
|
||||
CppKeywords.insert("const_cast",SkipType::skItself);
|
||||
CppKeywords.insert("continue",SkipType::skItself);
|
||||
CppKeywords.insert("dynamic_cast",SkipType::skItself);
|
||||
CppKeywords.insert("else",SkipType::skItself);
|
||||
CppKeywords.insert("explicit",SkipType::skItself);
|
||||
CppKeywords.insert("export",SkipType::skItself);
|
||||
CppKeywords.insert("false",SkipType::skItself);
|
||||
CppKeywords.insert("and",KeywordType::SkipItself);
|
||||
CppKeywords.insert("and_eq",KeywordType::SkipItself);
|
||||
CppKeywords.insert("bitand",KeywordType::SkipItself);
|
||||
CppKeywords.insert("bitor",KeywordType::SkipItself);
|
||||
CppKeywords.insert("break",KeywordType::SkipItself);
|
||||
CppKeywords.insert("compl",KeywordType::SkipItself);
|
||||
CppKeywords.insert("constexpr",KeywordType::SkipItself);
|
||||
CppKeywords.insert("const_cast",KeywordType::SkipItself);
|
||||
CppKeywords.insert("continue",KeywordType::SkipItself);
|
||||
CppKeywords.insert("dynamic_cast",KeywordType::SkipItself);
|
||||
CppKeywords.insert("else",KeywordType::SkipItself);
|
||||
CppKeywords.insert("explicit",KeywordType::SkipItself);
|
||||
CppKeywords.insert("export",KeywordType::SkipItself);
|
||||
CppKeywords.insert("false",KeywordType::SkipItself);
|
||||
//CppKeywords.insert("for",SkipType::skItself);
|
||||
CppKeywords.insert("mutable",SkipType::skItself);
|
||||
CppKeywords.insert("noexcept",SkipType::skItself);
|
||||
CppKeywords.insert("not",SkipType::skItself);
|
||||
CppKeywords.insert("not_eq",SkipType::skItself);
|
||||
CppKeywords.insert("nullptr",SkipType::skItself);
|
||||
CppKeywords.insert("or",SkipType::skItself);
|
||||
CppKeywords.insert("or_eq",SkipType::skItself);
|
||||
CppKeywords.insert("register",SkipType::skItself);
|
||||
CppKeywords.insert("reinterpret_cast",SkipType::skItself);
|
||||
CppKeywords.insert("static_assert",SkipType::skItself);
|
||||
CppKeywords.insert("static_cast",SkipType::skItself);
|
||||
CppKeywords.insert("template",SkipType::skItself);
|
||||
CppKeywords.insert("mutable",KeywordType::SkipItself);
|
||||
CppKeywords.insert("noexcept",KeywordType::SkipItself);
|
||||
CppKeywords.insert("not",KeywordType::SkipItself);
|
||||
CppKeywords.insert("not_eq",KeywordType::SkipItself);
|
||||
CppKeywords.insert("nullptr",KeywordType::SkipItself);
|
||||
CppKeywords.insert("or",KeywordType::SkipItself);
|
||||
CppKeywords.insert("or_eq",KeywordType::SkipItself);
|
||||
CppKeywords.insert("register",KeywordType::SkipItself);
|
||||
CppKeywords.insert("reinterpret_cast",KeywordType::SkipItself);
|
||||
CppKeywords.insert("static_assert",KeywordType::SkipItself);
|
||||
CppKeywords.insert("static_cast",KeywordType::SkipItself);
|
||||
CppKeywords.insert("template",KeywordType::SkipItself);
|
||||
//CppKeywords.insert("this",SkipType::skItself);
|
||||
CppKeywords.insert("thread_local",SkipType::skItself);
|
||||
CppKeywords.insert("true",SkipType::skItself);
|
||||
CppKeywords.insert("typename",SkipType::skItself);
|
||||
CppKeywords.insert("virtual",SkipType::skItself);
|
||||
CppKeywords.insert("volatile",SkipType::skItself);
|
||||
CppKeywords.insert("xor",SkipType::skItself);
|
||||
CppKeywords.insert("xor_eq",SkipType::skItself);
|
||||
CppKeywords.insert("thread_local",KeywordType::SkipItself);
|
||||
CppKeywords.insert("true",KeywordType::SkipItself);
|
||||
CppKeywords.insert("typename",KeywordType::SkipItself);
|
||||
CppKeywords.insert("virtual",KeywordType::SkipItself);
|
||||
CppKeywords.insert("volatile",KeywordType::SkipItself);
|
||||
CppKeywords.insert("xor",KeywordType::SkipItself);
|
||||
CppKeywords.insert("xor_eq",KeywordType::SkipItself);
|
||||
|
||||
|
||||
//CppKeywords.insert("catch",SkipType::skItself);
|
||||
CppKeywords.insert("do",SkipType::skItself);
|
||||
CppKeywords.insert("try",SkipType::skItself);
|
||||
CppKeywords.insert("do",KeywordType::SkipItself);
|
||||
CppKeywords.insert("try",KeywordType::SkipItself);
|
||||
|
||||
// Skip to ;
|
||||
CppKeywords.insert("delete",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("delete[]",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("goto",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("new",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("return",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("throw",SkipType::skToSemicolon);
|
||||
CppKeywords.insert("delete",KeywordType::SkipAfterSemicolon);
|
||||
CppKeywords.insert("delete[]",KeywordType::SkipAfterSemicolon);
|
||||
CppKeywords.insert("goto",KeywordType::SkipAfterSemicolon);
|
||||
CppKeywords.insert("new",KeywordType::SkipAfterSemicolon);
|
||||
CppKeywords.insert("return",KeywordType::SkipAfterSemicolon);
|
||||
CppKeywords.insert("throw",KeywordType::SkipAfterSemicolon);
|
||||
// CppKeywords.insert("using",SkipType::skToSemicolon); //won't use it
|
||||
|
||||
// Skip to :
|
||||
CppKeywords.insert("case",SkipType::skToColon);
|
||||
CppKeywords.insert("default",SkipType::skToColon);
|
||||
CppKeywords.insert("case",KeywordType::SkipAfterColon);
|
||||
CppKeywords.insert("default",KeywordType::SkipAfterColon);
|
||||
|
||||
// Skip to )
|
||||
CppKeywords.insert("__attribute__",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("alignas",SkipType::skToRightParenthesis); // not right
|
||||
CppKeywords.insert("alignof",SkipType::skToRightParenthesis); // not right
|
||||
CppKeywords.insert("decltype",SkipType::skToRightParenthesis); // not right
|
||||
CppKeywords.insert("if",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("sizeof",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("switch",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("typeid",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("while",SkipType::skToRightParenthesis);
|
||||
CppKeywords.insert("__attribute__",KeywordType::SkipAfterParenthesis);
|
||||
CppKeywords.insert("alignas",KeywordType::SkipAfterParenthesis); // not right
|
||||
CppKeywords.insert("alignof",KeywordType::SkipAfterParenthesis); // not right
|
||||
CppKeywords.insert("decltype",KeywordType::SkipAfterParenthesis); // not right
|
||||
CppKeywords.insert("if",KeywordType::SkipAfterParenthesis);
|
||||
CppKeywords.insert("sizeof",KeywordType::SkipAfterParenthesis);
|
||||
CppKeywords.insert("switch",KeywordType::SkipAfterParenthesis);
|
||||
CppKeywords.insert("typeid",KeywordType::SkipAfterParenthesis);
|
||||
CppKeywords.insert("while",KeywordType::SkipAfterParenthesis);
|
||||
|
||||
// Skip to }
|
||||
CppKeywords.insert("asm",SkipType::skToRightBrace);
|
||||
CppKeywords.insert("asm",KeywordType::SkipAfterBrace);
|
||||
//CppKeywords.insert("namespace",SkipType::skToLeftBrace); // won't process it
|
||||
// Skip to {
|
||||
|
||||
// wont handle
|
||||
|
||||
//Not supported yet
|
||||
CppKeywords.insert("atomic_cancel",SkipType::skNone);
|
||||
CppKeywords.insert("atomic_commit",SkipType::skNone);
|
||||
CppKeywords.insert("atomic_noexcept",SkipType::skNone);
|
||||
CppKeywords.insert("concept",SkipType::skNone);
|
||||
CppKeywords.insert("consteval",SkipType::skNone);
|
||||
CppKeywords.insert("constinit",SkipType::skNone);
|
||||
CppKeywords.insert("co_wait",SkipType::skNone);
|
||||
CppKeywords.insert("co_return",SkipType::skNone);
|
||||
CppKeywords.insert("co_yield",SkipType::skNone);
|
||||
CppKeywords.insert("reflexpr",SkipType::skNone);
|
||||
CppKeywords.insert("requires",SkipType::skNone);
|
||||
CppKeywords.insert("atomic_cancel",KeywordType::None);
|
||||
CppKeywords.insert("atomic_commit",KeywordType::None);
|
||||
CppKeywords.insert("atomic_noexcept",KeywordType::None);
|
||||
CppKeywords.insert("concept",KeywordType::None);
|
||||
CppKeywords.insert("consteval",KeywordType::None);
|
||||
CppKeywords.insert("constinit",KeywordType::None);
|
||||
CppKeywords.insert("co_wait",KeywordType::None);
|
||||
CppKeywords.insert("co_return",KeywordType::None);
|
||||
CppKeywords.insert("co_yield",KeywordType::None);
|
||||
CppKeywords.insert("reflexpr",KeywordType::None);
|
||||
CppKeywords.insert("requires",KeywordType::None);
|
||||
|
||||
// its a type
|
||||
CppKeywords.insert("auto",SkipType::skNone);
|
||||
CppKeywords.insert("bool",SkipType::skNone);
|
||||
CppKeywords.insert("char",SkipType::skNone);
|
||||
CppKeywords.insert("char8_t",SkipType::skNone);
|
||||
CppKeywords.insert("char16_t",SkipType::skNone);
|
||||
CppKeywords.insert("char32_t",SkipType::skNone);
|
||||
CppKeywords.insert("double",SkipType::skNone);
|
||||
CppKeywords.insert("float",SkipType::skNone);
|
||||
CppKeywords.insert("int",SkipType::skNone);
|
||||
CppKeywords.insert("long",SkipType::skNone);
|
||||
CppKeywords.insert("short",SkipType::skNone);
|
||||
CppKeywords.insert("signed",SkipType::skNone);
|
||||
CppKeywords.insert("unsigned",SkipType::skNone);
|
||||
CppKeywords.insert("void",SkipType::skNone);
|
||||
CppKeywords.insert("wchar_t",SkipType::skNone);
|
||||
CppKeywords.insert("auto",KeywordType::None);
|
||||
CppKeywords.insert("bool",KeywordType::None);
|
||||
CppKeywords.insert("char",KeywordType::None);
|
||||
CppKeywords.insert("char8_t",KeywordType::None);
|
||||
CppKeywords.insert("char16_t",KeywordType::None);
|
||||
CppKeywords.insert("char32_t",KeywordType::None);
|
||||
CppKeywords.insert("double",KeywordType::None);
|
||||
CppKeywords.insert("float",KeywordType::None);
|
||||
CppKeywords.insert("int",KeywordType::None);
|
||||
CppKeywords.insert("long",KeywordType::None);
|
||||
CppKeywords.insert("short",KeywordType::None);
|
||||
CppKeywords.insert("signed",KeywordType::None);
|
||||
CppKeywords.insert("unsigned",KeywordType::None);
|
||||
CppKeywords.insert("void",KeywordType::None);
|
||||
CppKeywords.insert("wchar_t",KeywordType::None);
|
||||
|
||||
// type keywords
|
||||
CppTypeKeywords.insert("auto");
|
||||
|
@ -177,30 +177,30 @@ void initParser()
|
|||
CppTypeKeywords.insert("unsigned");
|
||||
|
||||
// it's part of type info
|
||||
CppKeywords.insert("const",SkipType::skNone);
|
||||
CppKeywords.insert("extern",SkipType::skNone);
|
||||
CppKeywords.insert("const",KeywordType::None);
|
||||
CppKeywords.insert("extern",KeywordType::None);
|
||||
|
||||
// handled elsewhere
|
||||
CppKeywords.insert("class",SkipType::skNone);
|
||||
CppKeywords.insert("operator",SkipType::skNone);
|
||||
CppKeywords.insert("static",SkipType::skNone);
|
||||
CppKeywords.insert("struct",SkipType::skNone);
|
||||
CppKeywords.insert("union",SkipType::skNone);
|
||||
CppKeywords.insert("class",KeywordType::None);
|
||||
CppKeywords.insert("operator",KeywordType::None);
|
||||
CppKeywords.insert("static",KeywordType::None);
|
||||
CppKeywords.insert("struct",KeywordType::None);
|
||||
CppKeywords.insert("union",KeywordType::None);
|
||||
|
||||
CppKeywords.insert("for",SkipType::skFor);
|
||||
CppKeywords.insert("catch",SkipType::skCatch);
|
||||
CppKeywords.insert("private",SkipType::skScope);
|
||||
CppKeywords.insert("public",SkipType::skScope);
|
||||
CppKeywords.insert("enum",SkipType::skEnum);
|
||||
CppKeywords.insert("namespace",SkipType::skNamespace);
|
||||
CppKeywords.insert("inline",SkipType::skInline);
|
||||
CppKeywords.insert("typedef",SkipType::skTypedef);
|
||||
CppKeywords.insert("using",SkipType::skUsing);
|
||||
CppKeywords.insert("protected",SkipType::skProtected);
|
||||
CppKeywords.insert("friend",SkipType::skFriend);
|
||||
CppKeywords.insert("for",KeywordType::For);
|
||||
CppKeywords.insert("catch",KeywordType::Catch);
|
||||
CppKeywords.insert("private",KeywordType::Private);
|
||||
CppKeywords.insert("public",KeywordType::Public);
|
||||
CppKeywords.insert("enum",KeywordType::Enum);
|
||||
CppKeywords.insert("namespace",KeywordType::Namespace);
|
||||
CppKeywords.insert("inline",KeywordType::Inline);
|
||||
CppKeywords.insert("typedef",KeywordType::Typedef);
|
||||
CppKeywords.insert("using",KeywordType::Using);
|
||||
CppKeywords.insert("protected",KeywordType::Protected);
|
||||
CppKeywords.insert("friend",KeywordType::Friend);
|
||||
|
||||
// nullptr is value
|
||||
CppKeywords.insert("nullptr",SkipType::skNone);
|
||||
CppKeywords.insert("nullptr",KeywordType::None);
|
||||
|
||||
//C Keywords
|
||||
CKeywords.insert("auto");
|
||||
|
@ -535,16 +535,16 @@ void CppScopes::clear()
|
|||
MemberOperatorType getOperatorType(const QString &phrase, int index)
|
||||
{
|
||||
if (index>=phrase.length())
|
||||
return MemberOperatorType::otOther;
|
||||
return MemberOperatorType::Other;
|
||||
if (phrase[index] == '.')
|
||||
return MemberOperatorType::otDot;
|
||||
return MemberOperatorType::Dot;
|
||||
if (index+1>=phrase.length())
|
||||
return MemberOperatorType::otOther;
|
||||
return MemberOperatorType::Other;
|
||||
if ((phrase[index] == '-') && (phrase[index+1] == '>'))
|
||||
return MemberOperatorType::otArrow;
|
||||
return MemberOperatorType::Arrow;
|
||||
if ((phrase[index] == ':') && (phrase[index+1] == ':'))
|
||||
return MemberOperatorType::otDColon;
|
||||
return MemberOperatorType::otOther;
|
||||
return MemberOperatorType::DColon;
|
||||
return MemberOperatorType::Other;
|
||||
}
|
||||
|
||||
bool isScopeTypeKind(StatementKind kind)
|
||||
|
@ -645,7 +645,7 @@ StatementKind getKindOfStatement(const PStatement& statement)
|
|||
if (statement->kind == StatementKind::skVariable) {
|
||||
if (!statement->parentScope.lock()) {
|
||||
return StatementKind::skGlobalVariable;
|
||||
} else if (statement->scope == StatementScope::ssLocal) {
|
||||
} else if (statement->scope == StatementScope::Local) {
|
||||
return StatementKind::skLocalVariable;
|
||||
} else {
|
||||
return StatementKind::skVariable;
|
||||
|
|
|
@ -56,24 +56,25 @@ using PDefine = std::shared_ptr<Define>;
|
|||
using DefineMap = QHash<QString,PDefine>;
|
||||
using PDefineMap = std::shared_ptr<DefineMap>;
|
||||
|
||||
enum class SkipType {
|
||||
skItself, // skip itself
|
||||
skToSemicolon, // skip to ;
|
||||
skToColon, // skip to :
|
||||
skToRightParenthesis, // skip to )
|
||||
skToLeftBrace,// Skip to {
|
||||
skToRightBrace, // skip to }
|
||||
skFor, //for
|
||||
skCatch, //catch
|
||||
skScope, // public/private
|
||||
skProtected,
|
||||
skFriend,
|
||||
skEnum, //enum
|
||||
skInline, // inline
|
||||
skNamespace, //namespace
|
||||
skTypedef, //typedef
|
||||
skUsing, //using
|
||||
skNone // It's a keyword but don't process here
|
||||
enum class KeywordType {
|
||||
SkipItself, // skip itself
|
||||
SkipAfterSemicolon, // skip to ;
|
||||
SkipAfterColon, // skip to :
|
||||
SkipAfterParenthesis, // skip to )
|
||||
SkipToLeftBrace,// Skip to {
|
||||
SkipAfterBrace, // skip to }
|
||||
For, //for
|
||||
Catch, //catch
|
||||
Public, // public
|
||||
Private,
|
||||
Protected,
|
||||
Friend,
|
||||
Enum, //enum
|
||||
Inline, // inline
|
||||
Namespace, //namespace
|
||||
Typedef, //typedef
|
||||
Using, //using
|
||||
None // It's a keyword but don't process here
|
||||
};
|
||||
|
||||
|
||||
|
@ -104,23 +105,23 @@ enum StatementKind {
|
|||
using StatementKindSet = QSet<StatementKind>;
|
||||
|
||||
enum class StatementScope {
|
||||
ssGlobal,
|
||||
ssLocal,
|
||||
ssClassLocal
|
||||
Global,
|
||||
Local,
|
||||
ClassLocal
|
||||
};
|
||||
|
||||
enum class StatementClassScope {
|
||||
scsNone,
|
||||
scsPrivate,
|
||||
scsProtected,
|
||||
scsPublic
|
||||
None,
|
||||
Private,
|
||||
Protected,
|
||||
Public
|
||||
};
|
||||
|
||||
enum class MemberOperatorType {
|
||||
otArrow,
|
||||
otDot,
|
||||
otDColon,
|
||||
otOther
|
||||
Arrow,
|
||||
Dot,
|
||||
DColon,
|
||||
Other
|
||||
};
|
||||
|
||||
enum class EvalStatementKind {
|
||||
|
@ -242,7 +243,7 @@ using PFileIncludes = std::shared_ptr<FileIncludes>;
|
|||
|
||||
extern QStringList CppDirectives;
|
||||
extern QStringList JavadocTags;
|
||||
extern QMap<QString,SkipType> CppKeywords;
|
||||
extern QMap<QString,KeywordType> CppKeywords;
|
||||
extern QSet<QString> CppControlKeyWords;
|
||||
extern QSet<QString> CKeywords;
|
||||
extern QSet<QString> CppTypeKeywords;
|
||||
|
|
|
@ -338,7 +338,7 @@ void ClassBrowserModel::filterChildren(ClassBrowserNode *node, const StatementMa
|
|||
if (statement == node->statement) // prevent infinite recursion
|
||||
continue;
|
||||
|
||||
if (statement->scope == StatementScope::ssLocal)
|
||||
if (statement->scope == StatementScope::Local)
|
||||
continue;
|
||||
|
||||
if (pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine()
|
||||
|
|
|
@ -278,11 +278,11 @@ static bool sortByScopeComparator(PStatement statement1,PStatement statement2){
|
|||
if (statement1->inSystemHeader != statement2->inSystemHeader)
|
||||
return !(statement1->inSystemHeader);
|
||||
// Show local statements first
|
||||
if (statement1->scope != StatementScope::ssGlobal
|
||||
&& statement2->scope == StatementScope::ssGlobal ) {
|
||||
if (statement1->scope != StatementScope::Global
|
||||
&& statement2->scope == StatementScope::Global ) {
|
||||
return true;
|
||||
} else if (statement1->scope == StatementScope::ssGlobal
|
||||
&& statement2->scope != StatementScope::ssGlobal ) {
|
||||
} else if (statement1->scope == StatementScope::Global
|
||||
&& statement2->scope != StatementScope::Global ) {
|
||||
return false;
|
||||
} else
|
||||
return nameComparator(statement1,statement2);
|
||||
|
@ -359,11 +359,11 @@ static bool sortByScopeWithUsageComparator(PStatement statement1,PStatement stat
|
|||
if (statement1->inSystemHeader != statement2->inSystemHeader)
|
||||
return !(statement1->inSystemHeader);
|
||||
// Show local statements first
|
||||
if (statement1->scope != StatementScope::ssGlobal
|
||||
&& statement2->scope == StatementScope::ssGlobal ) {
|
||||
if (statement1->scope != StatementScope::Global
|
||||
&& statement2->scope == StatementScope::Global ) {
|
||||
return true;
|
||||
} else if (statement1->scope == StatementScope::ssGlobal
|
||||
&& statement2->scope != StatementScope::ssGlobal ) {
|
||||
} else if (statement1->scope == StatementScope::Global
|
||||
&& statement2->scope != StatementScope::Global ) {
|
||||
return false;
|
||||
} else
|
||||
return nameComparator(statement1,statement2);
|
||||
|
@ -712,7 +712,7 @@ void CodeCompletionPopup::getCompletionFor(
|
|||
if (children.isEmpty())
|
||||
return;
|
||||
foreach (const PStatement& childStatement, children) {
|
||||
if ((childStatement->classScope==StatementClassScope::scsPublic)
|
||||
if ((childStatement->classScope==StatementClassScope::Public)
|
||||
&& !(
|
||||
childStatement->kind == StatementKind::skConstructor
|
||||
|| childStatement->kind == StatementKind::skDestructor)
|
||||
|
@ -769,7 +769,7 @@ void CodeCompletionPopup::getCompletionFor(
|
|||
|| childStatement->kind == StatementKind::skEnumClassType
|
||||
|| childStatement->kind == StatementKind::skEnumType
|
||||
)) {
|
||||
if (childStatement->classScope == StatementClassScope::scsPublic)
|
||||
if (childStatement->classScope == StatementClassScope::Public)
|
||||
addStatement(childStatement,fileName,-1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue