diff --git a/src/plugins/clangcodemodel/clangdclient.h b/src/plugins/clangcodemodel/clangdclient.h index 5a12c8f56d7..1b57ea4b66f 100644 --- a/src/plugins/clangcodemodel/clangdclient.h +++ b/src/plugins/clangcodemodel/clangdclient.h @@ -14,7 +14,10 @@ #include -namespace Core { class SearchResult; } +namespace Core { +class HelpItem; +class SearchResult; +} namespace CppEditor { class CppEditorWidget; } namespace LanguageServerProtocol { class Range; } namespace ProjectExplorer { diff --git a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp index 5bf59150446..18fd250a982 100644 --- a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp +++ b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp @@ -6,6 +6,8 @@ #include "clangdclient.h" #include "clangmodelmanagersupport.h" +#include + #include #include #include diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index c2c8c88801b..24edc0b954a 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -47,7 +47,7 @@ Project *projectForCurrentEditor() return nullptr; if (ProjectPart::ConstPtr projectPart = projectPartForFile(filePath)) - return projectForProjectPart(*projectPart); + return projectPart->project(); return nullptr; } @@ -80,7 +80,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangDiagnostic &diagnostic) // Get config ClangDiagnosticConfig config = diagnosticConfig(); - ClangDiagnosticConfigsModel configsModel = CppEditor::diagnosticConfigsModel(); + ClangDiagnosticConfigsModel configsModel = ClangdSettings::diagnosticConfigsModel(); // Create copy if needed if (config.isReadOnly()) { diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index b27117f056e..11e7398f372 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -5,6 +5,7 @@ #include "clangcodemodeltr.h" +#include #include #include #include diff --git a/src/plugins/clangtools/diagnosticconfigswidget.cpp b/src/plugins/clangtools/diagnosticconfigswidget.cpp index 81aa6fb2305..51aec7c0400 100644 --- a/src/plugins/clangtools/diagnosticconfigswidget.cpp +++ b/src/plugins/clangtools/diagnosticconfigswidget.cpp @@ -38,12 +38,12 @@ #include #include #include +#include #include #include #include #include - using namespace CppEditor; using namespace Utils; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index f3e512eebb0..0ab987d978a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/src/plugins/cppeditor/baseeditordocumentparser.h b/src/plugins/cppeditor/baseeditordocumentparser.h index dce82893848..fb7686f1470 100644 --- a/src/plugins/cppeditor/baseeditordocumentparser.h +++ b/src/plugins/cppeditor/baseeditordocumentparser.h @@ -6,8 +6,10 @@ #include "cppeditor_global.h" #include "cpptoolsreuse.h" #include "cppworkingcopy.h" +#include "projectpart.h" #include +#include #include #include diff --git a/src/plugins/cppeditor/builtincursorinfo.cpp b/src/plugins/cppeditor/builtincursorinfo.cpp index 0bff4406e76..2b2acf82f1c 100644 --- a/src/plugins/cppeditor/builtincursorinfo.cpp +++ b/src/plugins/cppeditor/builtincursorinfo.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -26,6 +27,51 @@ namespace CppEditor { using SemanticUses = QList; namespace { +static bool isOwnershipRAIIName(const QString &name) +{ + static QSet knownNames; + if (knownNames.isEmpty()) { + // Qt + knownNames.insert(QLatin1String("QScopedPointer")); + knownNames.insert(QLatin1String("QScopedArrayPointer")); + knownNames.insert(QLatin1String("QMutexLocker")); + knownNames.insert(QLatin1String("QReadLocker")); + knownNames.insert(QLatin1String("QWriteLocker")); + // Standard C++ + knownNames.insert(QLatin1String("auto_ptr")); + knownNames.insert(QLatin1String("unique_ptr")); + // Boost + knownNames.insert(QLatin1String("scoped_ptr")); + knownNames.insert(QLatin1String("scoped_array")); + } + + return knownNames.contains(name); +} + +static bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context) +{ + if (!symbol) + return false; + + // This is not a "real" comparison of types. What we do is to resolve the symbol + // in question and then try to match its name with already known ones. + if (symbol->asDeclaration()) { + Declaration *declaration = symbol->asDeclaration(); + const NamedType *namedType = declaration->type()->asNamedType(); + if (namedType) { + ClassOrNamespace *clazz = context.lookupType(namedType->name(), + declaration->enclosingScope()); + if (clazz && !clazz->symbols().isEmpty()) { + Overview overview; + Symbol *symbol = clazz->symbols().at(0); + return isOwnershipRAIIName(overview.prettyName(symbol->name())); + } + } + } + + return false; +} + CursorInfo::Range toRange(const SemanticInfo::Use &use) { return {use.line, use.column, use.length}; diff --git a/src/plugins/cppeditor/clangdiagnosticconfigsmodel.cpp b/src/plugins/cppeditor/clangdiagnosticconfigsmodel.cpp index af63853edc5..8ebc5ffdb8e 100644 --- a/src/plugins/cppeditor/clangdiagnosticconfigsmodel.cpp +++ b/src/plugins/cppeditor/clangdiagnosticconfigsmodel.cpp @@ -4,6 +4,7 @@ #include "clangdiagnosticconfigsmodel.h" #include "cppeditorconstants.h" +#include "cppeditortr.h" #include "cpptoolsreuse.h" #include @@ -88,6 +89,34 @@ QStringList ClangDiagnosticConfigsModel::globalDiagnosticOptions() }; } +void ClangDiagnosticConfigsModel::addBuiltinConfigs() +{ + ClangDiagnosticConfig config; + + // Questionable constructs + config = ClangDiagnosticConfig(); + config.setId(Constants::CPP_CLANG_DIAG_CONFIG_QUESTIONABLE); + config.setDisplayName(Tr::tr("Checks for questionable constructs")); + config.setIsReadOnly(true); + config.setClangOptions({ + "-Wall", + "-Wextra", + }); + config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks); + config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::UseCustomChecks); + appendOrUpdate(config); + + // Warning flags from build system + config = ClangDiagnosticConfig(); + config.setId(Constants::CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM); + config.setDisplayName(Tr::tr("Build-system warnings")); + config.setIsReadOnly(true); + config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks); + config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::UseCustomChecks); + config.setUseBuildSystemWarnings(true); + appendOrUpdate(config); +} + int ClangDiagnosticConfigsModel::indexOfConfig(const Utils::Id &id) const { return Utils::indexOf(m_diagnosticConfigs, [&](const ClangDiagnosticConfig &config) { diff --git a/src/plugins/cppeditor/clangdiagnosticconfigsmodel.h b/src/plugins/cppeditor/clangdiagnosticconfigsmodel.h index ba384630e76..ddac337f3f6 100644 --- a/src/plugins/cppeditor/clangdiagnosticconfigsmodel.h +++ b/src/plugins/cppeditor/clangdiagnosticconfigsmodel.h @@ -34,6 +34,8 @@ public: const QString &displayName); static QStringList globalDiagnosticOptions(); + void addBuiltinConfigs(); + private: ClangDiagnosticConfigs m_diagnosticConfigs; }; diff --git a/src/plugins/cppeditor/clangdsettings.cpp b/src/plugins/cppeditor/clangdsettings.cpp index 78cce6df1c0..036dbeb41c3 100644 --- a/src/plugins/cppeditor/clangdsettings.cpp +++ b/src/plugins/cppeditor/clangdsettings.cpp @@ -11,6 +11,7 @@ #include "cpptoolsreuse.h" #include +#include #include #include #include @@ -201,6 +202,16 @@ void ClangdSettings::setCustomDiagnosticConfigs(const ClangDiagnosticConfigs &co instance().saveSettings(); } +ClangDiagnosticConfigsModel ClangdSettings::diagnosticConfigsModel() +{ + const ClangDiagnosticConfigs &customConfigs = instance().customDiagnosticConfigs(); + ClangDiagnosticConfigsModel model; + model.addBuiltinConfigs(); + for (const ClangDiagnosticConfig &config : customConfigs) + model.appendOrUpdate(config); + return model; +} + FilePath ClangdSettings::clangdFilePath() const { if (!m_data.executableFilePath.isEmpty()) @@ -237,7 +248,7 @@ Id ClangdSettings::diagnosticConfigId() const ClangDiagnosticConfig ClangdSettings::diagnosticConfig() const { - return diagnosticConfigsModel(customDiagnosticConfigs()).configWithId(diagnosticConfigId()); + return diagnosticConfigsModel().configWithId(diagnosticConfigId()); } ClangdSettings::Granularity ClangdSettings::granularity() const @@ -761,7 +772,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD m_configSelectionWidget = new ClangDiagnosticConfigsSelectionWidget(formLayout); m_configSelectionWidget->refresh( - diagnosticConfigsModel(settings.customDiagnosticConfigs()), + ClangdSettings::diagnosticConfigsModel(), settings.diagnosticConfigId(), [](const ClangDiagnosticConfigs &configs, const Utils::Id &configToSelect) { return new CppEditor::ClangDiagnosticConfigsWidget(configs, configToSelect); diff --git a/src/plugins/cppeditor/clangdsettings.h b/src/plugins/cppeditor/clangdsettings.h index e4fb22f5527..c5bf7052cea 100644 --- a/src/plugins/cppeditor/clangdsettings.h +++ b/src/plugins/cppeditor/clangdsettings.h @@ -13,6 +13,7 @@ namespace ProjectExplorer { class Project; } namespace Utils { class MacroExpander; } namespace CppEditor { +class ClangDiagnosticConfigsModel; // TODO: Can we move this to ClangCodeModel? class CPPEDITOR_EXPORT ClangdSettings : public QObject @@ -96,6 +97,8 @@ public: static void setDefaultClangdPath(const Utils::FilePath &filePath); static void setCustomDiagnosticConfigs(const ClangDiagnosticConfigs &configs); + static ClangDiagnosticConfigsModel diagnosticConfigsModel(); + Utils::FilePath clangdFilePath() const; IndexingPriority indexingPriority() const { return m_data.indexingPriority; } Utils::FilePath projectIndexPath(const Utils::MacroExpander &expander) const; diff --git a/src/plugins/cppeditor/cppbuiltinmodelmanagersupport.cpp b/src/plugins/cppeditor/cppbuiltinmodelmanagersupport.cpp index 3a82a411326..8944a52e7da 100644 --- a/src/plugins/cppeditor/cppbuiltinmodelmanagersupport.cpp +++ b/src/plugins/cppeditor/cppbuiltinmodelmanagersupport.cpp @@ -29,6 +29,7 @@ using namespace Utils; namespace CppEditor::Internal { namespace { + class CppHoverHandler : public TextEditor::BaseHoverHandler { private: diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp index 56c62dfca07..007a2c84cf7 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp @@ -1913,7 +1913,7 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Const QString projectFilePath = QLatin1String(""); if (part->hasProject()) { projectFilePath = part->topLevelProject.toUserOutput(); - if (const ProjectExplorer::Project * const project = projectForProjectPart(*part)) + if (const ProjectExplorer::Project * const project = part->project()) projectName = project->displayName(); } const QString callGroupId = part->callGroupId.isEmpty() ? QString::fromLatin1("") diff --git a/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp b/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp index 4a9cff34542..a5bab99f121 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp @@ -505,7 +505,7 @@ void Dumper::dumpProjectInfos(const QList &projectInfos) QString projectFilePath = ""; if (part->hasProject()) { projectFilePath = part->topLevelProject.toUserOutput(); - if (const ProjectExplorer::Project * const project = projectForProjectPart(*part)) + if (const ProjectExplorer::Project * const project = part->project()) projectName = project->displayName(); } if (!part->projectConfigFile.isEmpty()) diff --git a/src/plugins/cppeditor/cppheadersource.cpp b/src/plugins/cppeditor/cppheadersource.cpp index 954158f5df9..0c586a4082e 100644 --- a/src/plugins/cppeditor/cppheadersource.cpp +++ b/src/plugins/cppeditor/cppheadersource.cpp @@ -250,7 +250,7 @@ FilePath correspondingHeaderOrSource(const FilePath &filePath, bool *wasHeader, } else { const QList projectInfos = CppModelManager::projectInfos(); for (const ProjectInfo::ConstPtr &projectInfo : projectInfos) { - const Project *project = projectForProjectInfo(*projectInfo); + const Project *project = projectInfo->project(); if (project == currentProject) continue; // We have already checked the current project. diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 952d74707a2..3b4345944e0 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -7,6 +7,7 @@ #include "cpptoolsreuse.h" #include +#include #include #include diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp index 6f2aebcca32..511094b48de 100644 --- a/src/plugins/cppeditor/cppmodelmanager.cpp +++ b/src/plugins/cppeditor/cppmodelmanager.cpp @@ -1573,7 +1573,7 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo::ConstPtr &ne QStringList removedProjectParts; bool filesRemoved = false; - Project * const project = projectForProjectInfo(*newProjectInfo); + Project * const project = newProjectInfo->project(); if (!project) return {}; diff --git a/src/plugins/cppeditor/cppparsecontext.h b/src/plugins/cppeditor/cppparsecontext.h index 6ced36f5346..9d65f6740ac 100644 --- a/src/plugins/cppeditor/cppparsecontext.h +++ b/src/plugins/cppeditor/cppparsecontext.h @@ -3,7 +3,7 @@ #pragma once -#include "cpptoolsreuse.h" +#include "projectpart.h" #include #include diff --git a/src/plugins/cppeditor/cpptoolsreuse.cpp b/src/plugins/cppeditor/cpptoolsreuse.cpp index 7be177c2c1b..109943123b1 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.cpp +++ b/src/plugins/cppeditor/cpptoolsreuse.cpp @@ -3,20 +3,16 @@ #include "cpptoolsreuse.h" -#include "clangdiagnosticconfigsmodel.h" #include "clangdsettings.h" #include "cppautocompleter.h" #include "cppcanonicalsymbol.h" #include "cppcodemodelsettings.h" #include "cppcompletionassist.h" -#include "cppeditorconstants.h" #include "cppeditorwidget.h" #include "cppeditortr.h" #include "cppfilesettingspage.h" #include "cpphighlighter.h" #include "cppqtstyleindenter.h" -#include "cpprefactoringchanges.h" -#include "projectinfo.h" #include "quickfixes/cppquickfixassistant.h" #include @@ -144,51 +140,6 @@ void moveCursorToStartOfIdentifier(QTextCursor *tc) skipCharsBackward(tc, isValidIdentifierChar); } -static bool isOwnershipRAIIName(const QString &name) -{ - static QSet knownNames; - if (knownNames.isEmpty()) { - // Qt - knownNames.insert(QLatin1String("QScopedPointer")); - knownNames.insert(QLatin1String("QScopedArrayPointer")); - knownNames.insert(QLatin1String("QMutexLocker")); - knownNames.insert(QLatin1String("QReadLocker")); - knownNames.insert(QLatin1String("QWriteLocker")); - // Standard C++ - knownNames.insert(QLatin1String("auto_ptr")); - knownNames.insert(QLatin1String("unique_ptr")); - // Boost - knownNames.insert(QLatin1String("scoped_ptr")); - knownNames.insert(QLatin1String("scoped_array")); - } - - return knownNames.contains(name); -} - -bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context) -{ - if (!symbol) - return false; - - // This is not a "real" comparison of types. What we do is to resolve the symbol - // in question and then try to match its name with already known ones. - if (symbol->asDeclaration()) { - Declaration *declaration = symbol->asDeclaration(); - const NamedType *namedType = declaration->type()->asNamedType(); - if (namedType) { - ClassOrNamespace *clazz = context.lookupType(namedType->name(), - declaration->enclosingScope()); - if (clazz && !clazz->symbols().isEmpty()) { - Overview overview; - Symbol *symbol = clazz->symbols().at(0); - return isOwnershipRAIIName(overview.prettyName(symbol->name())); - } - } - } - - return false; -} - bool isValidAsciiIdentifierChar(const QChar &ch) { return ch.isLetterOrNumber() || ch == QLatin1Char('_'); @@ -377,245 +328,6 @@ bool fileSizeExceedsLimit(const FilePath &filePath, int sizeLimitInMb) return false; } -static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model) -{ - ClangDiagnosticConfig config; - - // Questionable constructs - config = ClangDiagnosticConfig(); - config.setId(Constants::CPP_CLANG_DIAG_CONFIG_QUESTIONABLE); - config.setDisplayName(Tr::tr("Checks for questionable constructs")); - config.setIsReadOnly(true); - config.setClangOptions({ - "-Wall", - "-Wextra", - }); - config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks); - config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::UseCustomChecks); - model.appendOrUpdate(config); - - // Warning flags from build system - config = ClangDiagnosticConfig(); - config.setId(Constants::CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM); - config.setDisplayName(Tr::tr("Build-system warnings")); - config.setIsReadOnly(true); - config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks); - config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::UseCustomChecks); - config.setUseBuildSystemWarnings(true); - model.appendOrUpdate(config); -} - -ClangDiagnosticConfigsModel diagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs) -{ - ClangDiagnosticConfigsModel model; - addBuiltinConfigs(model); - for (const ClangDiagnosticConfig &config : customConfigs) - model.appendOrUpdate(config); - return model; -} - -ClangDiagnosticConfigsModel diagnosticConfigsModel() -{ - return diagnosticConfigsModel(ClangdSettings::instance().customDiagnosticConfigs()); -} - -NSVisitor::NSVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos) - : ASTVisitor(file->cppDocument()->translationUnit()), - m_file(file), - m_remainingNamespaces(namespaces), - m_symbolPos(symbolPos) -{} - -bool NSVisitor::preVisit(AST *ast) -{ - if (!m_firstToken) - m_firstToken = ast; - if (m_file->startOf(ast) >= m_symbolPos) - m_done = true; - return !m_done; -} - -bool NSVisitor::visit(NamespaceAST *ns) -{ - if (!m_firstNamespace) - m_firstNamespace = ns; - if (m_remainingNamespaces.isEmpty()) { - m_done = true; - return false; - } - - QString name; - const Identifier * const id = translationUnit()->identifier(ns->identifier_token); - if (id) - name = QString::fromUtf8(id->chars(), id->size()); - if (name != m_remainingNamespaces.first()) - return false; - - if (!ns->linkage_body) { - m_done = true; - return false; - } - - m_enclosingNamespace = ns; - m_remainingNamespaces.removeFirst(); - return !m_remainingNamespaces.isEmpty(); -} - -void NSVisitor::postVisit(AST *ast) -{ - if (ast == m_enclosingNamespace) - m_done = true; -} - -/** - * @brief The NSCheckerVisitor class checks which namespaces are missing for a given list - * of enclosing namespaces at a given position - */ -NSCheckerVisitor::NSCheckerVisitor(const CppRefactoringFile *file, const QStringList &namespaces, - int symbolPos) - : ASTVisitor(file->cppDocument()->translationUnit()) - , m_file(file) - , m_remainingNamespaces(namespaces) - , m_symbolPos(symbolPos) -{} - -bool NSCheckerVisitor::preVisit(AST *ast) -{ - if (m_file->startOf(ast) >= m_symbolPos) - m_done = true; - return !m_done; -} - -void NSCheckerVisitor::postVisit(AST *ast) -{ - if (!m_done && m_file->endOf(ast) > m_symbolPos) - m_done = true; -} - -bool NSCheckerVisitor::visit(NamespaceAST *ns) -{ - if (m_remainingNamespaces.isEmpty()) - return false; - - QString name = getName(ns); - if (name != m_remainingNamespaces.first()) - return false; - - m_enteredNamespaces.push_back(ns); - m_remainingNamespaces.removeFirst(); - // if we reached the searched namespace we don't have to search deeper - return !m_remainingNamespaces.isEmpty(); -} - -bool NSCheckerVisitor::visit(UsingDirectiveAST *usingNS) -{ - // example: we search foo::bar and get 'using namespace foo;using namespace foo::bar;' - const QString fullName = Overview{}.prettyName(usingNS->name->name); - const QStringList namespaces = fullName.split("::"); - if (namespaces.length() > m_remainingNamespaces.length()) - return false; - - // from other using namespace statements - const auto curList = m_usingsPerNamespace.find(currentNamespace()); - const bool isCurListValid = curList != m_usingsPerNamespace.end(); - - const bool startEqual = std::equal(namespaces.cbegin(), - namespaces.cend(), - m_remainingNamespaces.cbegin()); - if (startEqual) { - if (isCurListValid) { - if (namespaces.length() > curList->second.length()) { - // eg. we already have 'using namespace foo;' and - // now get 'using namespace foo::bar;' - curList->second = namespaces; - } - // the other case: first 'using namespace foo::bar;' and now 'using namespace foo;' - } else - m_usingsPerNamespace.emplace(currentNamespace(), namespaces); - } else if (isCurListValid) { - // ex: we have already 'using namespace foo;' and get 'using namespace bar;' now - QStringList newlist = curList->second; - newlist.append(namespaces); - if (newlist.length() <= m_remainingNamespaces.length()) { - const bool startEqual = std::equal(newlist.cbegin(), - newlist.cend(), - m_remainingNamespaces.cbegin()); - if (startEqual) - curList->second.append(namespaces); - } - } - return false; -} - -void NSCheckerVisitor::endVisit(NamespaceAST *ns) -{ - // if the symbolPos was in the namespace and the - // namespace has no children, m_done should be true - postVisit(ns); - if (!m_done && currentNamespace() == ns) { - // we were not succesfull in this namespace, so undo all changes - m_remainingNamespaces.push_front(getName(currentNamespace())); - m_usingsPerNamespace.erase(currentNamespace()); - m_enteredNamespaces.pop_back(); - } -} - -void NSCheckerVisitor::endVisit(TranslationUnitAST *) -{ - // the last node, create the final result - // we must handle like the following: We search for foo::bar and have: - // using namespace foo::bar; - // namespace foo { - // // cursor/symbolPos here - // } - if (m_remainingNamespaces.empty()) { - // we are already finished - return; - } - // find the longest combination of normal namespaces + using statements - int longestNamespaceList = 0; - int enteredNamespaceCount = 0; - // check 'using namespace ...;' statements in the global scope - const auto namespaces = m_usingsPerNamespace.find(nullptr); - if (namespaces != m_usingsPerNamespace.end()) - longestNamespaceList = namespaces->second.length(); - - for (auto ns : m_enteredNamespaces) { - ++enteredNamespaceCount; - const auto namespaces = m_usingsPerNamespace.find(ns); - int newListLength = enteredNamespaceCount; - if (namespaces != m_usingsPerNamespace.end()) - newListLength += namespaces->second.length(); - longestNamespaceList = std::max(newListLength, longestNamespaceList); - } - m_remainingNamespaces.erase(m_remainingNamespaces.begin(), - m_remainingNamespaces.begin() + longestNamespaceList - - m_enteredNamespaces.size()); -} - -QString NSCheckerVisitor::getName(NamespaceAST *ns) -{ - const Identifier *const id = translationUnit()->identifier(ns->identifier_token); - if (id) - return QString::fromUtf8(id->chars(), id->size()); - return {}; -} - -NamespaceAST *NSCheckerVisitor::currentNamespace() -{ - return m_enteredNamespaces.empty() ? nullptr : m_enteredNamespaces.back(); -} - -ProjectExplorer::Project *projectForProjectPart(const ProjectPart &part) -{ - return ProjectExplorer::ProjectManager::projectWithProjectFilePath(part.topLevelProject); -} - -ProjectExplorer::Project *projectForProjectInfo(const ProjectInfo &info) -{ - return ProjectExplorer::ProjectManager::projectWithProjectFilePath(info.projectFilePath()); -} - void openEditor(const Utils::FilePath &filePath, bool inNextSplit, Utils::Id editorId) { using Core::EditorManager; diff --git a/src/plugins/cppeditor/cpptoolsreuse.h b/src/plugins/cppeditor/cpptoolsreuse.h index 71aabab08df..70349cacc37 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.h +++ b/src/plugins/cppeditor/cpptoolsreuse.h @@ -5,25 +5,21 @@ #include "cppeditor_global.h" -#include "clangdiagnosticconfig.h" -#include "projectpart.h" - -#include -#include - -#include - -#include #include -#include +#include +#include +#include namespace CPlusPlus { class Macro; class Symbol; class LookupContext; } // namespace CPlusPlus - -namespace TextEditor { class AssistInterface; } +namespace ProjectExplorer { class Project; } +namespace TextEditor { +class AssistInterface; +class TextEditorWidget; +} namespace Utils { namespace Text { class Range; } } namespace CppEditor { @@ -49,9 +45,6 @@ int CPPEDITOR_EXPORT activeArgumenForPrefix(const QString &prefix); QStringList CPPEDITOR_EXPORT identifierWordsUnderCursor(const QTextCursor &tc); QString CPPEDITOR_EXPORT identifierUnderCursor(QTextCursor *cursor); -bool CPPEDITOR_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol, - const CPlusPlus::LookupContext &context); - const CPlusPlus::Macro CPPEDITOR_EXPORT *findCanonicalMacro(const QTextCursor &cursor, CPlusPlus::Document::Ptr document); @@ -89,114 +82,6 @@ QList CPPEDITOR_EXPORT symbolOccurrencesInDeclarationComment bool fileSizeExceedsLimit(const Utils::FilePath &filePath, int sizeLimitInMb); -ProjectExplorer::Project CPPEDITOR_EXPORT *projectForProjectInfo(const ProjectInfo &info); -ProjectExplorer::Project CPPEDITOR_EXPORT *projectForProjectPart(const ProjectPart &part); - -class ClangDiagnosticConfigsModel; -ClangDiagnosticConfigsModel CPPEDITOR_EXPORT diagnosticConfigsModel(); -ClangDiagnosticConfigsModel CPPEDITOR_EXPORT -diagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs); - -class CPPEDITOR_EXPORT SymbolInfo -{ -public: - int startLine = 0; - int startColumn = 0; - int endLine = 0; - int endColumn = 0; - QString fileName; - bool isResultOnlyForFallBack = false; -}; - -class ProjectPartInfo { -public: - enum Hint { - NoHint = 0, - IsFallbackMatch = 1 << 0, - IsAmbiguousMatch = 1 << 1, - IsPreferredMatch = 1 << 2, - IsFromProjectMatch = 1 << 3, - IsFromDependenciesMatch = 1 << 4, - }; - Q_DECLARE_FLAGS(Hints, Hint) - - ProjectPartInfo() = default; - ProjectPartInfo(const ProjectPart::ConstPtr &projectPart, - const QList &projectParts, - Hints hints) - : projectPart(projectPart) - , projectParts(projectParts) - , hints(hints) - { - } - -public: - ProjectPart::ConstPtr projectPart; - QList projectParts; // The one above as first plus alternatives. - Hints hints = NoHint; -}; - -QStringList CPPEDITOR_EXPORT getNamespaceNames(const CPlusPlus::Namespace *firstNamespace); -QStringList CPPEDITOR_EXPORT getNamespaceNames(const CPlusPlus::Symbol *symbol); - -class CPPEDITOR_EXPORT NSVisitor : public CPlusPlus::ASTVisitor -{ -public: - NSVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos); - - const QStringList remainingNamespaces() const { return m_remainingNamespaces; } - const CPlusPlus::NamespaceAST *firstNamespace() const { return m_firstNamespace; } - const CPlusPlus::AST *firstToken() const { return m_firstToken; } - const CPlusPlus::NamespaceAST *enclosingNamespace() const { return m_enclosingNamespace; } - -private: - bool preVisit(CPlusPlus::AST *ast) override; - bool visit(CPlusPlus::NamespaceAST *ns) override; - void postVisit(CPlusPlus::AST *ast) override; - - const CppRefactoringFile * const m_file; - const CPlusPlus::NamespaceAST *m_enclosingNamespace = nullptr; - const CPlusPlus::NamespaceAST *m_firstNamespace = nullptr; - const CPlusPlus::AST *m_firstToken = nullptr; - QStringList m_remainingNamespaces; - const int m_symbolPos; - bool m_done = false; -}; - -class CPPEDITOR_EXPORT NSCheckerVisitor : public CPlusPlus::ASTVisitor -{ -public: - NSCheckerVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos); - - /** - * @brief returns the names of the namespaces that are additionally needed at the symbolPos - * @return A list of namespace names, the outermost namespace at index 0 and the innermost - * at the last index - */ - const QStringList remainingNamespaces() const { return m_remainingNamespaces; } - -private: - bool preVisit(CPlusPlus::AST *ast) override; - void postVisit(CPlusPlus::AST *ast) override; - bool visit(CPlusPlus::NamespaceAST *ns) override; - bool visit(CPlusPlus::UsingDirectiveAST *usingNS) override; - void endVisit(CPlusPlus::NamespaceAST *ns) override; - void endVisit(CPlusPlus::TranslationUnitAST *) override; - - QString getName(CPlusPlus::NamespaceAST *ns); - CPlusPlus::NamespaceAST *currentNamespace(); - - const CppRefactoringFile *const m_file; - QStringList m_remainingNamespaces; - const int m_symbolPos; - std::vector m_enteredNamespaces; - - // track 'using namespace ...' statements - std::unordered_map m_usingsPerNamespace; - - bool m_done = false; -}; - namespace Internal { void decorateCppEditor(TextEditor::TextEditorWidget *editor); } // namespace Internal diff --git a/src/plugins/cppeditor/insertionpointlocator.cpp b/src/plugins/cppeditor/insertionpointlocator.cpp index 8b2b03698e2..d791ffc2203 100644 --- a/src/plugins/cppeditor/insertionpointlocator.cpp +++ b/src/plugins/cppeditor/insertionpointlocator.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include @@ -18,6 +20,7 @@ using namespace CPlusPlus; using namespace Utils; namespace CppEditor { +using namespace Internal; namespace { static int ordering(InsertionPointLocator::AccessSpec xsSpec) @@ -719,39 +722,6 @@ static QStringList getListOfMissingNamespacesForLocation(const CppRefactoringFil return visitor.remainingNamespaces(); } -/** - * @brief getNamespaceNames Returns a list of namespaces for an enclosing namespaces of a - * namespace (contains the namespace itself) - * @param firstNamespace the starting namespace (included in the list) - * @return the enclosing namespaces, the outermost namespace is at the first index, the innermost - * at the last index - */ -QStringList getNamespaceNames(const Namespace *firstNamespace) -{ - QStringList namespaces; - for (const Namespace *scope = firstNamespace; scope; scope = scope->enclosingNamespace()) { - if (scope->name() && scope->name()->identifier()) { - namespaces.prepend(QString::fromUtf8(scope->name()->identifier()->chars(), - scope->name()->identifier()->size())); - } else { - namespaces.prepend(""); // an unnamed namespace - } - } - namespaces.pop_front(); // the "global namespace" is one namespace, but not an unnamed - return namespaces; -} - -/** - * @brief getNamespaceNames Returns a list of enclosing namespaces for a symbol - * @param symbol a symbol from which we want the enclosing namespaces - * @return the enclosing namespaces, the outermost namespace is at the first index, the innermost - * at the last index - */ -QStringList getNamespaceNames(const Symbol *symbol) -{ - return getNamespaceNames(symbol->enclosingNamespace()); -} - InsertionLocation insertLocationForMethodDefinition(Symbol *symbol, const bool useSymbolFinder, NamespaceHandling namespaceHandling, @@ -834,4 +804,226 @@ InsertionLocation insertLocationForMethodDefinition(Symbol *symbol, return InsertionLocation(filePath, prefix, suffix, line, column); } +namespace Internal { +NSVisitor::NSVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos) + : ASTVisitor(file->cppDocument()->translationUnit()), + m_file(file), + m_remainingNamespaces(namespaces), + m_symbolPos(symbolPos) +{} + +bool NSVisitor::preVisit(AST *ast) +{ + if (!m_firstToken) + m_firstToken = ast; + if (m_file->startOf(ast) >= m_symbolPos) + m_done = true; + return !m_done; +} + +bool NSVisitor::visit(NamespaceAST *ns) +{ + if (!m_firstNamespace) + m_firstNamespace = ns; + if (m_remainingNamespaces.isEmpty()) { + m_done = true; + return false; + } + + QString name; + const Identifier * const id = translationUnit()->identifier(ns->identifier_token); + if (id) + name = QString::fromUtf8(id->chars(), id->size()); + if (name != m_remainingNamespaces.first()) + return false; + + if (!ns->linkage_body) { + m_done = true; + return false; + } + + m_enclosingNamespace = ns; + m_remainingNamespaces.removeFirst(); + return !m_remainingNamespaces.isEmpty(); +} + +void NSVisitor::postVisit(AST *ast) +{ + if (ast == m_enclosingNamespace) + m_done = true; +} + +/** + * @brief The NSCheckerVisitor class checks which namespaces are missing for a given list + * of enclosing namespaces at a given position + */ +NSCheckerVisitor::NSCheckerVisitor(const CppRefactoringFile *file, const QStringList &namespaces, + int symbolPos) + : ASTVisitor(file->cppDocument()->translationUnit()) + , m_file(file) + , m_remainingNamespaces(namespaces) + , m_symbolPos(symbolPos) +{} + +bool NSCheckerVisitor::preVisit(AST *ast) +{ + if (m_file->startOf(ast) >= m_symbolPos) + m_done = true; + return !m_done; +} + +void NSCheckerVisitor::postVisit(AST *ast) +{ + if (!m_done && m_file->endOf(ast) > m_symbolPos) + m_done = true; +} + +bool NSCheckerVisitor::visit(NamespaceAST *ns) +{ + if (m_remainingNamespaces.isEmpty()) + return false; + + QString name = getName(ns); + if (name != m_remainingNamespaces.first()) + return false; + + m_enteredNamespaces.push_back(ns); + m_remainingNamespaces.removeFirst(); + // if we reached the searched namespace we don't have to search deeper + return !m_remainingNamespaces.isEmpty(); +} + +bool NSCheckerVisitor::visit(UsingDirectiveAST *usingNS) +{ + // example: we search foo::bar and get 'using namespace foo;using namespace foo::bar;' + const QString fullName = Overview{}.prettyName(usingNS->name->name); + const QStringList namespaces = fullName.split("::"); + if (namespaces.length() > m_remainingNamespaces.length()) + return false; + + // from other using namespace statements + const auto curList = m_usingsPerNamespace.find(currentNamespace()); + const bool isCurListValid = curList != m_usingsPerNamespace.end(); + + const bool startEqual = std::equal(namespaces.cbegin(), + namespaces.cend(), + m_remainingNamespaces.cbegin()); + if (startEqual) { + if (isCurListValid) { + if (namespaces.length() > curList->second.length()) { + // eg. we already have 'using namespace foo;' and + // now get 'using namespace foo::bar;' + curList->second = namespaces; + } + // the other case: first 'using namespace foo::bar;' and now 'using namespace foo;' + } else + m_usingsPerNamespace.emplace(currentNamespace(), namespaces); + } else if (isCurListValid) { + // ex: we have already 'using namespace foo;' and get 'using namespace bar;' now + QStringList newlist = curList->second; + newlist.append(namespaces); + if (newlist.length() <= m_remainingNamespaces.length()) { + const bool startEqual = std::equal(newlist.cbegin(), + newlist.cend(), + m_remainingNamespaces.cbegin()); + if (startEqual) + curList->second.append(namespaces); + } + } + return false; +} + +void NSCheckerVisitor::endVisit(NamespaceAST *ns) +{ + // if the symbolPos was in the namespace and the + // namespace has no children, m_done should be true + postVisit(ns); + if (!m_done && currentNamespace() == ns) { + // we were not succesfull in this namespace, so undo all changes + m_remainingNamespaces.push_front(getName(currentNamespace())); + m_usingsPerNamespace.erase(currentNamespace()); + m_enteredNamespaces.pop_back(); + } +} + +void NSCheckerVisitor::endVisit(TranslationUnitAST *) +{ + // the last node, create the final result + // we must handle like the following: We search for foo::bar and have: + // using namespace foo::bar; + // namespace foo { + // // cursor/symbolPos here + // } + if (m_remainingNamespaces.empty()) { + // we are already finished + return; + } + // find the longest combination of normal namespaces + using statements + int longestNamespaceList = 0; + int enteredNamespaceCount = 0; + // check 'using namespace ...;' statements in the global scope + const auto namespaces = m_usingsPerNamespace.find(nullptr); + if (namespaces != m_usingsPerNamespace.end()) + longestNamespaceList = namespaces->second.length(); + + for (auto ns : m_enteredNamespaces) { + ++enteredNamespaceCount; + const auto namespaces = m_usingsPerNamespace.find(ns); + int newListLength = enteredNamespaceCount; + if (namespaces != m_usingsPerNamespace.end()) + newListLength += namespaces->second.length(); + longestNamespaceList = std::max(newListLength, longestNamespaceList); + } + m_remainingNamespaces.erase(m_remainingNamespaces.begin(), + m_remainingNamespaces.begin() + longestNamespaceList + - m_enteredNamespaces.size()); +} + +QString NSCheckerVisitor::getName(NamespaceAST *ns) +{ + const Identifier *const id = translationUnit()->identifier(ns->identifier_token); + if (id) + return QString::fromUtf8(id->chars(), id->size()); + return {}; +} + +NamespaceAST *NSCheckerVisitor::currentNamespace() +{ + return m_enteredNamespaces.empty() ? nullptr : m_enteredNamespaces.back(); +} + +/** + * @brief getNamespaceNames Returns a list of namespaces for an enclosing namespaces of a + * namespace (contains the namespace itself) + * @param firstNamespace the starting namespace (included in the list) + * @return the enclosing namespaces, the outermost namespace is at the first index, the innermost + * at the last index + */ +QStringList getNamespaceNames(const Namespace *firstNamespace) +{ + QStringList namespaces; + for (const Namespace *scope = firstNamespace; scope; scope = scope->enclosingNamespace()) { + if (scope->name() && scope->name()->identifier()) { + namespaces.prepend(QString::fromUtf8(scope->name()->identifier()->chars(), + scope->name()->identifier()->size())); + } else { + namespaces.prepend(""); // an unnamed namespace + } + } + namespaces.pop_front(); // the "global namespace" is one namespace, but not an unnamed + return namespaces; +} + +/** + * @brief getNamespaceNames Returns a list of enclosing namespaces for a symbol + * @param symbol a symbol from which we want the enclosing namespaces + * @return the enclosing namespaces, the outermost namespace is at the first index, the innermost + * at the last index + */ +QStringList getNamespaceNames(const Symbol *symbol) +{ + return getNamespaceNames(symbol->enclosingNamespace()); +} + +} // namespace Internal } // namespace CppEditor; diff --git a/src/plugins/cppeditor/insertionpointlocator.h b/src/plugins/cppeditor/insertionpointlocator.h index d6fd5d735cc..833adbd8ac9 100644 --- a/src/plugins/cppeditor/insertionpointlocator.h +++ b/src/plugins/cppeditor/insertionpointlocator.h @@ -113,4 +113,67 @@ insertLocationForMethodDefinition(CPlusPlus::Symbol *symbol, const Utils::FilePath &fileName, QStringList *insertedNamespaces = nullptr); +namespace Internal { +class NSVisitor : public CPlusPlus::ASTVisitor +{ +public: + NSVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos); + + const QStringList remainingNamespaces() const { return m_remainingNamespaces; } + const CPlusPlus::NamespaceAST *firstNamespace() const { return m_firstNamespace; } + const CPlusPlus::AST *firstToken() const { return m_firstToken; } + const CPlusPlus::NamespaceAST *enclosingNamespace() const { return m_enclosingNamespace; } + +private: + bool preVisit(CPlusPlus::AST *ast) override; + bool visit(CPlusPlus::NamespaceAST *ns) override; + void postVisit(CPlusPlus::AST *ast) override; + + const CppRefactoringFile * const m_file; + const CPlusPlus::NamespaceAST *m_enclosingNamespace = nullptr; + const CPlusPlus::NamespaceAST *m_firstNamespace = nullptr; + const CPlusPlus::AST *m_firstToken = nullptr; + QStringList m_remainingNamespaces; + const int m_symbolPos; + bool m_done = false; +}; + +class NSCheckerVisitor : public CPlusPlus::ASTVisitor +{ +public: + NSCheckerVisitor(const CppRefactoringFile *file, const QStringList &namespaces, int symbolPos); + + /** + * @brief returns the names of the namespaces that are additionally needed at the symbolPos + * @return A list of namespace names, the outermost namespace at index 0 and the innermost + * at the last index + */ + const QStringList remainingNamespaces() const { return m_remainingNamespaces; } + +private: + bool preVisit(CPlusPlus::AST *ast) override; + void postVisit(CPlusPlus::AST *ast) override; + bool visit(CPlusPlus::NamespaceAST *ns) override; + bool visit(CPlusPlus::UsingDirectiveAST *usingNS) override; + void endVisit(CPlusPlus::NamespaceAST *ns) override; + void endVisit(CPlusPlus::TranslationUnitAST *) override; + + QString getName(CPlusPlus::NamespaceAST *ns); + CPlusPlus::NamespaceAST *currentNamespace(); + + const CppRefactoringFile *const m_file; + QStringList m_remainingNamespaces; + const int m_symbolPos; + std::vector m_enteredNamespaces; + + // track 'using namespace ...' statements + std::unordered_map m_usingsPerNamespace; + + bool m_done = false; +}; + +QStringList getNamespaceNames(const CPlusPlus::Namespace *firstNamespace); +QStringList getNamespaceNames(const CPlusPlus::Symbol *symbol); + +} // namespace Internal } // namespace CppEditor diff --git a/src/plugins/cppeditor/projectinfo.cpp b/src/plugins/cppeditor/projectinfo.cpp index 9561310f323..e25070044bd 100644 --- a/src/plugins/cppeditor/projectinfo.cpp +++ b/src/plugins/cppeditor/projectinfo.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,11 @@ ProjectInfo::ConstPtr ProjectInfo::cloneWithNewSettings(const ConstPtr &pi, return ConstPtr(new ProjectInfo(pi, settings)); } +ProjectExplorer::Project *ProjectInfo::project() const +{ + return ProjectExplorer::ProjectManager::projectWithProjectFilePath(projectFilePath()); +} + bool ProjectInfo::operator ==(const ProjectInfo &other) const { return m_projectName == other.m_projectName diff --git a/src/plugins/cppeditor/projectinfo.h b/src/plugins/cppeditor/projectinfo.h index 3b18c7ae6fd..43afd6cbefd 100644 --- a/src/plugins/cppeditor/projectinfo.h +++ b/src/plugins/cppeditor/projectinfo.h @@ -36,6 +36,7 @@ public: const QSet &sourceFiles() const { return m_sourceFiles; } QString projectName() const { return m_projectName; } Utils::FilePath projectFilePath() const { return m_projectFilePath; } + ProjectExplorer::Project *project() const; Utils::FilePath projectRoot() const { return m_projectFilePath.parentDir(); } Utils::FilePath buildRoot() const { return m_buildRoot; } const CppCodeModelSettings &settings() const { return m_settings; } diff --git a/src/plugins/cppeditor/projectpart.cpp b/src/plugins/cppeditor/projectpart.cpp index 24f9dc42e85..8e4bd1c4fe5 100644 --- a/src/plugins/cppeditor/projectpart.cpp +++ b/src/plugins/cppeditor/projectpart.cpp @@ -4,6 +4,7 @@ #include "projectpart.h" #include +#include #include @@ -44,6 +45,11 @@ bool ProjectPart::belongsToProject(const Utils::FilePath &project) const return topLevelProject == project; } +Project *ProjectPart::project() const +{ + return ProjectManager::projectWithProjectFilePath(topLevelProject); +} + QByteArray ProjectPart::readProjectConfigFile(const QString &projectConfigFile) { QByteArray result; diff --git a/src/plugins/cppeditor/projectpart.h b/src/plugins/cppeditor/projectpart.h index a55adb2a0c3..d3a96ab60c6 100644 --- a/src/plugins/cppeditor/projectpart.h +++ b/src/plugins/cppeditor/projectpart.h @@ -30,7 +30,6 @@ class CPPEDITOR_EXPORT ProjectPart public: using ConstPtr = QSharedPointer; -public: static ConstPtr create(const Utils::FilePath &topLevelProject, const ProjectExplorer::RawProjectPart &rpp = {}, const QString &displayName = {}, @@ -49,10 +48,10 @@ public: bool hasProject() const { return !topLevelProject.isEmpty(); } bool belongsToProject(const ProjectExplorer::Project *project) const; bool belongsToProject(const Utils::FilePath &project) const; + ProjectExplorer::Project *project() const; static QByteArray readProjectConfigFile(const QString &projectConfigFile); -public: const Utils::FilePath topLevelProject; const QString displayName; const QString projectFile; @@ -117,4 +116,31 @@ public: const CPlusPlus::LanguageFeatures languageFeatures; }; +class ProjectPartInfo { +public: + enum Hint { + NoHint = 0, + IsFallbackMatch = 1 << 0, + IsAmbiguousMatch = 1 << 1, + IsPreferredMatch = 1 << 2, + IsFromProjectMatch = 1 << 3, + IsFromDependenciesMatch = 1 << 4, + }; + Q_DECLARE_FLAGS(Hints, Hint) + + ProjectPartInfo() = default; + ProjectPartInfo(const ProjectPart::ConstPtr &projectPart, + const QList &projectParts, + Hints hints) + : projectPart(projectPart) + , projectParts(projectParts) + , hints(hints) + { + } + + ProjectPart::ConstPtr projectPart; + QList projectParts; // The one above as first plus alternatives. + Hints hints = NoHint; +}; + } // namespace CppEditor diff --git a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp index 6a85c95dfc9..157f48894d1 100644 --- a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp +++ b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp @@ -8,6 +8,7 @@ #include "../cppprojectfile.h" #include "../cpprefactoringchanges.h" #include "../indexitem.h" +#include "../insertionpointlocator.h" #include "cppquickfix.h" #include "cppquickfixhelpers.h" diff --git a/src/plugins/modeleditor/elementtasks.cpp b/src/plugins/modeleditor/elementtasks.cpp index 7bbdd7b3e0b..039964ccb83 100644 --- a/src/plugins/modeleditor/elementtasks.cpp +++ b/src/plugins/modeleditor/elementtasks.cpp @@ -27,12 +27,13 @@ #include "qmt/project_controller/projectcontroller.h" #include "qmt/project/project.h" -#include +#include +#include +#include #include #include #include -#include -#include +#include #include #include