From 648e555fc5b310eb0f309623eb728d70953187a9 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 3 Apr 2024 10:37:29 +0800 Subject: [PATCH] refactor: enum to enum class --- RedPandaIDE/colorscheme.cpp | 40 +-- RedPandaIDE/editor.cpp | 120 +++---- RedPandaIDE/iconsmanager.cpp | 34 +- RedPandaIDE/parser/cppparser.cpp | 348 ++++++++++---------- RedPandaIDE/parser/parserutils.cpp | 34 +- RedPandaIDE/parser/parserutils.h | 111 ++++--- RedPandaIDE/widgets/classbrowser.cpp | 24 +- RedPandaIDE/widgets/codecompletionpopup.cpp | 130 ++++---- RedPandaIDE/widgets/newclassdialog.cpp | 8 +- libs/qsynedit/qsynedit/qsynedit.cpp | 10 +- libs/qsynedit/qsynedit/qsynedit.h | 2 +- 11 files changed, 433 insertions(+), 428 deletions(-) diff --git a/RedPandaIDE/colorscheme.cpp b/RedPandaIDE/colorscheme.cpp index 0c26be21..cb73c72d 100644 --- a/RedPandaIDE/colorscheme.cpp +++ b/RedPandaIDE/colorscheme.cpp @@ -694,53 +694,53 @@ void ColorManager::updateStatementColors(std::shared_ptrinsert(StatementKind::skFunction,item); - statementColors->insert(StatementKind::skConstructor,item); - statementColors->insert(StatementKind::skDestructor,item); + statementColors->insert(StatementKind::Function,item); + statementColors->insert(StatementKind::Constructor,item); + statementColors->insert(StatementKind::Destructor,item); } item = getItem(schemeName, SYNS_AttrClass); if (item) { - statementColors->insert(StatementKind::skClass,item); - statementColors->insert(StatementKind::skTypedef,item); - statementColors->insert(StatementKind::skAlias,item); + statementColors->insert(StatementKind::Class,item); + statementColors->insert(StatementKind::Typedef,item); + statementColors->insert(StatementKind::Alias,item); } item = getItem(schemeName, SYNS_AttrIdentifier); if (item) { - statementColors->insert(StatementKind::skEnumType,item); - statementColors->insert(StatementKind::skEnumClassType,item); + statementColors->insert(StatementKind::EnumType,item); + statementColors->insert(StatementKind::EnumClassType,item); } item = getItem(schemeName, SYNS_AttrVariable); if (item) { - statementColors->insert(StatementKind::skVariable,item); + statementColors->insert(StatementKind::Variable,item); } item = getItem(schemeName, SYNS_AttrLocalVariable); if (item) { - statementColors->insert(StatementKind::skLocalVariable,item); - statementColors->insert(StatementKind::skParameter,item); + statementColors->insert(StatementKind::LocalVariable,item); + statementColors->insert(StatementKind::Parameter,item); } item = getItem(schemeName, SYNS_AttrGlobalVariable); if (item) { - statementColors->insert(StatementKind::skGlobalVariable,item); + statementColors->insert(StatementKind::GlobalVariable,item); } item = getItem(schemeName, SYNS_AttrPreprocessor); if (item) { - statementColors->insert(StatementKind::skPreprocessor,item); - statementColors->insert(StatementKind::skEnum,item); + statementColors->insert(StatementKind::Preprocessor,item); + statementColors->insert(StatementKind::Enum,item); } item = getItem(schemeName, SYNS_AttrReservedWord); if (item) { - statementColors->insert(StatementKind::skKeyword,item); - statementColors->insert(StatementKind::skUserCodeSnippet,item); - statementColors->insert(StatementKind::skKeywordType,item); + statementColors->insert(StatementKind::Keyword,item); + statementColors->insert(StatementKind::UserCodeSnippet,item); + statementColors->insert(StatementKind::KeywordType,item); } item = getItem(schemeName, SYNS_AttrReserveWord_Type); if (item) { - statementColors->insert(StatementKind::skKeywordType,item); + statementColors->insert(StatementKind::KeywordType,item); } item = getItem(schemeName, SYNS_AttrString); if (item) { - statementColors->insert(StatementKind::skNamespace,item); - statementColors->insert(StatementKind::skNamespaceAlias,item); + statementColors->insert(StatementKind::Namespace,item); + statementColors->insert(StatementKind::NamespaceAlias,item); } } diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index cdfd13e6..8c8c5f53 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -840,7 +840,7 @@ void Editor::keyPressEvent(QKeyEvent *event) QString funcName = function->command; bool isVoid = (function->type == "void"); foreach (const PStatement& child, function->children) { - if (child->kind == StatementKind::skParameter) + if (child->kind == StatementKind::Parameter) params.append(child->command); } insertString.append(QString(" * @brief ")+USER_CODE_IN_INSERT_POS); @@ -975,11 +975,11 @@ void Editor::keyPressEvent(QKeyEvent *event) return; } else if (CppTypeKeywords.contains(lastWord)) { PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); - while(currentScope && currentScope->kind==StatementKind::skBlock) { + while(currentScope && currentScope->kind==StatementKind::Block) { currentScope = currentScope->parentScope.lock(); } - if (!currentScope || currentScope->kind == StatementKind::skNamespace - || currentScope->kind == StatementKind::skClass) { + if (!currentScope || currentScope->kind == StatementKind::Namespace + || currentScope->kind == StatementKind::Class) { //may define a function processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false,CodeCompletionType::FunctionWithoutDefinition); @@ -1010,16 +1010,16 @@ void Editor::keyPressEvent(QKeyEvent *event) lastWord, caretY()); StatementKind kind = getKindOfStatement(statement); - if (kind == StatementKind::skClass - || kind == StatementKind::skEnumClassType - || kind == StatementKind::skEnumType - || kind == StatementKind::skTypedef) { + if (kind == StatementKind::Class + || kind == StatementKind::EnumClassType + || kind == StatementKind::EnumType + || kind == StatementKind::Typedef) { PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); - while(currentScope && currentScope->kind==StatementKind::skBlock) { + while(currentScope && currentScope->kind==StatementKind::Block) { currentScope = currentScope->parentScope.lock(); } - if (!currentScope || currentScope->kind == StatementKind::skNamespace) { + if (!currentScope || currentScope->kind == StatementKind::Namespace) { //may define a function processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); @@ -1034,10 +1034,10 @@ void Editor::keyPressEvent(QKeyEvent *event) lastWord = getPreviousWordAtPositionForCompleteFunctionDefinition(ws); if (mParser && !lastWord.isEmpty()) { PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); - while(currentScope && currentScope->kind==StatementKind::skBlock) { + while(currentScope && currentScope->kind==StatementKind::Block) { currentScope = currentScope->parentScope.lock(); } - if (!currentScope || currentScope->kind == StatementKind::skNamespace) { + if (!currentScope || currentScope->kind == StatementKind::Namespace) { //may define a function processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); @@ -1339,28 +1339,28 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to StatementKind kind; if (mParser->parsing()){ - kind=mIdentCache.value(QString("%1 %2").arg(aChar).arg(token),StatementKind::skUnknown); + kind=mIdentCache.value(QString("%1 %2").arg(aChar).arg(token),StatementKind::Unknown); } else { QStringList expression = getExpressionAtPosition(p); PStatement statement = parser()->findStatementOf( filename(), expression, p.line); - while (statement && statement->kind == StatementKind::skAlias) + while (statement && statement->kind == StatementKind::Alias) statement = mParser->findAliasedStatement(statement); kind = getKindOfStatement(statement); mIdentCache.insert(QString("%1 %2").arg(aChar).arg(token),kind); } - if (kind == StatementKind::skUnknown) { + if (kind == StatementKind::Unknown) { QSynedit::BufferCoord pBeginPos,pEndPos; QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation); if ((pEndPos.line>=1) && (pEndPos.ch>=0) && (pEndPos.ch+1 < document()->getLine(pEndPos.line-1).length()) && (document()->getLine(pEndPos.line-1)[pEndPos.ch+1] == '(')) { - kind = StatementKind::skFunction; + kind = StatementKind::Function; } else { - kind = StatementKind::skVariable; + kind = StatementKind::Variable; } } PColorSchemeItem item = mStatementColors->value(kind,PColorSchemeItem()); @@ -1398,7 +1398,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to ) ) { - PColorSchemeItem item = mStatementColors->value(StatementKind::skKeywordType,PColorSchemeItem()); + PColorSchemeItem item = mStatementColors->value(StatementKind::KeywordType,PColorSchemeItem()); if (item) { foreground = item->foreground(); @@ -1534,10 +1534,10 @@ void Editor::inputMethodEvent(QInputMethodEvent *event) lastWord, caretY()); StatementKind kind = getKindOfStatement(statement); - if (kind == StatementKind::skClass - || kind == StatementKind::skEnumClassType - || kind == StatementKind::skEnumType - || kind == StatementKind::skTypedef) { + if (kind == StatementKind::Class + || kind == StatementKind::EnumClassType + || kind == StatementKind::EnumType + || kind == StatementKind::Typedef) { //last word is a typedef/class/struct, this is a var or param define, and dont show suggestion // if devEditor.UseTabnine then // ShowTabnineCompletion; @@ -3843,7 +3843,7 @@ void Editor::completionInsert(bool appendFunc) return; if (pSettings->codeCompletion().recordUsage() - && statement->kind != StatementKind::skUserCodeSnippet) { + && statement->kind != StatementKind::UserCodeSnippet) { statement->usageCount+=1; pMainWindow->symbolUsageManager()->updateUsage(statement->fullName, statement->usageCount); @@ -3863,20 +3863,20 @@ void Editor::completionInsert(bool appendFunc) // if we are inserting a function, if (appendFunc) { - if (statement->kind == StatementKind::skAlias) { + if (statement->kind == StatementKind::Alias) { PStatement newStatement = mParser->findAliasedStatement(statement); - while (newStatement && newStatement->kind==StatementKind::skAlias) { + while (newStatement && newStatement->kind==StatementKind::Alias) { newStatement = mParser->findAliasedStatement(newStatement); } if (newStatement) statement = newStatement; } - if ( (statement->kind == StatementKind::skFunction + if ( (statement->kind == StatementKind::Function && !IOManipulators.contains(statement->fullName)) - || statement->kind == StatementKind::skConstructor - || statement->kind == StatementKind::skDestructor + || statement->kind == StatementKind::Constructor + || statement->kind == StatementKind::Destructor || - (statement->kind == StatementKind::skPreprocessor + (statement->kind == StatementKind::Preprocessor && !statement->args.isEmpty())) { QChar nextCh = nextNonSpaceChar(caretY()-1,p.ch-1); if (nextCh=='(') { @@ -3891,14 +3891,14 @@ void Editor::completionInsert(bool appendFunc) } // ... by replacing the selection - if (statement->kind == StatementKind::skUserCodeSnippet) { // it's a user code template + if (statement->kind == StatementKind::UserCodeSnippet) { // it's a user code template // insertUserCodeIn(Statement->value); //first move caret to the begin of the word to be replaced insertCodeSnippet(statement->value); } else { if ( - (statement->kind == StatementKind::skKeyword - || statement->kind == StatementKind::skPreprocessor) + (statement->kind == StatementKind::Keyword + || statement->kind == StatementKind::Preprocessor) && (statement->command.startsWith('#') || statement->command.startsWith('@')) ) { @@ -4168,9 +4168,9 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/ line); if (!statement) return result; - if (statement->kind == StatementKind::skFunction - || statement->kind == StatementKind::skConstructor - || statement->kind == StatementKind::skDestructor) { + if (statement->kind == StatementKind::Function + || statement->kind == StatementKind::Constructor + || statement->kind == StatementKind::Destructor) { result = getHintForFunction(statement,mFilename,line); } else if (statement->line>0) { QFileInfo fileInfo(statement->fileName); @@ -4190,10 +4190,10 @@ void Editor::showDebugHint(const QString &s, int line) return; PStatement statement = mParser->findStatementOf(mFilename,s,line); if (statement) { - if (statement->kind != StatementKind::skVariable - && statement->kind != StatementKind::skGlobalVariable - && statement->kind != StatementKind::skLocalVariable - && statement->kind != StatementKind::skParameter) { + if (statement->kind != StatementKind::Variable + && statement->kind != StatementKind::GlobalVariable + && statement->kind != StatementKind::LocalVariable + && statement->kind != StatementKind::Parameter) { return; } } @@ -4426,7 +4426,7 @@ void Editor::updateFunctionTip(bool showTip) pos.line); if (statement) { PStatement typeStatement = mParser->findTypeDef(statement,mFilename); - if (typeStatement && typeStatement->kind == StatementKind::skClass) { + if (typeStatement && typeStatement->kind == StatementKind::Class) { s = previousWord; functionNamePos = pos; } @@ -4540,52 +4540,52 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c // qDebug()<findStatementOf(mFilename, s , p.line); - while (statement && statement->kind == StatementKind::skAlias) + while (statement && statement->kind == StatementKind::Alias) statement = mParser->findAliasedStatement(statement); StatementKind kind = getKindOfStatement(statement); - if (kind == StatementKind::skUnknown) { + if (kind == StatementKind::Unknown) { if ((pEndPos.line>=1) && (pEndPos.ch>=0) && (pEndPos.ch < document()->getLine(pEndPos.line-1).length()) && (document()->getLine(pEndPos.line-1)[pEndPos.ch] == '(')) { - kind = StatementKind::skFunction; + kind = StatementKind::Function; } else { - kind = StatementKind::skVariable; + kind = StatementKind::Variable; } } QSynedit::CppSyntaxer* cppSyntaxer = dynamic_cast(syntaxer.get()); switch(kind) { - case StatementKind::skFunction: - case StatementKind::skConstructor: - case StatementKind::skDestructor: + case StatementKind::Function: + case StatementKind::Constructor: + case StatementKind::Destructor: attr = cppSyntaxer->functionAttribute(); break; - case StatementKind::skClass: - case StatementKind::skTypedef: + case StatementKind::Class: + case StatementKind::Typedef: attr = cppSyntaxer->classAttribute(); break; - case StatementKind::skEnumClassType: - case StatementKind::skEnumType: + case StatementKind::EnumClassType: + case StatementKind::EnumType: break; - case StatementKind::skLocalVariable: - case StatementKind::skParameter: + case StatementKind::LocalVariable: + case StatementKind::Parameter: attr = cppSyntaxer->localVarAttribute(); break; - case StatementKind::skVariable: + case StatementKind::Variable: attr = cppSyntaxer->variableAttribute(); break; - case StatementKind::skGlobalVariable: + case StatementKind::GlobalVariable: attr = cppSyntaxer->globalVarAttribute(); break; - case StatementKind::skEnum: - case StatementKind::skPreprocessor: + case StatementKind::Enum: + case StatementKind::Preprocessor: attr = cppSyntaxer->preprocessorAttribute(); break; - case StatementKind::skKeyword: + case StatementKind::Keyword: attr = cppSyntaxer->keywordAttribute(); break; - case StatementKind::skNamespace: - case StatementKind::skNamespaceAlias: + case StatementKind::Namespace: + case StatementKind::NamespaceAlias: attr = cppSyntaxer->stringAttribute(); break; default: diff --git a/RedPandaIDE/iconsmanager.cpp b/RedPandaIDE/iconsmanager.cpp index 01095e64..380054c0 100644 --- a/RedPandaIDE/iconsmanager.cpp +++ b/RedPandaIDE/iconsmanager.cpp @@ -285,22 +285,22 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement) return QPixmap(); StatementKind kind = getKindOfStatement(statement); switch (kind) { - case StatementKind::skTypedef: + case StatementKind::Typedef: return *(pIconsManager->getPixmap(IconsManager::PARSER_TYPE)); - case StatementKind::skClass: + case StatementKind::Class: return *(pIconsManager->getPixmap(IconsManager::PARSER_CLASS)); - case StatementKind::skNamespace: - case StatementKind::skNamespaceAlias: + case StatementKind::Namespace: + case StatementKind::NamespaceAlias: return *(pIconsManager->getPixmap(IconsManager::PARSER_NAMESPACE)); - case StatementKind::skPreprocessor: + case StatementKind::Preprocessor: return *(pIconsManager->getPixmap(IconsManager::PARSER_DEFINE)); - case StatementKind::skEnumClassType: - case StatementKind::skEnumType: - case StatementKind::skEnum: + case StatementKind::EnumClassType: + case StatementKind::EnumType: + case StatementKind::Enum: return *(pIconsManager->getPixmap(IconsManager::PARSER_ENUM)); - case StatementKind::skFunction: - case StatementKind::skConstructor: - case StatementKind::skDestructor: + case StatementKind::Function: + case StatementKind::Constructor: + case StatementKind::Destructor: if (statement->scope == StatementScope::Global) return *(pIconsManager->getPixmap(IconsManager::PARSER_GLOBAL_METHOD)); if (statement->isInherited()) { @@ -321,11 +321,11 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement) } } break; - case StatementKind::skGlobalVariable: + case StatementKind::GlobalVariable: return *(pIconsManager->getPixmap(IconsManager::PARSER_GLOBAL_VAR)); - case StatementKind::skLocalVariable: + case StatementKind::LocalVariable: return *(pIconsManager->getPixmap(IconsManager::PARSER_LOCAL_VAR)); - case StatementKind::skVariable: + case StatementKind::Variable: if (statement->isInherited()) { if (statement->accessibility == StatementAccessibility::Protected) { return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTD_VAR)); @@ -344,11 +344,11 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement) } } break; - case StatementKind::skKeyword: + case StatementKind::Keyword: return *(pIconsManager->getPixmap(IconsManager::PARSER_KEYWORD)); - case StatementKind::skUserCodeSnippet: + case StatementKind::UserCodeSnippet: return *(pIconsManager->getPixmap(IconsManager::PARSER_CODE_SNIPPET)); - case StatementKind::skAlias: + case StatementKind::Alias: return *(pIconsManager->getPixmap(IconsManager::PARSER_TYPE)); default: break; diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index b5eb3409..33c30d85 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -156,7 +156,7 @@ QList CppParser::getListOfFunctions(const QString &fileName, const Q PStatement statement = doFindStatementOf(fileName,phrase, line); if (!statement) return result; - if (statement->kind == StatementKind::skPreprocessor) { + if (statement->kind == StatementKind::Preprocessor) { if (statement->args.isEmpty()) { QString name = expandMacro(statement->value); statement = doFindStatementOf(fileName, name ,line); @@ -164,16 +164,16 @@ QList CppParser::getListOfFunctions(const QString &fileName, const Q return result; } } - while(statement && statement->kind == StatementKind::skAlias) + while(statement && statement->kind == StatementKind::Alias) statement = doFindAliasedStatement(statement); if (!statement) return result; PStatement parentScope; - if (statement->kind == StatementKind::skClass) { + if (statement->kind == StatementKind::Class) { parentScope = statement; } else parentScope = statement->parentScope.lock(); - if (parentScope && parentScope->kind == StatementKind::skNamespace) { + if (parentScope && parentScope->kind == StatementKind::Namespace) { PStatementList namespaceStatementsList = doFindNamespace(parentScope->command); if (namespaceStatementsList) { for (PStatement& namespaceStatement : *namespaceStatementsList) { @@ -237,9 +237,9 @@ PStatement CppParser::findFunctionAt(const QString &fileName, int line) if (!fileIncludes) return PStatement(); for (PStatement& statement : fileIncludes->statements) { - if (statement->kind != StatementKind::skFunction - && statement->kind != StatementKind::skConstructor - && statement->kind != StatementKind::skDestructor) + if (statement->kind != StatementKind::Function + && statement->kind != StatementKind::Constructor + && statement->kind != StatementKind::Destructor) continue; if (statement->line == line || statement->definitionLine == line) return statement; @@ -297,7 +297,7 @@ PStatement CppParser::doFindStatement(const QString &fullname) const for (int i=(phrases[0].isEmpty()?1:0);ikind == StatementKind::skNamespace) { + if (parentStatement && parentStatement->kind == StatementKind::Namespace) { PStatementList lst = doFindNamespace(parentStatement->fullName); foreach (const PStatement& namespaceStatement, *lst) { statement = findMemberOfStatement(phrase,namespaceStatement); @@ -390,20 +390,20 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, return PStatement(); } - if (!memberName.isEmpty() && (statement->kind == StatementKind::skTypedef)) { + if (!memberName.isEmpty() && (statement->kind == StatementKind::Typedef)) { PStatement typeStatement = doFindTypeDefinitionOf(fileName,statement->type, parentScopeType); if (typeStatement) statement = typeStatement; } //using alias like 'using std::vector;' - while (statement->kind == StatementKind::skAlias) { + while (statement->kind == StatementKind::Alias) { statement = doFindAliasedStatement(statement); if (!statement) return PStatement(); } - if (statement->kind == StatementKind::skConstructor) { + if (statement->kind == StatementKind::Constructor) { // we need the class, not the construtor statement = statement->parentScope.lock(); if (!statement) @@ -413,17 +413,17 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, QString typeName; PStatement typeStatement; while (!memberName.isEmpty()) { - if (statement->kind!=StatementKind::skClass + if (statement->kind!=StatementKind::Class && operatorToken == "::") { return PStatement(); } - if (statement->kind == StatementKind::skVariable - || statement->kind == StatementKind::skParameter - || statement->kind == StatementKind::skFunction) { + if (statement->kind == StatementKind::Variable + || statement->kind == StatementKind::Parameter + || statement->kind == StatementKind::Function) { bool isSTLContainerFunctions = false; - if (statement->kind == StatementKind::skFunction){ + if (statement->kind == StatementKind::Function){ PStatement parentScope = statement->parentScope.lock(); if (parentScope && STLContainers.contains(parentScope->fullName) @@ -488,7 +488,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, parentScopeType=statement; statement = memberStatement; - if (!memberName.isEmpty() && (statement->kind == StatementKind::skTypedef)) { + if (!memberName.isEmpty() && (statement->kind == StatementKind::Typedef)) { PStatement typeStatement = doFindTypeDefinitionOf(fileName,statement->type, parentScopeType); if (typeStatement) statement = typeStatement; @@ -556,7 +556,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QStringLi return PStatement(); } if (ownerEvalStatement->effectiveTypeStatement && - ownerEvalStatement->effectiveTypeStatement->kind == StatementKind::skNamespace) { + ownerEvalStatement->effectiveTypeStatement->kind == StatementKind::Namespace) { PStatementList lst = doFindNamespace(ownerEvalStatement->effectiveTypeStatement->fullName); foreach (const PStatement& namespaceStatement, *lst) { PStatement statement = findMemberOfStatement(phrase,namespaceStatement); @@ -639,14 +639,14 @@ PStatement CppParser::doFindAliasedStatement(const PStatement &statement) const PStatement CppParser::doFindNoTemplateSpecializationClass(const PStatement &statement) const { Q_ASSERT(statement!=nullptr); - Q_ASSERT(statement->kind == StatementKind::skClass); + Q_ASSERT(statement->kind == StatementKind::Class); if (statement->templateSpecializationParams.isEmpty()) return statement; PStatement parent = statement->parentScope.lock(); const StatementMap & statementMap = mStatementList.childrenStatements(parent); QList list = statementMap.values(statement->command); foreach(const PStatement &child, list) { - if (child->kind == StatementKind::skClass + if (child->kind == StatementKind::Class && child->templateSpecializationParams.isEmpty()) return child; } @@ -697,7 +697,7 @@ PStatement CppParser::doFindAliasedStatement(const PStatement &statement, QSetkind == StatementKind::skAlias) + if (result->kind == StatementKind::Alias) result = doFindAliasedStatement(result, foundSet); return result; } @@ -821,7 +821,7 @@ QStringList CppParser::getClassesList() PStatement statement = queue.dequeue(); StatementMap statementMap = mStatementList.childrenStatements(statement); for (PStatement& child:statementMap) { - if (child->kind == StatementKind::skClass) + if (child->kind == StatementKind::Class) list.append(child->command); if (!child->children.isEmpty()) queue.enqueue(child); @@ -1119,10 +1119,10 @@ void CppParser::parseHardDefines() "", define->value, -1, - StatementKind::skPreprocessor, + StatementKind::Preprocessor, StatementScope::Global, StatementAccessibility::None, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } } } @@ -1214,7 +1214,7 @@ QString CppParser::prettyPrintStatement(const PStatement& statement, const QStri { QString result; switch(statement->kind) { - case StatementKind::skPreprocessor: + case StatementKind::Preprocessor: if (statement->command == "__FILE__") result = '"'+filename+'"'; else if (statement->command == "__LINE__") @@ -1234,13 +1234,13 @@ QString CppParser::prettyPrintStatement(const PStatement& statement, const QStri result = hintText; } break; - case StatementKind::skEnumClassType: + case StatementKind::EnumClassType: result = "enum class "+statement->command; break; - case StatementKind::skEnumType: + case StatementKind::EnumType: result = "enum "+statement->command; break; - case StatementKind::skEnum: + case StatementKind::Enum: if (!statement->type.isEmpty()) result = statement->type + "::"; else @@ -1249,35 +1249,35 @@ QString CppParser::prettyPrintStatement(const PStatement& statement, const QStri if (!statement->value.isEmpty()) result += "(" + statement->value + ")"; break; - case StatementKind::skTypedef: + case StatementKind::Typedef: result = "typedef "+statement->type+" "+statement->command; if (!statement->args.isEmpty()) result += " "+statement->args; break; - case StatementKind::skAlias: + case StatementKind::Alias: result = "using "+statement->type; break; - case StatementKind::skFunction: - case StatementKind::skVariable: - case StatementKind::skParameter: - case StatementKind::skClass: + case StatementKind::Function: + case StatementKind::Variable: + case StatementKind::Parameter: + case StatementKind::Class: if (statement->scope!= StatementScope::Local) result = getScopePrefix(statement)+ ' '; // public result += statement->type + ' '; // void result += statement->fullName; // A::B::C::Bar result += statement->args; // (int a) break; - case StatementKind::skNamespace: + case StatementKind::Namespace: result = statement->fullName; // Bar break; - case StatementKind::skConstructor: + case StatementKind::Constructor: result = getScopePrefix(statement); // public result += QObject::tr("constructor") + ' '; // constructor result += statement->type + ' '; // void result += statement->fullName; // A::B::C::Bar result += statement->args; // (int a) break; - case StatementKind::skDestructor: + case StatementKind::Destructor: result = getScopePrefix(statement); // public result += QObject::tr("destructor") + ' '; // constructor result += statement->type + ' '; // void @@ -1298,7 +1298,7 @@ QString CppParser::getTemplateParam(const PStatement& statement, { if (!statement) return ""; - if (statement->kind != StatementKind::skTypedef) + if (statement->kind != StatementKind::Typedef) return ""; if (statement->type == phrase) // prevent infinite loop return ""; @@ -1368,7 +1368,7 @@ PStatement CppParser::addInheritedStatement(const PStatement& derived, const PSt inherit->kind, inherit->scope, access, - inherit->properties | StatementProperty::spInherited); + inherit->properties | StatementProperty::Inherited); return statement; } @@ -1424,13 +1424,13 @@ PStatement CppParser::addStatement(const PStatement& parent, // if (newCommand.startsWith("::") && parent && kind!=StatementKind::skBlock ) { // qDebug()<fullName; // } - if (kind == StatementKind::skConstructor - || kind == StatementKind::skFunction - || kind == StatementKind::skDestructor - || kind == StatementKind::skVariable + if (kind == StatementKind::Constructor + || kind == StatementKind::Function + || kind == StatementKind::Destructor + || kind == StatementKind::Variable ) { //find - if (properties.testFlag(StatementProperty::spHasDefinition)) { + if (properties.testFlag(StatementProperty::HasDefinition)) { PStatement oldStatement = findStatementInScope(newCommand,noNameArgs,kind,parent); if (oldStatement && !oldStatement->hasDefinition()) { oldStatement->setHasDefinition(true); @@ -1486,7 +1486,7 @@ PStatement CppParser::addStatement(const PStatement& parent, result->value.squeeze(); result->type.squeeze(); mStatementList.add(result); - if (result->kind == StatementKind::skNamespace) { + if (result->kind == StatementKind::Namespace) { PStatementList namespaceList = mNamespaces.value(result->fullName,PStatementList()); if (!namespaceList) { namespaceList=std::make_shared(); @@ -1495,7 +1495,7 @@ PStatement CppParser::addStatement(const PStatement& parent, namespaceList->append(result); } - if (result->kind!= StatementKind::skBlock) { + if (result->kind!= StatementKind::Block) { PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(fileName); if (fileIncludes) { fileIncludes->statements.insert(result->fullName,result); @@ -1616,10 +1616,10 @@ void CppParser::addMethodParameterStatement(QStringList words, int line, const P "", "", line, - StatementKind::skParameter, + StatementKind::Parameter, StatementScope::Local, StatementAccessibility::None, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } } } @@ -1728,9 +1728,9 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe // Add class list PStatement parentScope; - if (shouldResetBlock && statement && (statement->kind == StatementKind::skBlock)) { + if (shouldResetBlock && statement && (statement->kind == StatementKind::Block)) { parentScope = statement->parentScope.lock(); - while (parentScope && (parentScope->kind == StatementKind::skBlock)) { + while (parentScope && (parentScope->kind == StatementKind::Block)) { parentScope = parentScope->parentScope.lock(); } if (!parentScope) @@ -1752,7 +1752,7 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe // Set new scope if (!statement) mCurrentMemberAccessibility = StatementAccessibility::None; // {}, namespace or class that doesn't exist - else if (statement->kind == StatementKind::skNamespace) + else if (statement->kind == StatementKind::Namespace) mCurrentMemberAccessibility = StatementAccessibility::None; else if (statement->type == "class") mCurrentMemberAccessibility = StatementAccessibility::Private; // classes are private by default @@ -1777,7 +1777,7 @@ void CppParser::removeScopeLevel(int line, int maxIndex) PStatement currentScope = getCurrentScope(); PFileIncludes fileIncludes = mPreprocessor.findFileIncludes(mCurrentFile); if (currentScope) { - if (currentScope->kind == StatementKind::skBlock) { + if (currentScope->kind == StatementKind::Block) { if (currentScope->children.isEmpty()) { // remove no children block if (fileIncludes) @@ -1787,7 +1787,7 @@ void CppParser::removeScopeLevel(int line, int maxIndex) if (fileIncludes) fileIncludes->statements.insert(currentScope->fullName,currentScope); } - } else if (currentScope->kind == StatementKind::skClass) { + } else if (currentScope->kind == StatementKind::Class) { mIndex=indexOfNextSemicolon(mIndex, maxIndex); } } @@ -1998,10 +1998,10 @@ int CppParser::evaluateConstExprTerm(int endIndex, bool &ok) ok=false; return result; } - if (statement->kind == StatementKind::skEnum) { + if (statement->kind == StatementKind::Enum) { result = statement->value.toInt(&ok); break; - } else if (statement->kind == StatementKind::skAlias) { + } else if (statement->kind == StatementKind::Alias) { s = statement->value; } else { ok=false; @@ -2207,7 +2207,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) // operator overloading like (operator int) if (mTokenizer[mIndex+1]->text=="operator") { mIndex=indexAfterParentheis; - handleMethod(StatementKind::skFunction,"", + handleMethod(StatementKind::Function,"", mergeArgs(mIndex+1,mTokenizer[mIndex]->matchIndex-1), indexAfterParentheis,false,false,true, maxIndex); } else { @@ -2234,7 +2234,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) if (name.startsWith('~')) name=name.mid(1); if (removeTemplateParams(name)==removeTemplateParams(parentName)) { - handleMethod( (isDestructor?StatementKind::skDestructor:StatementKind::skConstructor), + handleMethod( (isDestructor?StatementKind::Destructor:StatementKind::Constructor), "", currentText, mIndex,false,false, false, maxIndex); @@ -2246,9 +2246,9 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) // Foo(); // }; PStatement scope=getCurrentScope(); - if (scope && scope->kind==StatementKind::skClass + if (scope && scope->kind==StatementKind::Class && removeTemplateParams(scope->command) == removeTemplateParams(currentText)) { - handleMethod(StatementKind::skConstructor,"", + handleMethod(StatementKind::Constructor,"", currentText, mIndex,false,false, false, maxIndex); return; @@ -2343,13 +2343,13 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) PStatement currentScope=getCurrentScope(); if (currentScope) { //in namespace, it might be function or object initilization - if (currentScope->kind == StatementKind::skNamespace) { + if (currentScope->kind == StatementKind::Namespace) { if (isNotFuncArgs(mIndex + 1)) { // var decl with init handleVar(sType+" "+sName,isExtern,isStatic, maxIndex); return; } - } else if (currentScope->kind != StatementKind::skClass) { + } else if (currentScope->kind != StatementKind::Class) { //not in class, it can't be a valid function definition // var decl with init handleVar(sType+" "+sName,isExtern,isStatic, maxIndex); @@ -2378,15 +2378,15 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) mIndex++; if (isDestructor) - handleMethod(StatementKind::skDestructor,sType, + handleMethod(StatementKind::Destructor,sType, sName,mIndex,false,isFriend, false, maxIndex); else { sType=sType.trimmed(); if (sType.isEmpty()) - handleMethod(StatementKind::skConstructor,sType, + handleMethod(StatementKind::Constructor,sType, sName,mIndex,false,isFriend, false, maxIndex); else - handleMethod(StatementKind::skFunction,sType, + handleMethod(StatementKind::Function,sType, sName,mIndex,isStatic,isFriend, false, maxIndex); } @@ -2569,7 +2569,7 @@ PStatement CppParser::getIncompleteClass(const QString &command, const PStatemen s.truncate(p); } PStatement result = doFindStatementOf(mCurrentFile,s,parentScope); - if (result && result->kind!=StatementKind::skClass) + if (result && result->kind!=StatementKind::Class) return PStatement(); return result; } @@ -2580,9 +2580,9 @@ StatementScope CppParser::getScope() PStatement currentScope = getCurrentScope(); // Invalid class or namespace/extern - if (!currentScope || (currentScope->kind == StatementKind::skNamespace)) + if (!currentScope || (currentScope->kind == StatementKind::Namespace)) return StatementScope::Global; - else if (currentScope->kind == StatementKind::skClass) + else if (currentScope->kind == StatementKind::Class) return StatementScope::ClassLocal; else return StatementScope::Local; @@ -2599,18 +2599,18 @@ PStatement CppParser::getTypeDef(const PStatement& statement, if (!statement) { return PStatement(); } - if (statement->kind == StatementKind::skClass - || statement->kind == StatementKind::skEnumType - || statement->kind == StatementKind::skEnumClassType) { + if (statement->kind == StatementKind::Class + || statement->kind == StatementKind::EnumType + || statement->kind == StatementKind::EnumClassType) { return statement; - } else if (statement->kind == StatementKind::skTypedef) { + } else if (statement->kind == StatementKind::Typedef) { if (statement->type == aType) // prevent infinite loop return statement; PStatement result = doFindTypeDefinitionOf(fileName,statement->type, statement->parentScope.lock()); if (!result) // found end of typedef trail, return result return statement; return result; - } else if (statement->kind == StatementKind::skAlias) { + } else if (statement->kind == StatementKind::Alias) { PStatement result = doFindAliasedStatement(statement); if (!result) // found end of typedef trail, return result return statement; @@ -2703,10 +2703,10 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", "", startLine, - StatementKind::skEnumClassType, + StatementKind::EnumClassType, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } else { enumStatement=addStatement( getCurrentScope(), @@ -2717,11 +2717,11 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", "", startLine, - StatementKind::skEnumType, + StatementKind::EnumType, getScope(), mCurrentMemberAccessibility, - isAdhocVar?(StatementProperty::spHasDefinition|StatementProperty::spDummyStatement) - :StatementProperty::spHasDefinition ); + isAdhocVar?(StatementProperty::HasDefinition|StatementProperty::DummyStatement) + :StatementProperty::HasDefinition ); } } if (isAdhocVar) { @@ -2745,10 +2745,10 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", "", mTokenizer[i]->line, - StatementKind::skVariable, + StatementKind::Variable, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } } else if (name!=',') { break; @@ -2795,10 +2795,10 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", canCalcValue?QString("%1").arg(value):"", mTokenizer[mIndex]->line, - StatementKind::skEnum, + StatementKind::Enum, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } } else { QString strValue=canCalcValue?QString("%1").arg(value):""; @@ -2812,10 +2812,10 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", strValue, mTokenizer[mIndex]->line, - StatementKind::skEnum, + StatementKind::Enum, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } addStatement( getCurrentScope(), @@ -2826,10 +2826,10 @@ void CppParser::handleEnum(bool isTypedef, int maxIndex) "", strValue, mTokenizer[mIndex]->line, - StatementKind::skEnum, + StatementKind::Enum, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } value++; } @@ -2924,10 +2924,10 @@ void CppParser::handleLambda(int index, int maxIndex) "", "", startLine, - StatementKind::skLambda, + StatementKind::Lambda, StatementScope::Local, StatementAccessibility::None, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); lambdaBlock->lambdaCaptures = captures; scanMethodArgs(lambdaBlock,argStart); addSoloScopeLevel(lambdaBlock,mTokenizer[bodyStart]->line); @@ -2978,7 +2978,7 @@ void CppParser::handleOperatorOverloading(const QString &sType, } Q_ASSERT(!op.isEmpty()); if (isIdentChar(op.front())) { - handleMethod(StatementKind::skFunction, + handleMethod(StatementKind::Function, sType+" "+op, "operator("+op+")", index, @@ -2987,7 +2987,7 @@ void CppParser::handleOperatorOverloading(const QString &sType, true, maxIndex); } else { - handleMethod(StatementKind::skFunction, + handleMethod(StatementKind::Function, sType, "operator"+op, index, @@ -3085,12 +3085,12 @@ void CppParser::handleMethod(StatementKind functionKind,const QString &sType, co functionKind, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition - | (isStatic?StatementProperty::spStatic:StatementProperty::spNone) - | (isOperatorOverload?StatementProperty::spOperatorOverloading:StatementProperty::spNone)); + StatementProperty::HasDefinition + | (isStatic?StatementProperty::Static:StatementProperty::None) + | (isOperatorOverload?StatementProperty::OperatorOverloading:StatementProperty::None)); scanMethodArgs(functionStatement, argStart); // add variable this to the class function - if (scopeStatement && scopeStatement->kind == StatementKind::skClass && + if (scopeStatement && scopeStatement->kind == StatementKind::Class && !isStatic) { //add this to non-static class member function addStatement( @@ -3102,11 +3102,11 @@ void CppParser::handleMethod(StatementKind functionKind,const QString &sType, co "", "", startLine, - StatementKind::skVariable, + StatementKind::Variable, StatementScope::Local, StatementAccessibility::None, - StatementProperty::spHasDefinition - | (isOperatorOverload?StatementProperty::spOperatorOverloading:StatementProperty::spNone)); + StatementProperty::HasDefinition + | (isOperatorOverload?StatementProperty::OperatorOverloading:StatementProperty::None)); } // add "__func__ variable" @@ -3119,11 +3119,11 @@ void CppParser::handleMethod(StatementKind functionKind,const QString &sType, co "", "\""+scopelessName+"\"", startLine+1, - StatementKind::skVariable, + StatementKind::Variable, StatementScope::Local, StatementAccessibility::None, - StatementProperty::spHasDefinition - | (isOperatorOverload?StatementProperty::spOperatorOverloading:StatementProperty::spNone)); + StatementProperty::HasDefinition + | (isOperatorOverload?StatementProperty::OperatorOverloading:StatementProperty::None)); } else { functionStatement = addStatement( @@ -3139,8 +3139,8 @@ void CppParser::handleMethod(StatementKind functionKind,const QString &sType, co functionKind, getScope(), mCurrentMemberAccessibility, - (isStatic?StatementProperty::spStatic:StatementProperty::spNone) - | (isOperatorOverload?StatementProperty::spOperatorOverloading:StatementProperty::spNone)); + (isStatic?StatementProperty::Static:StatementProperty::None) + | (isOperatorOverload?StatementProperty::OperatorOverloading:StatementProperty::None)); } } @@ -3211,10 +3211,10 @@ void CppParser::handleNamespace(KeywordType skipType, int maxIndex) "", // values //mTokenizer[mIndex]^.Line, startLine, - StatementKind::skNamespaceAlias, + StatementKind::NamespaceAlias, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); mIndex++; // skip ; return; } else if (isInline) { @@ -3239,10 +3239,10 @@ void CppParser::handleNamespace(KeywordType skipType, int maxIndex) "", // noname args "", // values startLine, - StatementKind::skNamespace, + StatementKind::Namespace, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); // find next '{' or ';' mIndex = indexOfNextSemicolonOrLeftBrace(mIndex, maxIndex); @@ -3337,10 +3337,10 @@ void CppParser::handleOtherTypedefs(int maxIndex) "", "", startLine, - StatementKind::skTypedef, + StatementKind::Typedef, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); tempType=""; } mIndex = mTokenizer[paramStart]->matchIndex+1; @@ -3360,10 +3360,10 @@ void CppParser::handleOtherTypedefs(int maxIndex) "", "", startLine, - StatementKind::skTypedef, + StatementKind::Typedef, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); tempType=""; newType = ""; mIndex++; @@ -3429,10 +3429,10 @@ void CppParser::handlePreprocessor() "",// noname args value, mTokenizer[mIndex]->line, - StatementKind::skPreprocessor, + StatementKind::Preprocessor, StatementScope::Global, StatementAccessibility::None, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } // TODO: undef ( define has limited scope) handlePreprocessorEnd: mIndex++; @@ -3496,10 +3496,10 @@ bool CppParser::handleStatement(int maxIndex) "", //mTokenizer[mIndex]^.Line, mTokenizer[mIndex]->line, - StatementKind::skBlock, + StatementKind::Block, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); addSoloScopeLevel(block,mTokenizer[mIndex]->line,true); mIndex++; } else if (mTokenizer[mIndex]->text[0] == '}') { @@ -3524,7 +3524,7 @@ bool CppParser::handleStatement(int maxIndex) && isIdentChar(mTokenizer[mIndex+1]->text[0]) && mTokenizer[mIndex+2]->text=='(') { //dont further check to speed up - handleMethod(StatementKind::skDestructor, "", '~'+mTokenizer[mIndex+1]->text, mIndex+2, false, false, false, maxIndex); + handleMethod(StatementKind::Destructor, "", '~'+mTokenizer[mIndex+1]->text, mIndex+2, false, false, false, maxIndex); } else { //error mIndex=moveToEndOfStatement(mIndex,false, maxIndex); @@ -3633,10 +3633,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", // noname args "", // values mTokenizer[mIndex]->line, - StatementKind::skTypedef, + StatementKind::Typedef, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); tempType=""; mIndex++; //skip , ; if (mTokenizer[mIndex]->text.front() == ';') @@ -3695,10 +3695,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", // values mTokenizer[mIndex]->line, //startLine, - StatementKind::skClass, + StatementKind::Class, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); command = ""; } mIndex++; @@ -3720,10 +3720,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", // values mTokenizer[mIndex]->line, //startLine, - StatementKind::skClass, + StatementKind::Class, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); command=""; } mIndex+=2; @@ -3790,10 +3790,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", mTokenizer[i]->line, //startLine, - StatementKind::skClass, + StatementKind::Class, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition | StatementProperty::spDummyStatement); + StatementProperty::HasDefinition | StatementProperty::DummyStatement); } if (isTypedef) { //typedef @@ -3806,10 +3806,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", "", mTokenizer[mIndex]->line, - StatementKind::skTypedef, + StatementKind::Typedef, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); // typedef + StatementProperty::HasDefinition); // typedef } else { //variable define addStatement( @@ -3821,10 +3821,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", "", mTokenizer[i]->line, - StatementKind::skVariable, + StatementKind::Variable, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); // TODO: not supported to pass list + StatementProperty::HasDefinition); // TODO: not supported to pass list } } command = ""; @@ -3841,7 +3841,7 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) } if (!firstSynonym) { PStatement scope = getCurrentScope(); - if (scope && scope->kind == StatementKind::skClass + if (scope && scope->kind == StatementKind::Class && mIndextext=="{") { //C11 anonymous union/struct addSoloScopeLevel(scope, mTokenizer[mIndex]->line); @@ -3859,10 +3859,10 @@ void CppParser::handleStructs(bool isTypedef, int maxIndex) "", "", mTokenizer[mIndex]->line, - StatementKind::skBlock, + StatementKind::Block, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } } if (mIndex < maxIndex) @@ -3907,10 +3907,10 @@ void CppParser::handleUsing(int maxIndex) "", // noname args "", // values startLine, - StatementKind::skTypedef, + StatementKind::Typedef, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); // skip ; mIndex++; return; @@ -3944,10 +3944,10 @@ void CppParser::handleUsing(int maxIndex) "", // noname args "", // values startLine, - StatementKind::skAlias, + StatementKind::Alias, getScope(), mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } //skip ; mIndex++; @@ -4023,7 +4023,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, && isIdentChar(mTokenizer[mIndex+1]->text.front()) && (isIdentChar(mTokenizer[mIndex+1]->text.back()) || isDigitChar(mTokenizer[mIndex+1]->text.back())) && addedVar - && !(addedVar->properties & StatementProperty::spFunctionPointer) + && !(addedVar->properties & StatementProperty::FunctionPointer) && AutoTypes.contains(addedVar->type)) { //handle e.g.: for(auto x:vec) // for(auto x:vec ) is replaced by "for { auto x: vec ;" in handleForAndCatch(); @@ -4082,7 +4082,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, if (mIndex+1text!="{" && addedVar - && !(addedVar->properties & StatementProperty::spFunctionPointer) + && !(addedVar->properties & StatementProperty::FunctionPointer) && AutoTypes.contains(addedVar->type)) { //handle e.g.: auto x=blahblah; int pos = 0; @@ -4156,13 +4156,13 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, "", "", mTokenizer[mIndex]->line, - StatementKind::skVariable, + StatementKind::Variable, getScope(), mCurrentMemberAccessibility, //True, - (isExtern?StatementProperty::spNone:StatementProperty::spHasDefinition) - | (isStatic?StatementProperty::spStatic:StatementProperty::spNone) - | StatementProperty::spFunctionPointer); + (isExtern?StatementProperty::None:StatementProperty::HasDefinition) + | (isStatic?StatementProperty::Static:StatementProperty::None) + | StatementProperty::FunctionPointer); } addedVar.reset(); tempType=""; @@ -4176,7 +4176,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, if (mIndex+1text) && addedVar - && !(addedVar->properties & StatementProperty::spFunctionPointer) + && !(addedVar->properties & StatementProperty::FunctionPointer) && AutoTypes.contains(addedVar->type)) { int pos = 0; int endIndex = mTokenizer[mIndex]->matchIndex; @@ -4244,12 +4244,12 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic, "", "", mTokenizer[mIndex]->line, - StatementKind::skVariable, + StatementKind::Variable, getScope(), mCurrentMemberAccessibility, //True, - (isExtern?StatementProperty::spNone:StatementProperty::spHasDefinition) - | (isStatic?StatementProperty::spStatic:StatementProperty::spNone)); + (isExtern?StatementProperty::None:StatementProperty::HasDefinition) + | (isStatic?StatementProperty::Static:StatementProperty::None)); tempType=""; } } @@ -4273,7 +4273,7 @@ void CppParser::handleInheritance(PStatement derivedStatement, PClassInheritance inheritanceInfo->parentClassName, inheritanceInfo->isGlobal?PStatement():derivedStatement->parentScope.lock()); - if (statement && statement->kind == StatementKind::skClass) { + if (statement && statement->kind == StatementKind::Class) { inheritClassStatement(derivedStatement, inheritanceInfo->isStruct, statement, @@ -4418,8 +4418,8 @@ void CppParser::inheritClassStatement(const PStatement& derived, bool isStruct, } foreach (const PStatement& statement, base->children) { if (statement->accessibility == StatementAccessibility::Private - || statement->kind == StatementKind::skConstructor - || statement->kind == StatementKind::skDestructor) + || statement->kind == StatementKind::Constructor + || statement->kind == StatementKind::Destructor) continue; if (derived->children.contains(statement->command)) { // Check if it's overwritten(hidden) by the derived @@ -4460,7 +4460,7 @@ QList CppParser::getListOfFunctions(const QString &fileName, int lin QSet includedFiles = internalGetIncludedFiles(fileName); for (const PStatement& child:children) { if (statement->command == child->command) { - if (child->kind == StatementKind::skAlias) + if (child->kind == StatementKind::Alias) continue; if (!includedFiles.contains(fileName)) continue; @@ -4480,7 +4480,7 @@ PStatement CppParser::findMacro(const QString &phrase, const QString &fileName) StatementList statements = statementMap.values(phrase); PFileIncludes includes = mPreprocessor.findFileIncludes(fileName); foreach (const PStatement& s, statements) { - if (s->kind == StatementKind::skPreprocessor) { + if (s->kind == StatementKind::Preprocessor) { if (includes && fileName != s->fileName && !includes->includeFiles.contains(s->fileName)) continue; return s; @@ -4583,7 +4583,7 @@ QList CppParser::findMembersOfStatement(const QString &phrase, const PStatement CppParser::findStatementInScope(const QString &name, const QString &noNameArgs, StatementKind kind, const PStatement& scope) const { - if (scope && scope->kind == StatementKind::skNamespace) { + if (scope && scope->kind == StatementKind::Namespace) { PStatementList namespaceStatementsList = doFindNamespace(scope->command); if (!namespaceStatementsList) return PStatement(); @@ -4602,7 +4602,7 @@ PStatement CppParser::findStatementInScope(const QString &name, const PStatement { if (!scope) return findMemberOfStatement(name,scope); - if (scope->kind == StatementKind::skNamespace) { + if (scope->kind == StatementKind::Namespace) { return findStatementInNamespace(name, scope->fullName); } else { return findMemberOfStatement(name,scope); @@ -5272,33 +5272,33 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName, // } } pos++; - if (statement && statement->kind == StatementKind::skConstructor) { + if (statement && statement->kind == StatementKind::Constructor) { statement = statement->parentScope.lock(); } - while (statement && statement->kind == StatementKind::skAlias) { + while (statement && statement->kind == StatementKind::Alias) { statement = doFindAliasedStatement(statement); } if (statement) { switch (statement->kind) { - case StatementKind::skNamespace: + case StatementKind::Namespace: result = doCreateEvalNamespace(statement); break; - case StatementKind::skNamespaceAlias: + case StatementKind::NamespaceAlias: result = doFindAliasedNamespace(statement); break; - case StatementKind::skVariable: - case StatementKind::skParameter: + case StatementKind::Variable: + case StatementKind::Parameter: result = doCreateEvalVariable(fileName,statement, previousResult?previousResult->templateParams:"",scope); break; - case StatementKind::skClass: + case StatementKind::Class: statement = doFindNoTemplateSpecializationClass(statement); [[fallthrough]]; - case StatementKind::skEnumType: - case StatementKind::skEnumClassType: - case StatementKind::skTypedef: + case StatementKind::EnumType: + case StatementKind::EnumClassType: + case StatementKind::Typedef: result = doCreateEvalType(fileName,statement); break; - case StatementKind::skFunction: { + case StatementKind::Function: { if (statement->type=="auto") { PStatement scopeStatement = statement->parentScope.lock(); if (scopeStatement) { @@ -5563,7 +5563,7 @@ PEvalStatement CppParser::doCreateEvalType(const QString& fileName,const PStatem { if (!typeStatement) return PEvalStatement(); - if (typeStatement->kind == StatementKind::skTypedef) { + if (typeStatement->kind == StatementKind::Typedef) { QString baseType; int pointerLevel=0; QString templateParams; @@ -5576,7 +5576,7 @@ PEvalStatement CppParser::doCreateEvalType(const QString& fileName,const PStatem tempStatement, pointerLevel, templateParams); - if (effectiveTypeStatement && effectiveTypeStatement->kind == StatementKind::skClass) + if (effectiveTypeStatement && effectiveTypeStatement->kind == StatementKind::Class) effectiveTypeStatement = doFindNoTemplateSpecializationClass(effectiveTypeStatement); return std::make_shared( baseType, @@ -5810,8 +5810,8 @@ PStatement CppParser::doParseEvalTypeInfo( typeStatement = doFindStatementOf(fileName,baseType,scope); PStatement effectiveTypeStatement = typeStatement; int level=0; - while (effectiveTypeStatement && (effectiveTypeStatement->kind == StatementKind::skTypedef - || effectiveTypeStatement->kind == StatementKind::skPreprocessor)) { + while (effectiveTypeStatement && (effectiveTypeStatement->kind == StatementKind::Typedef + || effectiveTypeStatement->kind == StatementKind::Preprocessor)) { if (level >20) // prevent infinite loop break; level++; @@ -6006,10 +6006,10 @@ void CppParser::scanMethodArgs(const PStatement& functionStatement, int argStart "", "", mTokenizer[i+1]->line, - StatementKind::skParameter, + StatementKind::Parameter, StatementScope::Local, StatementAccessibility::None, - StatementProperty::spHasDefinition); + StatementProperty::HasDefinition); } i=argEnd+1; words.clear(); @@ -6277,9 +6277,9 @@ bool CppParser::isNotFuncArgs(int startIndex) bool CppParser::isNamedScope(StatementKind kind) const { switch(kind) { - case StatementKind::skClass: - case StatementKind::skNamespace: - case StatementKind::skFunction: + case StatementKind::Class: + case StatementKind::Namespace: + case StatementKind::Function: return true; default: return false; @@ -6289,10 +6289,10 @@ bool CppParser::isNamedScope(StatementKind kind) const bool CppParser::isTypeStatement(StatementKind kind) const { switch(kind) { - case StatementKind::skClass: - case StatementKind::skTypedef: - case StatementKind::skEnumClassType: - case StatementKind::skEnumType: + case StatementKind::Class: + case StatementKind::Typedef: + case StatementKind::EnumClassType: + case StatementKind::EnumType: return true; default: return false; diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index 9add7799..623ba217 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -618,10 +618,10 @@ MemberOperatorType getOperatorType(const QString &phrase, int index) bool isScopeTypeKind(StatementKind kind) { switch(kind) { - case StatementKind::skClass: - case StatementKind::skNamespace: - case StatementKind::skEnumType: - case StatementKind::skEnumClassType: + case StatementKind::Class: + case StatementKind::Namespace: + case StatementKind::EnumType: + case StatementKind::EnumClassType: return true; default: return false; @@ -713,17 +713,17 @@ bool isMemberOperator(QString token) StatementKind getKindOfStatement(const PStatement& statement) { if (!statement) - return StatementKind::skUnknown; - if (statement->kind == StatementKind::skVariable) { + return StatementKind::Unknown; + if (statement->kind == StatementKind::Variable) { if (!statement->parentScope.lock()) { - return StatementKind::skGlobalVariable; + return StatementKind::GlobalVariable; } else if (statement->scope == StatementScope::Local) { - return StatementKind::skLocalVariable; + return StatementKind::LocalVariable; } else { - return StatementKind::skVariable; + return StatementKind::Variable; } - } else if (statement->kind == StatementKind::skParameter) { - return StatementKind::skLocalVariable; + } else if (statement->kind == StatementKind::Parameter) { + return StatementKind::LocalVariable; } return statement->kind; } @@ -755,12 +755,12 @@ bool isCppControlKeyword(const QString &word) bool isTypeKind(StatementKind kind) { switch(kind) { - case StatementKind::skClass: - case StatementKind::skNamespace: - case StatementKind::skEnumType: - case StatementKind::skEnumClassType: - case StatementKind::skTypedef: - case StatementKind::skPreprocessor: + case StatementKind::Class: + case StatementKind::Namespace: + case StatementKind::EnumType: + case StatementKind::EnumClassType: + case StatementKind::Typedef: + case StatementKind::Preprocessor: return true; default: return false; diff --git a/RedPandaIDE/parser/parserutils.h b/RedPandaIDE/parser/parserutils.h index c293fcd8..39c36638 100644 --- a/RedPandaIDE/parser/parserutils.h +++ b/RedPandaIDE/parser/parserutils.h @@ -25,7 +25,7 @@ using GetFileStreamCallBack = std::function; -enum ParserLanguage { +enum class ParserLanguage { C, CPlusPlus, #ifdef ENABLE_SDCC @@ -33,6 +33,10 @@ enum ParserLanguage { #endif }; +inline qHash(const ParserLanguage& value, uint seed) { + return qHash((int)value, seed); +} + struct CodeSnippet { QString caption; //Name QString prefix; //Prefix used in code suggestion @@ -88,34 +92,35 @@ enum class KeywordType { NotKeyword }; -//It will be used as hash key. DONT make it enum class!!!!! -enum StatementKind { - skUnknown, - skNamespace, - skNamespaceAlias, - skClass, - skPreprocessor, - skEnumType, - skEnumClassType, - skTypedef, - skConstructor, - skDestructor, - skFunction, - skVariable, - skGlobalVariable, - skLocalVariable, - skEnum, - skOperator, - skParameter, - skBlock, - skLambda, - skUserCodeSnippet, // user code template - skKeyword, // keywords - skKeywordType, //keywords for type (for color management) - skAlias +enum class StatementKind { + Unknown, + Namespace, + NamespaceAlias, + Class, + Preprocessor, + EnumType, + EnumClassType, + Typedef, + Constructor, + Destructor, + Function, + Variable, + GlobalVariable, + LocalVariable, + Enum, + Operator, + Parameter, + Block, + Lambda, + UserCodeSnippet, // user code template + Keyword, // keywords + KeywordType, //keywords for type (for color management) + Alias, // using alias }; -using StatementKindSet = QSet; +inline qHash(const StatementKind& value, uint seed) { + return qHash((int)value, seed); +} enum class StatementScope { Global, @@ -131,10 +136,10 @@ enum class StatementAccessibility { }; enum class MemberOperatorType { - Arrow, - Dot, - DColon, - Other + Arrow, + Dot, + DColon, + Other }; enum class EvalStatementKind { @@ -150,19 +155,19 @@ struct StatementMatchPosition{ uint16_t end; }; -enum StatementProperty { - spNone = 0x0, - spStatic = 0x0001, - spHasDefinition = 0x0002, - spInProject = 0x0004, - spInSystemHeader = 0x0008, - spInherited = 0x0010, - spVirtual = 0x0020, - spOverride = 0x0040, - spConstexpr = 0x0080, - spFunctionPointer = 0x0100, - spOperatorOverloading = 0x0200, - spDummyStatement = 0x0400 +enum class StatementProperty { + None = 0x0, + Static = 0x0001, + HasDefinition = 0x0002, + InProject = 0x0004, + InSystemHeader = 0x0008, + Inherited = 0x0010, + Virtual = 0x0020, + Override = 0x0040, + Constexpr = 0x0080, + FunctionPointer = 0x0100, + OperatorOverloading = 0x0200, + DummyStatement = 0x0400 }; Q_DECLARE_FLAGS(StatementProperties, StatementProperty) @@ -212,33 +217,33 @@ struct Statement { // definiton line/filename is valid bool hasDefinition() { - return properties.testFlag(StatementProperty::spHasDefinition); + return properties.testFlag(StatementProperty::HasDefinition); } void setHasDefinition(bool on) { - properties.setFlag(StatementProperty::spHasDefinition,on); + properties.setFlag(StatementProperty::HasDefinition,on); } // statement in project bool inProject() { - return properties.testFlag(StatementProperty::spInProject); + return properties.testFlag(StatementProperty::InProject); } void setInProject(bool on) { - properties.setFlag(StatementProperty::spInProject, on); + properties.setFlag(StatementProperty::InProject, on); } // statement in system header (#include <>) bool inSystemHeader() { - return properties.testFlag(StatementProperty::spInSystemHeader); + return properties.testFlag(StatementProperty::InSystemHeader); } void setInSystemHeader(bool on) { - properties.setFlag(StatementProperty::spInSystemHeader, on); + properties.setFlag(StatementProperty::InSystemHeader, on); } bool isStatic() { - return properties.testFlag(StatementProperty::spStatic); + return properties.testFlag(StatementProperty::Static); } // static function / variable void setIsStatic(bool on) { - properties.setFlag(StatementProperty::spStatic, on); + properties.setFlag(StatementProperty::Static, on); } bool isInherited() { - return properties.testFlag(StatementProperty::spInherited); + return properties.testFlag(StatementProperty::Inherited); } // inherted member; }; diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 30810469..64b58e4b 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -149,14 +149,14 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const if (role == Qt::DisplayRole) { if (node->statement) { if (!(node->statement->type.isEmpty())) { - if ((node->statement->kind == StatementKind::skFunction) - || (node->statement->kind == StatementKind::skVariable) - || (node->statement->kind == StatementKind::skTypedef) + if ((node->statement->kind == StatementKind::Function) + || (node->statement->kind == StatementKind::Variable) + || (node->statement->kind == StatementKind::Typedef) ) { return node->statement->command + node->statement->args + " : " + node->statement->type; } } - if (node->statement->kind == StatementKind::skEnum) { + if (node->statement->kind == StatementKind::Enum) { if (!node->statement->value.isEmpty()) return node->statement->command + node->statement->args + QString("(%1)").arg(node->statement->value); else @@ -168,9 +168,9 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const if (mColors && node->statement) { PStatement statement = (node->statement); StatementKind kind = getKindOfStatement(statement); - if (kind == StatementKind::skKeyword) { + if (kind == StatementKind::Keyword) { if (statement->command.startsWith('#')) - kind = StatementKind::skPreprocessor; + kind = StatementKind::Preprocessor; } PColorSchemeItem item = mColors->value(kind,PColorSchemeItem()); if (item) { @@ -361,9 +361,9 @@ void ClassBrowserModel::filterChildren(ClassBrowserNode *node, const StatementMa // if (statement->properties.testFlag(StatementProperty::spDummyStatement)) // continue; - if (statement->kind == StatementKind::skBlock) + if (statement->kind == StatementKind::Block) continue; - if (statement->kind == StatementKind::skLambda) + if (statement->kind == StatementKind::Lambda) continue; if (statement->isInherited() && !pSettings->ui().classBrowserShowInherited()) continue; @@ -457,10 +457,10 @@ ClassBrowserNode* ClassBrowserModel::getParentNode(const PStatement &parentState bool ClassBrowserModel::isScopeStatement(const PStatement &statement) { switch(statement->kind) { - case StatementKind::skClass: - case StatementKind::skNamespace: - case StatementKind::skEnumClassType: - case StatementKind::skEnumType: + case StatementKind::Class: + case StatementKind::Namespace: + case StatementKind::EnumClassType: + case StatementKind::EnumType: return true; default: return false; diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index 24a1b3fa..c31ef68c 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -274,14 +274,14 @@ void CodeCompletionPopup::addFunctionWithoutDefinitionChildren(const PStatement& continue; } switch(childStatement->kind) { - case StatementKind::skConstructor: - case StatementKind::skFunction: - case StatementKind::skDestructor: + case StatementKind::Constructor: + case StatementKind::Function: + case StatementKind::Destructor: if (!childStatement->hasDefinition()) addStatement(childStatement,fileName,line); break; - case StatementKind::skClass: - case StatementKind::skNamespace: + case StatementKind::Class: + case StatementKind::Namespace: if (isIncluded(childStatement->fileName)) addStatement(childStatement,fileName,line); break; @@ -295,12 +295,12 @@ void CodeCompletionPopup::addStatement(const PStatement& statement, const QStrin { if (mAddedStatements.contains(statement->command)) return; - if (statement->kind == StatementKind::skConstructor - || statement->kind == StatementKind::skDestructor - || statement->kind == StatementKind::skBlock - || statement->kind == StatementKind::skLambda - || statement->properties.testFlag(StatementProperty::spOperatorOverloading) - || statement->properties.testFlag(StatementProperty::spDummyStatement) + if (statement->kind == StatementKind::Constructor + || statement->kind == StatementKind::Destructor + || statement->kind == StatementKind::Block + || statement->kind == StatementKind::Lambda + || statement->properties.testFlag(StatementProperty::OperatorOverloading) + || statement->properties.testFlag(StatementProperty::DummyStatement) ) return; if ((line!=-1) @@ -308,7 +308,7 @@ void CodeCompletionPopup::addStatement(const PStatement& statement, const QStrin && (fileName == statement->fileName)) return; mAddedStatements.insert(statement->command); - if (statement->kind == StatementKind::skUserCodeSnippet || !statement->command.contains("<")) + if (statement->kind == StatementKind::UserCodeSnippet || !statement->command.contains("<")) mFullCompletionStatementList.append(statement); } @@ -326,19 +326,19 @@ static bool defaultComparator(PStatement statement1,PStatement statement2) { if (statement1->caseMatched != statement2->caseMatched) return statement1->caseMatched > statement2->caseMatched; // Show user template first - if (statement1->kind == StatementKind::skUserCodeSnippet) { - if (statement2->kind != StatementKind::skUserCodeSnippet) + if (statement1->kind == StatementKind::UserCodeSnippet) { + if (statement2->kind != StatementKind::UserCodeSnippet) return true; else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skUserCodeSnippet) { + } else if (statement2->kind == StatementKind::UserCodeSnippet) { return false; // show keywords first - } else if ((statement1->kind == StatementKind::skKeyword) - && (statement2->kind != StatementKind::skKeyword)) { + } else if ((statement1->kind == StatementKind::Keyword) + && (statement2->kind != StatementKind::Keyword)) { return true; - } else if ((statement1->kind != StatementKind::skKeyword) - && (statement2->kind == StatementKind::skKeyword)) { + } else if ((statement1->kind != StatementKind::Keyword) + && (statement2->kind == StatementKind::Keyword)) { return false; } else return nameComparator(statement1,statement2); @@ -354,22 +354,22 @@ static bool sortByScopeComparator(PStatement statement1,PStatement statement2){ if (statement1->caseMatched != statement2->caseMatched) return statement1->caseMatched > statement2->caseMatched; // Show user template first - if (statement1->kind == StatementKind::skUserCodeSnippet) { - if (statement2->kind != StatementKind::skUserCodeSnippet) + if (statement1->kind == StatementKind::UserCodeSnippet) { + if (statement2->kind != StatementKind::UserCodeSnippet) return true; else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skUserCodeSnippet) { + } else if (statement2->kind == StatementKind::UserCodeSnippet) { return false; // show non-system defines before keyword - } else if (statement1->kind == StatementKind::skKeyword) { - if (statement2->kind != StatementKind::skKeyword) { + } else if (statement1->kind == StatementKind::Keyword) { + if (statement2->kind != StatementKind::Keyword) { //s1 keyword / s2 system defines, s1 < s2, should return true //s1 keyword / s2 not system defines, s2 < s1, should return false; return statement2->inSystemHeader(); } else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skKeyword) { + } else if (statement2->kind == StatementKind::Keyword) { //s1 system defines / s2 keyword, s2 < s1, should return false; //s1 not system defines / s2 keyword, s1 < s2, should return true; return (!statement1->inSystemHeader()); @@ -398,23 +398,23 @@ static bool sortWithUsageComparator(PStatement statement1,PStatement statement2) if (statement1->caseMatched != statement2->caseMatched) return statement1->caseMatched > statement2->caseMatched; // Show user template first - if (statement1->kind == StatementKind::skUserCodeSnippet) { - if (statement2->kind != StatementKind::skUserCodeSnippet) + if (statement1->kind == StatementKind::UserCodeSnippet) { + if (statement2->kind != StatementKind::UserCodeSnippet) return true; else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skUserCodeSnippet) { + } else if (statement2->kind == StatementKind::UserCodeSnippet) { return false; //show most freq first } if (statement1->usageCount != statement2->usageCount) return statement1->usageCount > statement2->usageCount; - if ((statement1->kind != StatementKind::skKeyword) - && (statement2->kind == StatementKind::skKeyword)) { + if ((statement1->kind != StatementKind::Keyword) + && (statement2->kind == StatementKind::Keyword)) { return true; - } else if ((statement1->kind == StatementKind::skKeyword) - && (statement2->kind != StatementKind::skKeyword)) { + } else if ((statement1->kind == StatementKind::Keyword) + && (statement2->kind != StatementKind::Keyword)) { return false; } else return nameComparator(statement1,statement2); @@ -430,12 +430,12 @@ static bool sortByScopeWithUsageComparator(PStatement statement1,PStatement stat if (statement1->caseMatched != statement2->caseMatched) return statement1->caseMatched > statement2->caseMatched; // Show user template first - if (statement1->kind == StatementKind::skUserCodeSnippet) { - if (statement2->kind != StatementKind::skUserCodeSnippet) + if (statement1->kind == StatementKind::UserCodeSnippet) { + if (statement2->kind != StatementKind::UserCodeSnippet) return true; else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skUserCodeSnippet) { + } else if (statement2->kind == StatementKind::UserCodeSnippet) { return false; //show most freq first } @@ -443,14 +443,14 @@ static bool sortByScopeWithUsageComparator(PStatement statement1,PStatement stat return statement1->usageCount > statement2->usageCount; // show non-system defines before keyword - if (statement1->kind == StatementKind::skKeyword) { - if (statement2->kind != StatementKind::skKeyword) { + if (statement1->kind == StatementKind::Keyword) { + if (statement2->kind != StatementKind::Keyword) { //s1 keyword / s2 system defines, s1 < s2, should return true //s1 keyword / s2 not system defines, s2 < s1, should return false; return statement2->inSystemHeader(); } else return statement1->command < statement2->command; - } else if (statement2->kind == StatementKind::skKeyword) { + } else if (statement2->kind == StatementKind::Keyword) { //s1 system defines / s2 keyword, s2 < s1, should return false; //s1 not system defines / s2 keyword, s1 < s2, should return true; return (!statement1->inSystemHeader()); @@ -598,7 +598,7 @@ void CodeCompletionPopup::getMacroCompletionList(const QString &fileName, int li { const StatementMap& statementMap = mParser->statementList().childrenStatements(nullptr); foreach(const PStatement& statement, statementMap.values()) { - if (statement->kind==StatementKind::skPreprocessor) + if (statement->kind==StatementKind::Preprocessor) addStatement(statement,fileName,line); } } @@ -649,7 +649,7 @@ void CodeCompletionPopup::getCompletionFor( PStatement statement = std::make_shared(); statement->command = codeIn->prefix; statement->value = codeIn->code; - statement->kind = StatementKind::skUserCodeSnippet; + statement->kind = StatementKind::UserCodeSnippet; statement->fullName = codeIn->prefix; statement->usageCount = 0; mFullCompletionStatementList.append(statement); @@ -686,13 +686,13 @@ void CodeCompletionPopup::getCompletionFor( // repeat until reach global while (scopeStatement) { //add members of current scope that not added before - if (scopeStatement->kind == StatementKind::skNamespace) { + if (scopeStatement->kind == StatementKind::Namespace) { PStatementList namespaceStatementsList = mParser->findNamespace(scopeStatement->fullName); foreach (const PStatement& namespaceStatement,*namespaceStatementsList) { addChildren(namespaceStatement, fileName, line, isLambdaReturnType); } - } else if (scopeStatement->kind == StatementKind::skClass) { + } else if (scopeStatement->kind == StatementKind::Class) { addChildren(scopeStatement, fileName, -1, isLambdaReturnType); } else { addChildren(scopeStatement, fileName, line, isLambdaReturnType); @@ -708,7 +708,7 @@ void CodeCompletionPopup::getCompletionFor( addChildren(namespaceStatement, fileName, line, isLambdaReturnType); } } - if (scopeStatement->kind == StatementKind::skLambda) { + if (scopeStatement->kind == StatementKind::Lambda) { foreach (const QString& phrase, scopeStatement->lambdaCaptures) { if (phrase=="&" || phrase == "=" || phrase =="this") continue; @@ -724,12 +724,12 @@ void CodeCompletionPopup::getCompletionFor( } else if (scopeStatement->lambdaCaptures.contains("this")) { do { scopeStatement = scopeStatement->parentScope.lock(); - } while (scopeStatement && scopeStatement->kind!=StatementKind::skClass - && scopeStatement->kind!=StatementKind::skNamespace); + } while (scopeStatement && scopeStatement->kind!=StatementKind::Class + && scopeStatement->kind!=StatementKind::Namespace); } else { do { scopeStatement = scopeStatement->parentScope.lock(); - } while (scopeStatement && scopeStatement->kind!=StatementKind::skNamespace); + } while (scopeStatement && scopeStatement->kind!=StatementKind::Namespace); } continue; } @@ -863,8 +863,8 @@ void CodeCompletionPopup::getCompletionFor( foreach (const PStatement& childStatement, children) { if ((childStatement->accessibility==StatementAccessibility::Public) && !( - childStatement->kind == StatementKind::skConstructor - || childStatement->kind == StatementKind::skDestructor) + childStatement->kind == StatementKind::Constructor + || childStatement->kind == StatementKind::Destructor) && !mAddedStatements.contains(childStatement->command)) { addStatement(childStatement,fileName,-1); } @@ -880,8 +880,8 @@ void CodeCompletionPopup::getCompletionFor( if (!isIncluded(classTypeStatement->fileName) && !isIncluded(classTypeStatement->definitionFileName)) return; - if (classTypeStatement->kind == StatementKind::skEnumType - || classTypeStatement->kind == StatementKind::skEnumClassType) { + if (classTypeStatement->kind == StatementKind::EnumType + || classTypeStatement->kind == StatementKind::EnumClassType) { const StatementMap& children = mParser->statementList().childrenStatements(classTypeStatement); foreach (const PStatement& child,children) { @@ -896,11 +896,11 @@ void CodeCompletionPopup::getCompletionFor( foreach (const PStatement& childStatement, children) { if ( (childStatement->isStatic()) - || (childStatement->kind == StatementKind::skTypedef - || childStatement->kind == StatementKind::skClass - || childStatement->kind == StatementKind::skEnum - || childStatement->kind == StatementKind::skEnumClassType - || childStatement->kind == StatementKind::skEnumType + || (childStatement->kind == StatementKind::Typedef + || childStatement->kind == StatementKind::Class + || childStatement->kind == StatementKind::Enum + || childStatement->kind == StatementKind::EnumClassType + || childStatement->kind == StatementKind::EnumType )) { addStatement(childStatement,fileName,-1); } @@ -912,11 +912,11 @@ void CodeCompletionPopup::getCompletionFor( foreach (const PStatement& childStatement,children) { if ( (childStatement->isStatic()) - || (childStatement->kind == StatementKind::skTypedef - || childStatement->kind == StatementKind::skClass - || childStatement->kind == StatementKind::skEnum - || childStatement->kind == StatementKind::skEnumClassType - || childStatement->kind == StatementKind::skEnumType + || (childStatement->kind == StatementKind::Typedef + || childStatement->kind == StatementKind::Class + || childStatement->kind == StatementKind::Enum + || childStatement->kind == StatementKind::EnumClassType + || childStatement->kind == StatementKind::EnumType )) { if (childStatement->accessibility == StatementAccessibility::Public) addStatement(childStatement,fileName,-1); @@ -950,12 +950,12 @@ void CodeCompletionPopup::getCompletionForFunctionWithoutDefinition(const QStrin getCompletionListForComplexKeyword(preWord); PStatement scopeStatement = mCurrentScope; //add members of current scope that not added before - while (scopeStatement && scopeStatement->kind!=StatementKind::skNamespace - && scopeStatement->kind!=StatementKind::skClass) { + while (scopeStatement && scopeStatement->kind!=StatementKind::Namespace + && scopeStatement->kind!=StatementKind::Class) { scopeStatement = scopeStatement->parentScope.lock(); } if (scopeStatement) { - if (scopeStatement->kind == StatementKind::skNamespace) { + if (scopeStatement->kind == StatementKind::Namespace) { //namespace; PStatementList namespaceStatementsList = mParser->findNamespace(scopeStatement->fullName); @@ -1007,7 +1007,7 @@ void CodeCompletionPopup::getCompletionForFunctionWithoutDefinition(const QStrin } } return; - } else if (ownerStatement->effectiveTypeStatement->kind == StatementKind::skClass) { + } else if (ownerStatement->effectiveTypeStatement->kind == StatementKind::Class) { addKeyword("operator"); addFunctionWithoutDefinitionChildren(ownerStatement->effectiveTypeStatement, fileName, line); } @@ -1104,7 +1104,7 @@ void CodeCompletionPopup::addKeyword(const QString &keyword) { PStatement statement = std::make_shared(); statement->command = keyword; - statement->kind = StatementKind::skKeyword; + statement->kind = StatementKind::Keyword; statement->fullName = keyword; statement->usageCount = 0; mFullCompletionStatementList.append(statement); diff --git a/RedPandaIDE/widgets/newclassdialog.cpp b/RedPandaIDE/widgets/newclassdialog.cpp index 3f6d60cf..199c2a87 100644 --- a/RedPandaIDE/widgets/newclassdialog.cpp +++ b/RedPandaIDE/widgets/newclassdialog.cpp @@ -131,7 +131,7 @@ void NewClassCandidatesModel::fillClasses() if (!mParser->freeze()) return; foreach( const PStatement& s, mParser->statementList().childrenStatements()) { - if (s->kind==StatementKind::skClass + if (s->kind==StatementKind::Class && s->inProject() && !s->command.startsWith("_") && !s->command.contains("<") @@ -141,7 +141,7 @@ void NewClassCandidatesModel::fillClasses() mCandidates.append(s); mClassNames.insert(s->fullName); } - } else if (s->kind == StatementKind::skNamespace + } else if (s->kind == StatementKind::Namespace && !s->command.startsWith("_") && !s->command.contains("<")) { fillClassesInNamespace(s); @@ -157,7 +157,7 @@ void NewClassCandidatesModel::fillClasses() void NewClassCandidatesModel::fillClassesInNamespace(PStatement ns) { foreach( const PStatement& s, mParser->statementList().childrenStatements(ns)) { - if (s->kind==StatementKind::skClass + if (s->kind==StatementKind::Class && s->inProject() && !s->command.startsWith("_") && !s->command.contains("<") @@ -167,7 +167,7 @@ void NewClassCandidatesModel::fillClassesInNamespace(PStatement ns) mCandidates.append(s); mClassNames.insert(s->fullName); } - } else if (s->kind == StatementKind::skNamespace + } else if (s->kind == StatementKind::Namespace && !s->command.startsWith("_") && !s->command.contains("<")) { fillClassesInNamespace(s); diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 6e3fc84b..446f61d1 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -170,7 +170,7 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent), setAcceptDrops(true); setFont(mFontDummy); - setScrollBars(ScrollStyle::ssBoth); + setScrollBars(ScrollStyle::Both); } int QSynEdit::displayLineCount() const @@ -3801,7 +3801,7 @@ ScrollStyle QSynEdit::scrollBars() const void QSynEdit::setScrollBars(ScrollStyle newScrollBars) { mScrollBars = newScrollBars; - if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) { + if (mScrollBars == ScrollStyle::Both || mScrollBars == ScrollStyle::OnlyHorizontal) { if (mOptions.testFlag(EditorOption::AutoHideScrollbars)) { setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); } else { @@ -3811,7 +3811,7 @@ void QSynEdit::setScrollBars(ScrollStyle newScrollBars) } else { setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff); } - if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) { + if (mScrollBars == ScrollStyle::Both || mScrollBars == ScrollStyle::OnlyVertical) { if (mOptions.testFlag(EditorOption::AutoHideScrollbars)) { setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); } else { @@ -6816,7 +6816,7 @@ void QSynEdit::setLeftPos(int value) if (mDocument->maxLineWidth()<0) mLeftPos = value; setStatusChanged(StatusChange::LeftPos); - if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) + if (mScrollBars == ScrollStyle::Both || mScrollBars == ScrollStyle::OnlyHorizontal) horizontalScrollBar()->setValue(value); else { if (mDocument->maxLineWidth()>0) { @@ -6845,7 +6845,7 @@ void QSynEdit::setTopPos(int value) if (value != mTopPos) { setStatusChanged(StatusChange::TopPos); mTopPos = value; - if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) { + if (mScrollBars == ScrollStyle::Both || mScrollBars == ScrollStyle::OnlyVertical) { verticalScrollBar()->setValue(value); } else { invalidate(); diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 1e396796..cf876da4 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -35,7 +35,7 @@ namespace QSynedit { enum class ScrollStyle { - ssNone, ssHorizontal, ssVertical, ssBoth + None, OnlyHorizontal, OnlyVertical, Both }; enum class EditCaretType {