diff --git a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp index 6cc0632234b..194e6466464 100644 --- a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp +++ b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp @@ -21,6 +21,7 @@ #include #include +using namespace Core; using namespace LanguageClient; using namespace LanguageServerProtocol; using namespace Utils; @@ -148,11 +149,11 @@ void ClangGlobalSymbolFilter::prepareSearch(const QString &entry) m_lspFilter->prepareSearch(entry, clients); } -QList ClangGlobalSymbolFilter::matchesFor( - QFutureInterface &future, const QString &entry) +QList ClangGlobalSymbolFilter::matchesFor( + QFutureInterface &future, const QString &entry) { - QList matches = m_cppFilter->matchesFor(future, entry); - const QList lspMatches = m_lspFilter->matchesFor(future, entry); + QList matches = m_cppFilter->matchesFor(future, entry); + const QList lspMatches = m_lspFilter->matchesFor(future, entry); if (!lspMatches.isEmpty()) { std::set> locations; for (const auto &entry : std::as_const(matches)) { @@ -174,7 +175,7 @@ QList ClangGlobalSymbolFilter::matchesFor( return matches; } -void ClangGlobalSymbolFilter::accept(const Core::LocatorFilterEntry &selection, QString *newText, +void ClangGlobalSymbolFilter::accept(const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const { if (qvariant_cast(selection.internalData)) @@ -221,10 +222,10 @@ private: m_content = TextEditor::TextDocument::currentTextDocument()->plainText(); } - Core::LocatorFilterEntry generateLocatorEntry(const DocumentSymbol &info, - const Core::LocatorFilterEntry &parent) override + LocatorFilterEntry generateLocatorEntry(const DocumentSymbol &info, + const LocatorFilterEntry &parent) override { - Core::LocatorFilterEntry entry; + LocatorFilterEntry entry; entry.filter = this; entry.displayName = ClangdClient::displayNameFromDocumentSymbol( static_cast(info.kind()), info.name(), @@ -242,22 +243,22 @@ private: } // Filter out declarations for which a definition is also present. - QList matchesFor(QFutureInterface &future, - const QString &entry) override + QList matchesFor(QFutureInterface &future, + const QString &entry) override { - QList allMatches + QList allMatches = DocumentLocatorFilter::matchesFor(future, entry); - QHash> possibleDuplicates; - for (const Core::LocatorFilterEntry &e : std::as_const(allMatches)) + QHash> possibleDuplicates; + for (const LocatorFilterEntry &e : std::as_const(allMatches)) possibleDuplicates[e.displayName + e.extraInfo] << e; const QTextDocument doc(m_content); for (auto it = possibleDuplicates.cbegin(); it != possibleDuplicates.cend(); ++it) { - const QList &duplicates = it.value(); + const QList &duplicates = it.value(); if (duplicates.size() == 1) continue; - QList declarations; - QList definitions; - for (const Core::LocatorFilterEntry &candidate : duplicates) { + QList declarations; + QList definitions; + for (const LocatorFilterEntry &candidate : duplicates) { const auto symbol = qvariant_cast(candidate.internalData); const SymbolKind kind = static_cast(symbol.kind()); if (kind != SymbolKind::Class && kind != SymbolKind::Function) @@ -283,15 +284,15 @@ private: } if (definitions.size() == 1 && declarations.size() + definitions.size() == duplicates.size()) { - for (const Core::LocatorFilterEntry &decl : std::as_const(declarations)) - Utils::erase(allMatches, [&decl](const Core::LocatorFilterEntry &e) { + for (const LocatorFilterEntry &decl : std::as_const(declarations)) + Utils::erase(allMatches, [&decl](const LocatorFilterEntry &e) { return e.internalData == decl.internalData; }); } } // The base implementation expects the position in the internal data. - for (Core::LocatorFilterEntry &e : allMatches) { + for (LocatorFilterEntry &e : allMatches) { const Position pos = qvariant_cast(e.internalData).range().start(); e.internalData = QVariant::fromValue(Utils::LineColumn(pos.line(), pos.character())); } @@ -307,10 +308,10 @@ class ClangdCurrentDocumentFilter::Private public: ~Private() { delete cppFilter; } - Core::ILocatorFilter * const cppFilter + ILocatorFilter * const cppFilter = CppEditor::CppModelManager::createAuxiliaryCurrentDocumentFilter(); LspCurrentDocumentFilter lspFilter; - Core::ILocatorFilter *activeFilter = nullptr; + ILocatorFilter *activeFilter = nullptr; }; @@ -322,8 +323,8 @@ ClangdCurrentDocumentFilter::ClangdCurrentDocumentFilter() : d(new Private) setPriority(High); setDefaultIncludedByDefault(false); setEnabled(false); - connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, - this, [this](const Core::IEditor *editor) { setEnabled(editor); }); + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, + this, [this](const IEditor *editor) { setEnabled(editor); }); } ClangdCurrentDocumentFilter::~ClangdCurrentDocumentFilter() { delete d; } @@ -346,14 +347,14 @@ void ClangdCurrentDocumentFilter::prepareSearch(const QString &entry) d->activeFilter->prepareSearch(entry); } -QList ClangdCurrentDocumentFilter::matchesFor( - QFutureInterface &future, const QString &entry) +QList ClangdCurrentDocumentFilter::matchesFor( + QFutureInterface &future, const QString &entry) { QTC_ASSERT(d->activeFilter, return {}); return d->activeFilter->matchesFor(future, entry); } -void ClangdCurrentDocumentFilter::accept(const Core::LocatorFilterEntry &selection, QString *newText, +void ClangdCurrentDocumentFilter::accept(const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const { QTC_ASSERT(d->activeFilter, return); diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index ab646d1fa69..225217490cb 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -17,6 +17,7 @@ #include +using namespace Core; using namespace ProjectExplorer; using namespace Utils; @@ -64,7 +65,7 @@ void CMakeTargetLocatorFilter::prepareSearch(const QString &entry) extraData.insert("line", line); extraData.insert("file", path.toString()); - Core::LocatorFilterEntry filterEntry(this, target.title, extraData); + LocatorFilterEntry filterEntry(this, target.title, extraData); filterEntry.extraInfo = path.shortNativePath(); filterEntry.highlightInfo = {index, int(entry.length())}; filterEntry.filePath = path; @@ -75,7 +76,8 @@ void CMakeTargetLocatorFilter::prepareSearch(const QString &entry) } } -QList CMakeTargetLocatorFilter::matchesFor(QFutureInterface &future, const QString &entry) +QList CMakeTargetLocatorFilter::matchesFor( + QFutureInterface &future, const QString &entry) { Q_UNUSED(future) Q_UNUSED(entry) @@ -85,7 +87,8 @@ QList CMakeTargetLocatorFilter::matchesFor(QFutureInte void CMakeTargetLocatorFilter::projectListUpdated() { // Enable the filter if there's at least one CMake project - setEnabled(Utils::contains(SessionManager::projects(), [](Project *p) { return qobject_cast(p); })); + setEnabled(Utils::contains(SessionManager::projects(), + [](Project *p) { return qobject_cast(p); })); } // -------------------------------------------------------------------- @@ -101,10 +104,8 @@ BuildCMakeTargetLocatorFilter::BuildCMakeTargetLocatorFilter() setPriority(High); } -void BuildCMakeTargetLocatorFilter::accept(const Core::LocatorFilterEntry &selection, - QString *newText, - int *selectionStart, - int *selectionLength) const +void BuildCMakeTargetLocatorFilter::accept(const LocatorFilterEntry &selection, QString *newText, + int *selectionStart, int *selectionLength) const { Q_UNUSED(newText) Q_UNUSED(selectionStart) @@ -151,7 +152,7 @@ OpenCMakeTargetLocatorFilter::OpenCMakeTargetLocatorFilter() setPriority(Medium); } -void OpenCMakeTargetLocatorFilter::accept(const Core::LocatorFilterEntry &selection, +void OpenCMakeTargetLocatorFilter::accept(const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const @@ -165,11 +166,9 @@ void OpenCMakeTargetLocatorFilter::accept(const Core::LocatorFilterEntry &select const auto file = FilePath::fromVariant(extraData.value("file")); if (line >= 0) - Core::EditorManager::openEditorAt({file, line}, - {}, - Core::EditorManager::AllowExternalEditor); + EditorManager::openEditorAt({file, line}, {}, EditorManager::AllowExternalEditor); else - Core::EditorManager::openEditor(file, {}, Core::EditorManager::AllowExternalEditor); + EditorManager::openEditor(file, {}, EditorManager::AllowExternalEditor); } } // CMakeProjectManager::Internal diff --git a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp index d6687284588..a52edbfce52 100644 --- a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp @@ -15,6 +15,7 @@ #include #include +using namespace Core; using namespace CPlusPlus; namespace CppEditor::Internal { @@ -35,9 +36,9 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager) connect(manager, &CppModelManager::documentUpdated, this, &CppCurrentDocumentFilter::onDocumentUpdated); - connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, this, &CppCurrentDocumentFilter::onCurrentEditorChanged); - connect(Core::EditorManager::instance(), &Core::EditorManager::editorAboutToClose, + connect(EditorManager::instance(), &EditorManager::editorAboutToClose, this, &CppCurrentDocumentFilter::onEditorAboutToClose); } @@ -50,11 +51,11 @@ void CppCurrentDocumentFilter::makeAuxiliary() setHidden(true); } -QList CppCurrentDocumentFilter::matchesFor( - QFutureInterface &future, const QString & entry) +QList CppCurrentDocumentFilter::matchesFor( + QFutureInterface &future, const QString & entry) { - QList goodEntries; - QList betterEntries; + QList goodEntries; + QList betterEntries; const QRegularExpression regexp = createRegExp(entry); if (!regexp.isValid()) @@ -84,14 +85,14 @@ QList CppCurrentDocumentFilter::matchesFor( } } - Core::LocatorFilterEntry filterEntry(this, name, id, info->icon()); + LocatorFilterEntry filterEntry(this, name, id, info->icon()); filterEntry.extraInfo = extraInfo; if (match.hasMatch()) { filterEntry.highlightInfo = highlightInfo(match); } else { match = regexp.match(extraInfo); filterEntry.highlightInfo = - highlightInfo(match, Core::LocatorFilterEntry::HighlightInfo::ExtraInfo); + highlightInfo(match, LocatorFilterEntry::HighlightInfo::ExtraInfo); } if (betterMatch) @@ -104,18 +105,18 @@ QList CppCurrentDocumentFilter::matchesFor( // entries are unsorted by design! betterEntries += goodEntries; - QHash> possibleDuplicates; - for (const Core::LocatorFilterEntry &e : std::as_const(betterEntries)) { + QHash> possibleDuplicates; + for (const LocatorFilterEntry &e : std::as_const(betterEntries)) { const IndexItem::Ptr info = qvariant_cast(e.internalData); possibleDuplicates[info->scopedSymbolName() + info->symbolType()] << e; } for (auto it = possibleDuplicates.cbegin(); it != possibleDuplicates.cend(); ++it) { - const QList &duplicates = it.value(); + const QList &duplicates = it.value(); if (duplicates.size() == 1) continue; - QList declarations; - QList definitions; - for (const Core::LocatorFilterEntry &candidate : duplicates) { + QList declarations; + QList definitions; + for (const LocatorFilterEntry &candidate : duplicates) { const IndexItem::Ptr info = qvariant_cast(candidate.internalData); if (info->type() != IndexItem::Function) break; @@ -126,8 +127,8 @@ QList CppCurrentDocumentFilter::matchesFor( } if (definitions.size() == 1 && declarations.size() + definitions.size() == duplicates.size()) { - for (const Core::LocatorFilterEntry &decl : std::as_const(declarations)) - Utils::erase(betterEntries, [&decl](const Core::LocatorFilterEntry &e) { + for (const LocatorFilterEntry &decl : std::as_const(declarations)) + Utils::erase(betterEntries, [&decl](const LocatorFilterEntry &e) { return e.internalData == decl.internalData; }); } @@ -136,15 +137,14 @@ QList CppCurrentDocumentFilter::matchesFor( return betterEntries; } -void CppCurrentDocumentFilter::accept(const Core::LocatorFilterEntry &selection, - QString *newText, int *selectionStart, - int *selectionLength) const +void CppCurrentDocumentFilter::accept(const LocatorFilterEntry &selection, QString *newText, + int *selectionStart, int *selectionLength) const { Q_UNUSED(newText) Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) IndexItem::Ptr info = qvariant_cast(selection.internalData); - Core::EditorManager::openEditorAt({info->filePath(), info->line(), info->column()}); + EditorManager::openEditorAt({info->filePath(), info->line(), info->column()}); } void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc) @@ -154,7 +154,7 @@ void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc) m_itemsOfCurrentDoc.clear(); } -void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor *currentEditor) +void CppCurrentDocumentFilter::onCurrentEditorChanged(IEditor *currentEditor) { QMutexLocker locker(&m_mutex); if (currentEditor) @@ -164,7 +164,7 @@ void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor *currentEdit m_itemsOfCurrentDoc.clear(); } -void CppCurrentDocumentFilter::onEditorAboutToClose(Core::IEditor *editorAboutToClose) +void CppCurrentDocumentFilter::onEditorAboutToClose(IEditor *editorAboutToClose) { if (!editorAboutToClose) return; diff --git a/src/plugins/cppeditor/cpplocatorfilter.cpp b/src/plugins/cppeditor/cpplocatorfilter.cpp index 083c5df1b2f..c6567165910 100644 --- a/src/plugins/cppeditor/cpplocatorfilter.cpp +++ b/src/plugins/cppeditor/cpplocatorfilter.cpp @@ -14,6 +14,8 @@ #include #include +using namespace Core; + namespace CppEditor { CppLocatorFilter::CppLocatorFilter(CppLocatorData *locatorData) @@ -27,10 +29,10 @@ CppLocatorFilter::CppLocatorFilter(CppLocatorData *locatorData) CppLocatorFilter::~CppLocatorFilter() = default; -Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info) +LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info) { const QVariant id = QVariant::fromValue(info); - Core::LocatorFilterEntry filterEntry(this, info->scopedSymbolName(), id, info->icon()); + LocatorFilterEntry filterEntry(this, info->scopedSymbolName(), id, info->icon()); if (info->type() == IndexItem::Class || info->type() == IndexItem::Enum) filterEntry.extraInfo = info->shortNativeFilePath(); else @@ -39,10 +41,10 @@ Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::P return filterEntry; } -QList CppLocatorFilter::matchesFor( - QFutureInterface &future, const QString &entry) +QList CppLocatorFilter::matchesFor( + QFutureInterface &future, const QString &entry) { - QList entries[int(MatchLevel::Count)]; + QList entries[int(MatchLevel::Count)]; const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); const IndexItem::ItemType wanted = matchTypes(); @@ -70,7 +72,7 @@ QList CppLocatorFilter::matchesFor( } if (match.hasMatch()) { - Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info); + LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info); // Highlight the matched characters, therefore it may be necessary // to update the match if the displayName is different from matchString @@ -82,7 +84,7 @@ QList CppLocatorFilter::matchesFor( if (matchInParameterList && filterEntry.highlightInfo.startsDisplay.isEmpty()) { match = regexp.match(filterEntry.extraInfo); filterEntry.highlightInfo - = highlightInfo(match, Core::LocatorFilterEntry::HighlightInfo::ExtraInfo); + = highlightInfo(match, LocatorFilterEntry::HighlightInfo::ExtraInfo); } else if (matchOffset > 0) { for (int &start : filterEntry.highlightInfo.startsDisplay) start -= matchOffset; @@ -107,22 +109,21 @@ QList CppLocatorFilter::matchesFor( for (auto &entry : entries) { if (entry.size() < 1000) - Utils::sort(entry, Core::LocatorFilterEntry::compareLexigraphically); + Utils::sort(entry, LocatorFilterEntry::compareLexigraphically); } - return std::accumulate(std::begin(entries), std::end(entries), QList()); + return std::accumulate(std::begin(entries), std::end(entries), QList()); } -void CppLocatorFilter::accept(const Core::LocatorFilterEntry &selection, +void CppLocatorFilter::accept(const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const { Q_UNUSED(newText) Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) IndexItem::Ptr info = qvariant_cast(selection.internalData); - Core::EditorManager::openEditorAt({info->filePath(), info->line(), info->column()}, - {}, - Core::EditorManager::AllowExternalEditor); + EditorManager::openEditorAt({info->filePath(), info->line(), info->column()}, {}, + EditorManager::AllowExternalEditor); } CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData) @@ -136,10 +137,10 @@ CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData) CppClassesFilter::~CppClassesFilter() = default; -Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info) +LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info) { const QVariant id = QVariant::fromValue(info); - Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon()); + LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon()); filterEntry.extraInfo = info->symbolScope().isEmpty() ? info->shortNativeFilePath() : info->symbolScope(); @@ -158,7 +159,7 @@ CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData) CppFunctionsFilter::~CppFunctionsFilter() = default; -Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info) +LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info) { const QVariant id = QVariant::fromValue(info); @@ -171,7 +172,7 @@ Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem: extraInfo.append(" (" + info->filePath().fileName() + ')'); } - Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon()); + LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon()); filterEntry.extraInfo = extraInfo; return filterEntry; diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp index 8fc44622ab2..373773786a9 100644 --- a/src/plugins/cppeditor/cppmodelmanager.cpp +++ b/src/plugins/cppeditor/cppmodelmanager.cpp @@ -90,6 +90,7 @@ #include #endif +using namespace Core; using namespace CPlusPlus; using namespace ProjectExplorer; using namespace Utils; @@ -155,7 +156,7 @@ public: class CppModelManagerPrivate { public: - void setupWatcher(const QFuture &future, ProjectExplorer::Project *project, + void setupWatcher(const QFuture &future, Project *project, ProjectData *projectData, CppModelManager *q); // Snapshot @@ -164,15 +165,15 @@ public: // Project integration QReadWriteLock m_projectLock; - QHash m_projectData; - QMap > m_fileToProjectParts; + QHash m_projectData; + QMap > m_fileToProjectParts; QMap m_projectPartIdToProjectProjectPart; // The members below are cached/(re)calculated from the projects and/or their project parts bool m_dirty; - Utils::FilePaths m_projectFiles; - ProjectExplorer::HeaderPaths m_headerPaths; - ProjectExplorer::Macros m_definedMacros; + FilePaths m_projectFiles; + HeaderPaths m_headerPaths; + Macros m_definedMacros; // Editor integration mutable QMutex m_cppEditorDocumentsMutex; @@ -201,12 +202,12 @@ public: QTimer m_fallbackProjectPartTimer; CppLocatorData m_locatorData; - std::unique_ptr m_locatorFilter; - std::unique_ptr m_classesFilter; - std::unique_ptr m_includesFilter; - std::unique_ptr m_functionsFilter; - std::unique_ptr m_symbolsFindFilter; - std::unique_ptr m_currentDocumentFilter; + std::unique_ptr m_locatorFilter; + std::unique_ptr m_classesFilter; + std::unique_ptr m_includesFilter; + std::unique_ptr m_functionsFilter; + std::unique_ptr m_symbolsFindFilter; + std::unique_ptr m_currentDocumentFilter; QList m_diagnosticMessages; }; @@ -338,7 +339,7 @@ void CppModelManager::findUsages(const CursorInEditor &data, Backend backend) void CppModelManager::switchHeaderSource(bool inNextSplit, Backend backend) { - const Core::IDocument *currentDocument = Core::EditorManager::currentDocument(); + const IDocument *currentDocument = EditorManager::currentDocument(); QTC_ASSERT(currentDocument, return); instance()->modelManagerSupport(backend)->switchHeaderSource(currentDocument->filePath(), inNextSplit); @@ -346,16 +347,16 @@ void CppModelManager::switchHeaderSource(bool inNextSplit, Backend backend) void CppModelManager::showPreprocessedFile(bool inNextSplit) { - const Core::IDocument *doc = Core::EditorManager::currentDocument(); + const IDocument *doc = EditorManager::currentDocument(); QTC_ASSERT(doc, return); static const auto showError = [](const QString &reason) { - Core::MessageManager::writeFlashing(Tr::tr("Cannot show preprocessed file: %1") - .arg(reason)); + MessageManager::writeFlashing(Tr::tr("Cannot show preprocessed file: %1") + .arg(reason)); }; static const auto showFallbackWarning = [](const QString &reason) { - Core::MessageManager::writeSilently( - Tr::tr("Falling back to built-in preprocessor: %1").arg(reason)); + MessageManager::writeSilently(Tr::tr("Falling back to built-in preprocessor: %1") + .arg(reason)); }; static const auto saveAndOpen = [](const FilePath &filePath, const QByteArray &contents, bool inNextSplit) { @@ -469,24 +470,24 @@ class FindUnusedActionsEnabledSwitcher { public: FindUnusedActionsEnabledSwitcher() - : actions{Core::ActionManager::command("CppTools.FindUnusedFunctions"), - Core::ActionManager::command("CppTools.FindUnusedFunctionsInSubProject")} + : actions{ActionManager::command("CppTools.FindUnusedFunctions"), + ActionManager::command("CppTools.FindUnusedFunctionsInSubProject")} { - for (Core::Command * const action : actions) + for (Command * const action : actions) action->action()->setEnabled(false); } ~FindUnusedActionsEnabledSwitcher() { - for (Core::Command * const action : actions) + for (Command * const action : actions) action->action()->setEnabled(true); } private: - const QList actions; + const QList actions; }; using FindUnusedActionsEnabledSwitcherPtr = std::shared_ptr; static void checkNextFunctionForUnused( - const QPointer &search, + const QPointer &search, const std::shared_ptr> &findRefsFuture, const FindUnusedActionsEnabledSwitcherPtr &actionsSwitcher) { @@ -531,30 +532,28 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder) const auto actionsSwitcher = std::make_shared(); // Step 1: Employ locator to find all functions - Core::ILocatorFilter *const functionsFilter - = Utils::findOrDefault(Core::ILocatorFilter::allLocatorFilters(), - Utils::equal(&Core::ILocatorFilter::id, + ILocatorFilter *const functionsFilter + = Utils::findOrDefault(ILocatorFilter::allLocatorFilters(), + Utils::equal(&ILocatorFilter::id, Id(Constants::FUNCTIONS_FILTER_ID))); QTC_ASSERT(functionsFilter, return); - const QPointer search - = Core::SearchResultWindow::instance() - ->startNewSearch(Tr::tr("Find Unused Functions"), + const QPointer search + = SearchResultWindow::instance()->startNewSearch(Tr::tr("Find Unused Functions"), {}, {}, - Core::SearchResultWindow::SearchOnly, - Core::SearchResultWindow::PreserveCaseDisabled, + SearchResultWindow::SearchOnly, + SearchResultWindow::PreserveCaseDisabled, "CppEditor"); - connect(search, &Core::SearchResult::activated, [](const Core::SearchResultItem &item) { - Core::EditorManager::openEditorAtSearchResult(item); + connect(search, &SearchResult::activated, [](const SearchResultItem &item) { + EditorManager::openEditorAtSearchResult(item); }); - Core::SearchResultWindow::instance()->popup(Core::IOutputPane::ModeSwitch - | Core::IOutputPane::WithFocus); - const auto locatorWatcher = new QFutureWatcher(search); + SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); + const auto locatorWatcher = new QFutureWatcher(search); functionsFilter->prepareSearch({}); - connect(search, &Core::SearchResult::canceled, locatorWatcher, [locatorWatcher] { + connect(search, &SearchResult::canceled, locatorWatcher, [locatorWatcher] { locatorWatcher->cancel(); }); - connect(locatorWatcher, &QFutureWatcher::finished, search, + connect(locatorWatcher, &QFutureWatcher::finished, search, [locatorWatcher, search, folder, actionsSwitcher] { locatorWatcher->deleteLater(); if (locatorWatcher->isCanceled()) { @@ -563,7 +562,7 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder) } Links links; for (int i = 0; i < locatorWatcher->future().resultCount(); ++i) { - const Core::LocatorFilterEntry &entry = locatorWatcher->resultAt(i); + const LocatorFilterEntry &entry = locatorWatcher->resultAt(i); static const QStringList prefixBlacklist{"main(", "~", "qHash(", "begin()", "end()", "cbegin()", "cend()", "constBegin()", "constEnd()"}; if (Utils::anyOf(prefixBlacklist, [&entry](const QString &prefix) { @@ -593,12 +592,11 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder) })); search->setUserData(remainingAndActiveLinks); const auto findRefsFuture = std::make_shared>(); - Core::FutureProgress *const progress - = Core::ProgressManager::addTask(findRefsFuture->future(), - Tr::tr("Finding Unused Functions"), - "CppEditor.FindUnusedFunctions"); + FutureProgress *const progress = ProgressManager::addTask(findRefsFuture->future(), + Tr::tr("Finding Unused Functions"), + "CppEditor.FindUnusedFunctions"); connect(progress, - &Core::FutureProgress::canceled, + &FutureProgress::canceled, search, [search, future = std::weak_ptr>(findRefsFuture)] { search->finishSearch(true); @@ -608,7 +606,7 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder) } }); findRefsFuture->setProgressRange(0, links.size()); - connect(search, &Core::SearchResult::canceled, [findRefsFuture] { + connect(search, &SearchResult::canceled, [findRefsFuture] { findRefsFuture->cancel(); findRefsFuture->reportFinished(); }); @@ -620,12 +618,12 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder) checkNextFunctionForUnused(search, findRefsFuture, actionsSwitcher); }); locatorWatcher->setFuture( - Utils::runAsync([functionsFilter](QFutureInterface &future) { + Utils::runAsync([functionsFilter](QFutureInterface &future) { future.reportResults(functionsFilter->matchesFor(future, {})); })); } -void CppModelManager::checkForUnusedSymbol(Core::SearchResult *search, +void CppModelManager::checkForUnusedSymbol(SearchResult *search, const Link &link, CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context, @@ -785,62 +783,62 @@ static void setFilter(std::unique_ptr &filter, filter = std::move(newFilter); } -void CppModelManager::setLocatorFilter(std::unique_ptr &&filter) +void CppModelManager::setLocatorFilter(std::unique_ptr &&filter) { setFilter(d->m_locatorFilter, std::move(filter)); } -void CppModelManager::setClassesFilter(std::unique_ptr &&filter) +void CppModelManager::setClassesFilter(std::unique_ptr &&filter) { setFilter(d->m_classesFilter, std::move(filter)); } -void CppModelManager::setIncludesFilter(std::unique_ptr &&filter) +void CppModelManager::setIncludesFilter(std::unique_ptr &&filter) { setFilter(d->m_includesFilter, std::move(filter)); } -void CppModelManager::setFunctionsFilter(std::unique_ptr &&filter) +void CppModelManager::setFunctionsFilter(std::unique_ptr &&filter) { setFilter(d->m_functionsFilter, std::move(filter)); } -void CppModelManager::setSymbolsFindFilter(std::unique_ptr &&filter) +void CppModelManager::setSymbolsFindFilter(std::unique_ptr &&filter) { setFilter(d->m_symbolsFindFilter, std::move(filter)); } -void CppModelManager::setCurrentDocumentFilter(std::unique_ptr &&filter) +void CppModelManager::setCurrentDocumentFilter(std::unique_ptr &&filter) { setFilter(d->m_currentDocumentFilter, std::move(filter)); } -Core::ILocatorFilter *CppModelManager::locatorFilter() const +ILocatorFilter *CppModelManager::locatorFilter() const { return d->m_locatorFilter.get(); } -Core::ILocatorFilter *CppModelManager::classesFilter() const +ILocatorFilter *CppModelManager::classesFilter() const { return d->m_classesFilter.get(); } -Core::ILocatorFilter *CppModelManager::includesFilter() const +ILocatorFilter *CppModelManager::includesFilter() const { return d->m_includesFilter.get(); } -Core::ILocatorFilter *CppModelManager::functionsFilter() const +ILocatorFilter *CppModelManager::functionsFilter() const { return d->m_functionsFilter.get(); } -Core::IFindFilter *CppModelManager::symbolsFindFilter() const +IFindFilter *CppModelManager::symbolsFindFilter() const { return d->m_symbolsFindFilter.get(); } -Core::ILocatorFilter *CppModelManager::currentDocumentFilter() const +ILocatorFilter *CppModelManager::currentDocumentFilter() const { return d->m_currentDocumentFilter.get(); } @@ -880,7 +878,7 @@ CppModelManager *CppModelManager::instance() void CppModelManager::registerJsExtension() { - Core::JsExpander::registerGlobalObject("Cpp", [this] { + JsExpander::registerGlobalObject("Cpp", [this] { return new CppToolsJsExtension(&d->m_locatorData); }); } @@ -888,9 +886,9 @@ void CppModelManager::registerJsExtension() void CppModelManager::initCppTools() { // Objects - connect(Core::VcsManager::instance(), &Core::VcsManager::repositoryChanged, + connect(VcsManager::instance(), &VcsManager::repositoryChanged, this, &CppModelManager::updateModifiedSourceFiles); - connect(Core::DocumentManager::instance(), &Core::DocumentManager::filesChangedInternally, + connect(DocumentManager::instance(), &DocumentManager::filesChangedInternally, [this](const FilePaths &filePaths) { updateSourceFiles(toSet(filePaths)); }); @@ -924,7 +922,7 @@ CppModelManager::CppModelManager() d->m_enableGC = true; // Visual C++ has 1MiB, macOSX has 512KiB - if (Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()) + if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost()) d->m_threadPool.setStackSize(2 * 1024 * 1024); qRegisterMetaType >(); @@ -940,23 +938,23 @@ CppModelManager::CppModelManager() d->m_delayedGcTimer.setSingleShot(true); connect(&d->m_delayedGcTimer, &QTimer::timeout, this, &CppModelManager::GC); - auto sessionManager = ProjectExplorer::SessionManager::instance(); - connect(sessionManager, &ProjectExplorer::SessionManager::projectAdded, + auto sessionManager = SessionManager::instance(); + connect(sessionManager, &SessionManager::projectAdded, this, &CppModelManager::onProjectAdded); - connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject, + connect(sessionManager, &SessionManager::aboutToRemoveProject, this, &CppModelManager::onAboutToRemoveProject); - connect(sessionManager, &ProjectExplorer::SessionManager::aboutToLoadSession, + connect(sessionManager, &SessionManager::aboutToLoadSession, this, &CppModelManager::onAboutToLoadSession); - connect(sessionManager, &ProjectExplorer::SessionManager::startupProjectChanged, + connect(sessionManager, &SessionManager::startupProjectChanged, this, &CppModelManager::onActiveProjectChanged); - connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, this, &CppModelManager::onCurrentEditorChanged); - connect(Core::DocumentManager::instance(), &Core::DocumentManager::allDocumentsRenamed, + connect(DocumentManager::instance(), &DocumentManager::allDocumentsRenamed, this, &CppModelManager::renameIncludes); - connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose, + connect(ICore::instance(), &ICore::coreAboutToClose, this, &CppModelManager::onCoreAboutToClose); d->m_fallbackProjectPartTimer.setSingleShot(true); @@ -1041,13 +1039,13 @@ FilePaths CppModelManager::internalProjectFiles() const return files; } -ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const +HeaderPaths CppModelManager::internalHeaderPaths() const { - ProjectExplorer::HeaderPaths headerPaths; + HeaderPaths headerPaths; for (const ProjectData &projectData: std::as_const(d->m_projectData)) { for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) { - for (const ProjectExplorer::HeaderPath &path : part->headerPaths) { - ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type); + for (const HeaderPath &path : part->headerPaths) { + HeaderPath hp(QDir::cleanPath(path.path), path.type); if (!headerPaths.contains(hp)) headerPaths.push_back(std::move(hp)); } @@ -1056,8 +1054,7 @@ ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const return headerPaths; } -static void addUnique(const ProjectExplorer::Macros &newMacros, - ProjectExplorer::Macros ¯os, +static void addUnique(const Macros &newMacros, Macros ¯os, QSet &alreadyIn) { for (const ProjectExplorer::Macro ¯o : newMacros) { @@ -1068,9 +1065,9 @@ static void addUnique(const ProjectExplorer::Macros &newMacros, } } -ProjectExplorer::Macros CppModelManager::internalDefinedMacros() const +Macros CppModelManager::internalDefinedMacros() const { - ProjectExplorer::Macros macros; + Macros macros; QSet alreadyIn; for (const ProjectData &projectData : std::as_const(d->m_projectData)) { for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) { @@ -1093,7 +1090,7 @@ void CppModelManager::dumpModelManagerConfiguration(const QString &logFileId) dumper.dumpSnapshot(globalSnapshot, globalSnapshotTitle, /*isGlobalSnapshot=*/ true); dumper.dumpWorkingCopy(workingCopy()); dumper.dumpMergedEntities(headerPaths(), - ProjectExplorer:: Macro::toByteArray(definedMacros())); + ProjectExplorer::Macro::toByteArray(definedMacros())); } QSet CppModelManager::abstractEditorSupports() const @@ -1268,8 +1265,8 @@ static QSet filteredFilesRemoved(const QSet &files, int fileSi const QString msg = Tr::tr("C++ Indexer: Skipping file \"%1\" " "because its path matches the ignore pattern.") .arg(filePath.displayName()); - QMetaObject::invokeMethod(Core::MessageManager::instance(), - [msg]() { Core::MessageManager::writeSilently(msg); }); + QMetaObject::invokeMethod(MessageManager::instance(), + [msg] { MessageManager::writeSilently(msg); }); skip = true; break; } @@ -1304,7 +1301,7 @@ ProjectInfoList CppModelManager::projectInfos() const [](const ProjectData &d) { return d.projectInfo; }); } -ProjectInfo::ConstPtr CppModelManager::projectInfo(ProjectExplorer::Project *project) const +ProjectInfo::ConstPtr CppModelManager::projectInfo(Project *project) const { QReadLocker locker(&d->m_projectLock); return d->m_projectData.value(project).projectInfo; @@ -1424,8 +1421,7 @@ void CppModelManager::recalculateProjectPartMappings() d->m_symbolFinder.clearCache(); } -void CppModelManagerPrivate::setupWatcher(const QFuture &future, - ProjectExplorer::Project *project, +void CppModelManagerPrivate::setupWatcher(const QFuture &future, Project *project, ProjectData *projectData, CppModelManager *q) { projectData->indexer = new QFutureWatcher(q); @@ -1446,10 +1442,10 @@ void CppModelManagerPrivate::setupWatcher(const QFuture &future, void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const { // Refresh visible documents - QSet visibleCppEditorDocuments; - const QList editors = Core::EditorManager::visibleEditors(); - for (Core::IEditor *editor: editors) { - if (Core::IDocument *document = editor->document()) { + QSet visibleCppEditorDocuments; + const QList editors = EditorManager::visibleEditors(); + for (IEditor *editor: editors) { + if (IDocument *document = editor->document()) { const FilePath filePath = document->filePath(); if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) { visibleCppEditorDocuments.insert(document); @@ -1459,10 +1455,10 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const } // Mark invisible documents dirty - QSet invisibleCppEditorDocuments - = Utils::toSet(Core::DocumentModel::openedDocuments()); + QSet invisibleCppEditorDocuments + = Utils::toSet(DocumentModel::openedDocuments()); invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments); - for (Core::IDocument *document : std::as_const(invisibleCppEditorDocuments)) { + for (IDocument *document : std::as_const(invisibleCppEditorDocuments)) { const FilePath filePath = document->filePath(); if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) { const CppEditorDocumentHandle::RefreshReason refreshReason = projectsUpdated @@ -1483,7 +1479,7 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo::ConstPtr &ne QStringList removedProjectParts; bool filesRemoved = false; - ProjectExplorer::Project * const project = projectForProjectInfo(*newProjectInfo); + Project * const project = projectForProjectInfo(*newProjectInfo); if (!project) return {}; @@ -1589,20 +1585,20 @@ ProjectPart::ConstPtr CppModelManager::projectPartForId(const QString &projectPa return d->m_projectPartIdToProjectProjectPart.value(projectPartId); } -QList CppModelManager::projectPart(const Utils::FilePath &fileName) const +QList CppModelManager::projectPart(const FilePath &fileName) const { QReadLocker locker(&d->m_projectLock); return d->m_fileToProjectParts.value(fileName.canonicalPath()); } QList CppModelManager::projectPartFromDependencies( - const Utils::FilePath &fileName) const + const FilePath &fileName) const { QSet parts; - const Utils::FilePaths deps = snapshot().filesDependingOn(fileName); + const FilePaths deps = snapshot().filesDependingOn(fileName); QReadLocker locker(&d->m_projectLock); - for (const Utils::FilePath &dep : deps) + for (const FilePath &dep : deps) parts.unite(Utils::toSet(d->m_fileToProjectParts.value(dep.canonicalPath()))); return parts.values(); @@ -1614,7 +1610,7 @@ ProjectPart::ConstPtr CppModelManager::fallbackProjectPart() return d->m_fallbackProjectPart; } -bool CppModelManager::isCppEditor(Core::IEditor *editor) +bool CppModelManager::isCppEditor(IEditor *editor) { return editor->context().contains(ProjectExplorer::Constants::CXX_LANGUAGE_ID); } @@ -1647,7 +1643,7 @@ void CppModelManager::emitAbstractEditorSupportRemoved(const QString &filePath) emit abstractEditorSupportRemoved(filePath); } -void CppModelManager::onProjectAdded(ProjectExplorer::Project *) +void CppModelManager::onProjectAdded(Project *) { QWriteLocker locker(&d->m_projectLock); d->m_dirty = true; @@ -1667,7 +1663,7 @@ static QStringList removedProjectParts(const QStringList &before, const QStringL return Utils::toList(b); } -void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project) +void CppModelManager::onAboutToRemoveProject(Project *project) { QStringList idsOfRemovedProjectParts; @@ -1689,7 +1685,7 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project) delayedGC(); } -void CppModelManager::onActiveProjectChanged(ProjectExplorer::Project *project) +void CppModelManager::onActiveProjectChanged(Project *project) { if (!project) return; // Last project closed. @@ -1711,7 +1707,7 @@ void CppModelManager::onSourceFilesRefreshed() const } } -void CppModelManager::onCurrentEditorChanged(Core::IEditor *editor) +void CppModelManager::onCurrentEditorChanged(IEditor *editor) { if (!editor || !editor->document()) return; @@ -1752,7 +1748,7 @@ QSet CppModelManager::dependingInternalTargets(const FilePath &file) co return result; } -QSet CppModelManager::internalTargets(const Utils::FilePath &filePath) const +QSet CppModelManager::internalTargets(const FilePath &filePath) const { const QList projectParts = projectPart(filePath); // if we have no project parts it's most likely a header with declarations only and CMake based @@ -1761,14 +1757,13 @@ QSet CppModelManager::internalTargets(const Utils::FilePath &filePath) QSet targets; for (const ProjectPart::ConstPtr &part : projectParts) { targets.insert(part->buildSystemTarget); - if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable) + if (part->buildTargetType != BuildTargetType::Executable) targets.unite(dependingInternalTargets(filePath)); } return targets; } -void CppModelManager::renameIncludes(const Utils::FilePath &oldFilePath, - const Utils::FilePath &newFilePath) +void CppModelManager::renameIncludes(const FilePath &oldFilePath, const FilePath &newFilePath) { if (oldFilePath.isEmpty() || newFilePath.isEmpty()) return; @@ -1815,7 +1810,7 @@ void CppModelManager::renameIncludes(const Utils::FilePath &oldFilePath, const QTextBlock &block = file->document()->findBlockByNumber(loc.second - 1); const int replaceStart = block.text().indexOf(oldFileName); if (replaceStart > -1) { - Utils::ChangeSet changeSet; + ChangeSet changeSet; changeSet.replace(block.position() + replaceStart, block.position() + replaceStart + oldFileName.length(), newFileName); @@ -1843,13 +1838,13 @@ static const char *belongingClassName(const Function *function) return nullptr; } -QSet CppModelManager::symbolsInFiles(const QSet &files) const +QSet CppModelManager::symbolsInFiles(const QSet &files) const { QSet uniqueSymbols; const Snapshot cppSnapShot = snapshot(); // Iterate over the files and get interesting symbols - for (const Utils::FilePath &file : files) { + for (const FilePath &file : files) { // Add symbols from the C++ code model const CPlusPlus::Document::Ptr doc = cppSnapShot.document(file); if (!doc.isNull() && doc->control()) { @@ -1881,7 +1876,7 @@ QSet CppModelManager::symbolsInFiles(const QSet &files void CppModelManager::onCoreAboutToClose() { - Core::ProgressManager::cancelTasks(Constants::TASK_INDEX); + ProgressManager::cancelTasks(Constants::TASK_INDEX); d->m_enableGC = false; } @@ -1891,27 +1886,27 @@ void CppModelManager::setupFallbackProjectPart() RawProjectPart rpp; rpp.setMacros(definedMacros()); rpp.setHeaderPaths(headerPaths()); - rpp.setQtVersion(Utils::QtMajorVersion::Qt5); + rpp.setQtVersion(QtMajorVersion::Qt5); // Do not activate ObjectiveCExtensions since this will lead to the // "objective-c++" language option for a project-less *.cpp file. - Utils::LanguageExtensions langExtensions = Utils::LanguageExtension::All; - langExtensions &= ~Utils::LanguageExtensions(Utils::LanguageExtension::ObjectiveC); + LanguageExtensions langExtensions = LanguageExtension::All; + langExtensions &= ~LanguageExtensions(LanguageExtension::ObjectiveC); // TODO: Use different fallback toolchain for different kinds of files? const Kit * const defaultKit = KitManager::isLoaded() ? KitManager::defaultKit() : nullptr; const ToolChain * const defaultTc = defaultKit ? ToolChainKitAspect::cxxToolChain(defaultKit) : nullptr; if (defaultKit && defaultTc) { - Utils::FilePath sysroot = SysRootKitAspect::sysRoot(defaultKit); + FilePath sysroot = SysRootKitAspect::sysRoot(defaultKit); if (sysroot.isEmpty()) - sysroot = Utils::FilePath::fromString(defaultTc->sysRoot()); + sysroot = FilePath::fromString(defaultTc->sysRoot()); Utils::Environment env = defaultKit->buildEnvironment(); tcInfo = ToolChainInfo(defaultTc, sysroot, env); const auto macroInspectionWrapper = [runner = tcInfo.macroInspectionRunner]( const QStringList &flags) { ToolChain::MacroInspectionReport report = runner(flags); - report.languageVersion = Utils::LanguageVersion::LatestCxx; + report.languageVersion = LanguageVersion::LatestCxx; return report; }; tcInfo.macroInspectionRunner = macroInspectionWrapper; @@ -1941,7 +1936,7 @@ void CppModelManager::GC() filesInEditorSupports << abstractEditorSupport->filePath(); Snapshot currentSnapshot = snapshot(); - QSet reachableFiles; + QSet reachableFiles; // The configuration file is part of the project files, which is just fine. // If single files are open, without any project, then there is no need to // keep the configuration file around. @@ -1964,7 +1959,7 @@ void CppModelManager::GC() QStringList notReachableFiles; Snapshot newSnapshot; for (Snapshot::const_iterator it = currentSnapshot.begin(); it != currentSnapshot.end(); ++it) { - const Utils::FilePath &fileName = it.key(); + const FilePath &fileName = it.key(); if (reachableFiles.contains(fileName)) newSnapshot.insert(it.value()); @@ -2001,7 +1996,7 @@ TextEditor::BaseHoverHandler *CppModelManager::createHoverHandler() const } void CppModelManager::followSymbol(const CursorInEditor &data, - const Utils::LinkHandler &processLinkCallback, + const LinkHandler &processLinkCallback, bool resolveTarget, bool inNextSplit, Backend backend) { instance()->modelManagerSupport(backend)->followSymbol(data, processLinkCallback, @@ -2009,7 +2004,7 @@ void CppModelManager::followSymbol(const CursorInEditor &data, } void CppModelManager::followSymbolToType(const CursorInEditor &data, - const Utils::LinkHandler &processLinkCallback, + const LinkHandler &processLinkCallback, bool inNextSplit, Backend backend) { instance()->modelManagerSupport(backend)->followSymbolToType(data, processLinkCallback, @@ -2017,13 +2012,13 @@ void CppModelManager::followSymbolToType(const CursorInEditor &data, } void CppModelManager::switchDeclDef(const CursorInEditor &data, - const Utils::LinkHandler &processLinkCallback, + const LinkHandler &processLinkCallback, Backend backend) { instance()->modelManagerSupport(backend)->switchDeclDef(data, processLinkCallback); } -Core::ILocatorFilter *CppModelManager::createAuxiliaryCurrentDocumentFilter() +ILocatorFilter *CppModelManager::createAuxiliaryCurrentDocumentFilter() { const auto filter = new Internal::CppCurrentDocumentFilter(instance()); filter->makeAuxiliary(); @@ -2049,7 +2044,7 @@ FilePaths CppModelManager::projectFiles() return d->m_projectFiles; } -ProjectExplorer::HeaderPaths CppModelManager::headerPaths() +HeaderPaths CppModelManager::headerPaths() { QWriteLocker locker(&d->m_projectLock); ensureUpdated(); @@ -2057,13 +2052,13 @@ ProjectExplorer::HeaderPaths CppModelManager::headerPaths() return d->m_headerPaths; } -void CppModelManager::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths) +void CppModelManager::setHeaderPaths(const HeaderPaths &headerPaths) { QWriteLocker locker(&d->m_projectLock); d->m_headerPaths = headerPaths; } -ProjectExplorer::Macros CppModelManager::definedMacros() +Macros CppModelManager::definedMacros() { QWriteLocker locker(&d->m_projectLock); ensureUpdated(); diff --git a/src/plugins/languageclient/locatorfilter.cpp b/src/plugins/languageclient/locatorfilter.cpp index 2c933c12204..2b0eca3a578 100644 --- a/src/plugins/languageclient/locatorfilter.cpp +++ b/src/plugins/languageclient/locatorfilter.cpp @@ -23,6 +23,7 @@ #include #include +using namespace Core; using namespace LanguageServerProtocol; namespace LanguageClient { @@ -36,7 +37,7 @@ DocumentLocatorFilter::DocumentLocatorFilter() setDefaultShortcutString("."); setDefaultIncludedByDefault(false); setPriority(ILocatorFilter::Low); - connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, this, &DocumentLocatorFilter::updateCurrentClient); } @@ -56,7 +57,7 @@ void DocumentLocatorFilter::updateCurrentClient() m_updateSymbolsConnection = connect(m_symbolCache, &DocumentSymbolCache::gotSymbols, this, &DocumentLocatorFilter::updateSymbols); } - m_resetSymbolsConnection = connect(document, &Core::IDocument::contentsChanged, + m_resetSymbolsConnection = connect(document, &IDocument::contentsChanged, this, &DocumentLocatorFilter::resetSymbols); m_currentUri = client->hostPathToServerUri(document->filePath()); m_pathMapper = client->hostPathMapper(); @@ -85,11 +86,11 @@ void DocumentLocatorFilter::resetSymbols() m_currentSymbols.reset(); } -static Core::LocatorFilterEntry generateLocatorEntry(const SymbolInformation &info, - Core::ILocatorFilter *filter, - DocumentUri::PathMapper pathMapper) +static LocatorFilterEntry generateLocatorEntry(const SymbolInformation &info, + ILocatorFilter *filter, + DocumentUri::PathMapper pathMapper) { - Core::LocatorFilterEntry entry; + LocatorFilterEntry entry; entry.filter = filter; entry.displayName = info.name(); if (std::optional container = info.containerName()) @@ -99,15 +100,15 @@ static Core::LocatorFilterEntry generateLocatorEntry(const SymbolInformation &in return entry; } -Core::LocatorFilterEntry DocumentLocatorFilter::generateLocatorEntry(const SymbolInformation &info) +LocatorFilterEntry DocumentLocatorFilter::generateLocatorEntry(const SymbolInformation &info) { QTC_ASSERT(m_pathMapper, return {}); return LanguageClient::generateLocatorEntry(info, this, m_pathMapper); } -QList DocumentLocatorFilter::generateLocatorEntries( +QList DocumentLocatorFilter::generateLocatorEntries( const SymbolInformation &info, const QRegularExpression ®exp, - const Core::LocatorFilterEntry &parent) + const LocatorFilterEntry &parent) { Q_UNUSED(parent) if (regexp.match(info.name()).hasMatch()) @@ -115,12 +116,11 @@ QList DocumentLocatorFilter::generateLocatorEntries( return {}; } -Core::LocatorFilterEntry DocumentLocatorFilter::generateLocatorEntry( - const DocumentSymbol &info, - const Core::LocatorFilterEntry &parent) +LocatorFilterEntry DocumentLocatorFilter::generateLocatorEntry(const DocumentSymbol &info, + const LocatorFilterEntry &parent) { Q_UNUSED(parent) - Core::LocatorFilterEntry entry; + LocatorFilterEntry entry; entry.filter = this; entry.displayName = info.name(); if (std::optional detail = info.detail()) @@ -131,14 +131,14 @@ Core::LocatorFilterEntry DocumentLocatorFilter::generateLocatorEntry( return entry; } -QList DocumentLocatorFilter::generateLocatorEntries( +QList DocumentLocatorFilter::generateLocatorEntries( const DocumentSymbol &info, const QRegularExpression ®exp, - const Core::LocatorFilterEntry &parent) + const LocatorFilterEntry &parent) { - QList entries; + QList entries; const QList children = info.children().value_or(QList()); const bool hasMatch = regexp.match(info.name()).hasMatch(); - Core::LocatorFilterEntry entry; + LocatorFilterEntry entry; if (hasMatch || !children.isEmpty()) entry = generateLocatorEntry(info, parent); if (hasMatch) @@ -149,10 +149,10 @@ QList DocumentLocatorFilter::generateLocatorEntries( } template -QList DocumentLocatorFilter::generateEntries(const QList &list, +QList DocumentLocatorFilter::generateEntries(const QList &list, const QString &filter) { - QList entries; + QList entries; FuzzyMatcher::CaseSensitivity caseSensitivity = ILocatorFilter::caseSensitivity(filter) == Qt::CaseSensitive ? FuzzyMatcher::CaseSensitivity::CaseSensitive @@ -175,20 +175,17 @@ void DocumentLocatorFilter::prepareSearch(const QString &/*entry*/) } } -QList DocumentLocatorFilter::matchesFor( - QFutureInterface &future, const QString &entry) +QList DocumentLocatorFilter::matchesFor( + QFutureInterface &future, const QString &entry) { QMutexLocker locker(&m_mutex); if (!m_symbolCache) return {}; if (!m_currentSymbols.has_value()) { QEventLoop loop; - connect(this, &DocumentLocatorFilter::symbolsUpToDate, &loop, [&]() { loop.exit(1); }); - QFutureWatcher watcher; - connect(&watcher, - &QFutureWatcher::canceled, - &loop, - &QEventLoop::quit); + connect(this, &DocumentLocatorFilter::symbolsUpToDate, &loop, [&] { loop.exit(1); }); + QFutureWatcher watcher; + connect(&watcher, &QFutureWatcher::canceled, &loop, &QEventLoop::quit); watcher.setFuture(future.future()); locker.unlock(); if (!loop.exec()) @@ -206,7 +203,7 @@ QList DocumentLocatorFilter::matchesFor( return {}; } -void DocumentLocatorFilter::accept(const Core::LocatorFilterEntry &selection, +void DocumentLocatorFilter::accept(const LocatorFilterEntry &selection, QString * /*newText*/, int * /*selectionStart*/, int * /*selectionLength*/) const @@ -217,11 +214,10 @@ void DocumentLocatorFilter::accept(const Core::LocatorFilterEntry &selection, const Utils::Link link(m_currentUri.toFilePath(m_pathMapper), lineColumn.line + 1, lineColumn.column); - Core::EditorManager::openEditorAt(link, {}, Core::EditorManager::AllowExternalEditor); + EditorManager::openEditorAt(link, {}, EditorManager::AllowExternalEditor); } else if (selection.internalData.canConvert()) { - Core::EditorManager::openEditorAt(qvariant_cast(selection.internalData), - {}, - Core::EditorManager::AllowExternalEditor); + EditorManager::openEditorAt(qvariant_cast(selection.internalData), {}, + EditorManager::AllowExternalEditor); } } @@ -283,16 +279,16 @@ void WorkspaceLocatorFilter::prepareSearch(const QString &entry, } } -QList WorkspaceLocatorFilter::matchesFor( - QFutureInterface &future, const QString & /*entry*/) +QList WorkspaceLocatorFilter::matchesFor( + QFutureInterface &future, const QString & /*entry*/) { QMutexLocker locker(&m_mutex); if (!m_pendingRequests.isEmpty()) { QEventLoop loop; - connect(this, &WorkspaceLocatorFilter::allRequestsFinished, &loop, [&]() { loop.exit(1); }); - QFutureWatcher watcher; + connect(this, &WorkspaceLocatorFilter::allRequestsFinished, &loop, [&] { loop.exit(1); }); + QFutureWatcher watcher; connect(&watcher, - &QFutureWatcher::canceled, + &QFutureWatcher::canceled, &loop, &QEventLoop::quit); watcher.setFuture(future.future()); @@ -315,15 +311,15 @@ QList WorkspaceLocatorFilter::matchesFor( return Utils::transform(m_results, generateEntry).toList(); } -void WorkspaceLocatorFilter::accept(const Core::LocatorFilterEntry &selection, +void WorkspaceLocatorFilter::accept(const LocatorFilterEntry &selection, QString * /*newText*/, int * /*selectionStart*/, int * /*selectionLength*/) const { - if (selection.internalData.canConvert()) - Core::EditorManager::openEditorAt(qvariant_cast(selection.internalData), - {}, - Core::EditorManager::AllowExternalEditor); + if (selection.internalData.canConvert()) { + EditorManager::openEditorAt(qvariant_cast(selection.internalData), {}, + EditorManager::AllowExternalEditor); + } } void WorkspaceLocatorFilter::handleResponse(Client *client, diff --git a/src/plugins/modeleditor/elementtasks.cpp b/src/plugins/modeleditor/elementtasks.cpp index e0efd6914a6..6702344db5c 100644 --- a/src/plugins/modeleditor/elementtasks.cpp +++ b/src/plugins/modeleditor/elementtasks.cpp @@ -33,6 +33,8 @@ #include +using namespace Core; + namespace ModelEditor { namespace Internal { @@ -87,15 +89,14 @@ bool ElementTasks::hasClassDefinition(const qmt::MElement *element) const ? klass->name() : klass->umlNamespace() + "::" + klass->name(); - Core::ILocatorFilter *classesFilter - = CppEditor::CppModelManager::instance()->classesFilter(); + ILocatorFilter *classesFilter = CppEditor::CppModelManager::instance()->classesFilter(); if (!classesFilter) return false; - QFutureInterface dummyInterface; - const QList matches + QFutureInterface dummyInterface; + const QList matches = classesFilter->matchesFor(dummyInterface, qualifiedClassName); - for (const Core::LocatorFilterEntry &entry : matches) { + for (const LocatorFilterEntry &entry : matches) { CppEditor::IndexItem::Ptr info = qvariant_cast(entry.internalData); if (info->scopedSymbolName() != qualifiedClassName) continue; @@ -124,19 +125,18 @@ void ElementTasks::openClassDefinition(const qmt::MElement *element) ? klass->name() : klass->umlNamespace() + "::" + klass->name(); - Core::ILocatorFilter *classesFilter - = CppEditor::CppModelManager::instance()->classesFilter(); + ILocatorFilter *classesFilter = CppEditor::CppModelManager::instance()->classesFilter(); if (!classesFilter) return; - QFutureInterface dummyInterface; - const QList matches + QFutureInterface dummyInterface; + const QList matches = classesFilter->matchesFor(dummyInterface, qualifiedClassName); - for (const Core::LocatorFilterEntry &entry : matches) { + for (const LocatorFilterEntry &entry : matches) { CppEditor::IndexItem::Ptr info = qvariant_cast(entry.internalData); if (info->scopedSymbolName() != qualifiedClassName) continue; - if (Core::EditorManager::instance()->openEditorAt( + if (EditorManager::instance()->openEditorAt( {info->filePath(), info->line(), info->column()})) { return; } diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp index 4d4ce05fb72..7ce42af1149 100644 --- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp +++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp @@ -12,12 +12,13 @@ #include +using namespace Core; using namespace QmlJSTools::Internal; Q_DECLARE_METATYPE(LocatorData::Entry) FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent) - : Core::ILocatorFilter(parent) + : ILocatorFilter(parent) , m_data(data) { setId("Functions"); @@ -28,11 +29,10 @@ FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent) FunctionFilter::~FunctionFilter() = default; -QList FunctionFilter::matchesFor( - QFutureInterface &future, - const QString &entry) +QList FunctionFilter::matchesFor(QFutureInterface &future, + const QString &entry) { - QList entries[int(MatchLevel::Count)]; + QList entries[int(MatchLevel::Count)]; const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); const QRegularExpression regexp = createRegExp(entry); @@ -51,7 +51,7 @@ QList FunctionFilter::matchesFor( const QRegularExpressionMatch match = regexp.match(info.symbolName); if (match.hasMatch()) { QVariant id = QVariant::fromValue(info); - Core::LocatorFilterEntry filterEntry(this, info.displayName, id/*, info.icon*/); + LocatorFilterEntry filterEntry(this, info.displayName, id/*, info.icon*/); filterEntry.extraInfo = info.extraInfo; filterEntry.highlightInfo = highlightInfo(match); @@ -67,18 +67,17 @@ QList FunctionFilter::matchesFor( for (auto &entry : entries) { if (entry.size() < 1000) - Utils::sort(entry, Core::LocatorFilterEntry::compareLexigraphically); + Utils::sort(entry, LocatorFilterEntry::compareLexigraphically); } - - return std::accumulate(std::begin(entries), std::end(entries), QList()); + return std::accumulate(std::begin(entries), std::end(entries), QList()); } -void FunctionFilter::accept(const Core::LocatorFilterEntry &selection, +void FunctionFilter::accept(const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const { Q_UNUSED(newText) Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) const LocatorData::Entry entry = qvariant_cast(selection.internalData); - Core::EditorManager::openEditorAt({entry.fileName, entry.line, entry.column}); + EditorManager::openEditorAt({entry.fileName, entry.line, entry.column}); }