diff --git a/src/plugins/clangcodemodel/clangbackendreceiver.h b/src/plugins/clangcodemodel/clangbackendreceiver.h index 3ce19a7b83a..253a0ff52c3 100644 --- a/src/plugins/clangcodemodel/clangbackendreceiver.h +++ b/src/plugins/clangcodemodel/clangbackendreceiver.h @@ -26,7 +26,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/plugins/clangcodemodel/clangfollowsymbol.h b/src/plugins/clangcodemodel/clangfollowsymbol.h index 5880d59301e..0ae10035b40 100644 --- a/src/plugins/clangcodemodel/clangfollowsymbol.h +++ b/src/plugins/clangcodemodel/clangfollowsymbol.h @@ -25,8 +25,8 @@ #pragma once +#include #include -#include #include diff --git a/src/plugins/cppeditor/CMakeLists.txt b/src/plugins/cppeditor/CMakeLists.txt index b79457e3055..afc8d04d80f 100644 --- a/src/plugins/cppeditor/CMakeLists.txt +++ b/src/plugins/cppeditor/CMakeLists.txt @@ -41,7 +41,6 @@ add_qtc_plugin(CppEditor cppdoxygen.cpp cppdoxygen.h cppeditor.qrc cppeditor_global.h - cppeditor_utils.h cppeditorconstants.h cppeditordocument.cpp cppeditordocument.h cppeditoroutline.cpp cppeditoroutline.h @@ -93,7 +92,6 @@ add_qtc_plugin(CppEditor cppsemanticinfo.h cppsemanticinfoupdater.cpp cppsemanticinfoupdater.h cppsourceprocessor.cpp cppsourceprocessor.h - cppsymbolinfo.h cpptoolsjsextension.cpp cpptoolsjsextension.h cpptoolsreuse.cpp cpptoolsreuse.h cpptoolssettings.cpp cpptoolssettings.h diff --git a/src/plugins/cppeditor/baseeditordocumentparser.cpp b/src/plugins/cppeditor/baseeditordocumentparser.cpp index 966ee3ebc3e..f1066bd8380 100644 --- a/src/plugins/cppeditor/baseeditordocumentparser.cpp +++ b/src/plugins/cppeditor/baseeditordocumentparser.cpp @@ -117,12 +117,11 @@ BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const QString &fileP return BaseEditorDocumentParser::Ptr(); } -ProjectPartInfo BaseEditorDocumentParser::determineProjectPart( - const QString &filePath, +ProjectPartInfo BaseEditorDocumentParser::determineProjectPart(const QString &filePath, const QString &preferredProjectPartId, const ProjectPartInfo ¤tProjectPartInfo, const ProjectExplorer::Project *activeProject, - Language languagePreference, + Utils::Language languagePreference, bool projectsUpdated) { Internal::ProjectPartChooser chooser; diff --git a/src/plugins/cppeditor/baseeditordocumentparser.h b/src/plugins/cppeditor/baseeditordocumentparser.h index 9e465d6d70c..2e10d561787 100644 --- a/src/plugins/cppeditor/baseeditordocumentparser.h +++ b/src/plugins/cppeditor/baseeditordocumentparser.h @@ -26,7 +26,7 @@ #pragma once #include "cppeditor_global.h" -#include "cppeditor_utils.h" +#include "cpptoolsreuse.h" #include "cppworkingcopy.h" #include "projectpart.h" @@ -55,7 +55,7 @@ public: struct UpdateParams { UpdateParams(const WorkingCopy &workingCopy, const ProjectExplorer::Project *activeProject, - Language languagePreference, + Utils::Language languagePreference, bool projectsUpdated) : workingCopy(workingCopy) , activeProject(activeProject) @@ -66,7 +66,7 @@ public: WorkingCopy workingCopy; const ProjectExplorer::Project *activeProject = nullptr; - Language languagePreference = Language::Cxx; + Utils::Language languagePreference = Utils::Language::Cxx; bool projectsUpdated = false; }; @@ -98,7 +98,7 @@ protected: const QString &preferredProjectPartId, const ProjectPartInfo ¤tProjectPartInfo, const ProjectExplorer::Project *activeProject, - Language languagePreference, + Utils::Language languagePreference, bool projectsUpdated); mutable QMutex m_stateAndConfigurationMutex; diff --git a/src/plugins/cppeditor/baseeditordocumentprocessor.cpp b/src/plugins/cppeditor/baseeditordocumentprocessor.cpp index 2f2b16461fc..dcd64222e4a 100644 --- a/src/plugins/cppeditor/baseeditordocumentprocessor.cpp +++ b/src/plugins/cppeditor/baseeditordocumentprocessor.cpp @@ -26,7 +26,6 @@ #include "baseeditordocumentprocessor.h" #include "cppcodemodelsettings.h" -#include "cppeditor_utils.h" #include "cppmodelmanager.h" #include "cpptoolsreuse.h" #include "editordocumenthandle.h" @@ -55,9 +54,9 @@ BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor() = default; void BaseEditorDocumentProcessor::run(bool projectsUpdated) { - const Language languagePreference = codeModelSettings()->interpretAmbigiousHeadersAsCHeaders() - ? Language::C - : Language::Cxx; + const Utils::Language languagePreference = codeModelSettings()->interpretAmbigiousHeadersAsCHeaders() + ? Utils::Language::C + : Utils::Language::Cxx; runImpl({CppModelManager::instance()->workingCopy(), ProjectExplorer::SessionManager::startupProject(), diff --git a/src/plugins/cppeditor/baseeditordocumentprocessor.h b/src/plugins/cppeditor/baseeditordocumentprocessor.h index 20d392dd740..3a7f9844fb1 100644 --- a/src/plugins/cppeditor/baseeditordocumentprocessor.h +++ b/src/plugins/cppeditor/baseeditordocumentprocessor.h @@ -27,9 +27,9 @@ #include "baseeditordocumentparser.h" #include "cppcursorinfo.h" -#include "cppsymbolinfo.h" -#include "cppsemanticinfo.h" #include "cppeditor_global.h" +#include "cppsemanticinfo.h" +#include "cpptoolsreuse.h" #include #include diff --git a/src/plugins/cppeditor/builtinindexingsupport.cpp b/src/plugins/cppeditor/builtinindexingsupport.cpp index 0e823282e24..7bbad4179c0 100644 --- a/src/plugins/cppeditor/builtinindexingsupport.cpp +++ b/src/plugins/cppeditor/builtinindexingsupport.cpp @@ -156,7 +156,8 @@ void indexFindErrors(QFutureInterface &indexingFuture, // Parse the file as precisely as possible BuiltinEditorDocumentParser parser(file); parser.setReleaseSourceAndAST(false); - parser.update({CppModelManager::instance()->workingCopy(), nullptr, Language::Cxx, false}); + parser.update({CppModelManager::instance()->workingCopy(), nullptr, + Utils::Language::Cxx, false}); CPlusPlus::Document::Ptr document = parser.document(); QTC_ASSERT(document, return); diff --git a/src/plugins/cppeditor/cppcompletionassist.cpp b/src/plugins/cppeditor/cppcompletionassist.cpp index 88e5e0d8657..1eb767427bf 100644 --- a/src/plugins/cppeditor/cppcompletionassist.cpp +++ b/src/plugins/cppeditor/cppcompletionassist.cpp @@ -2124,7 +2124,7 @@ void CppCompletionAssistInterface::getCppSpecifics() const if (m_parser) { m_parser->update({CppModelManager::instance()->workingCopy(), nullptr, - Language::Cxx, + Utils::Language::Cxx, false}); m_snapshot = m_parser->snapshot(); m_headerPaths = m_parser->headerPaths(); diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro index 553d27787b9..ab000441f10 100644 --- a/src/plugins/cppeditor/cppeditor.pro +++ b/src/plugins/cppeditor/cppeditor.pro @@ -37,7 +37,6 @@ HEADERS += \ cppcursorinfo.h \ cppdoxygen.h \ cppeditor_global.h \ - cppeditor_utils.h \ cppeditorconstants.h \ cppeditordocument.h \ cppeditoroutline.h \ @@ -88,7 +87,6 @@ HEADERS += \ cppsemanticinfo.h \ cppsemanticinfoupdater.h \ cppsourceprocessor.h \ - cppsymbolinfo.h \ cpptoolsjsextension.h \ cpptoolsreuse.h \ cpptoolssettings.h \ diff --git a/src/plugins/cppeditor/cppeditor.qbs b/src/plugins/cppeditor/cppeditor.qbs index ec05e0717c7..0e6e2d5efe3 100644 --- a/src/plugins/cppeditor/cppeditor.qbs +++ b/src/plugins/cppeditor/cppeditor.qbs @@ -101,7 +101,6 @@ QtcPlugin { "cppeditorwidget.h", "cppeditor.qrc", "cppeditor_global.h", - "cppeditor_utils.h", "cppeditorconstants.h", "cppeditordocument.cpp", "cppeditordocument.h", @@ -200,7 +199,6 @@ QtcPlugin { "cppsemanticinfoupdater.h", "cppsourceprocessor.cpp", "cppsourceprocessor.h", - "cppsymbolinfo.h", "cpptoolsjsextension.cpp", "cpptoolsjsextension.h", "cpptoolsreuse.cpp", diff --git a/src/plugins/cppeditor/cppeditor_utils.h b/src/plugins/cppeditor/cppeditor_utils.h deleted file mode 100644 index 43f99d783d7..00000000000 --- a/src/plugins/cppeditor/cppeditor_utils.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "projectpart.h" - -namespace CppEditor { - -using Utils::Language; - -// FIXME: Surely this can get merged into another header? -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; -}; - -} // namespace CppEditor diff --git a/src/plugins/cppeditor/cppmodelmanager_test.cpp b/src/plugins/cppeditor/cppmodelmanager_test.cpp index 67716028cfd..a72f0e02561 100644 --- a/src/plugins/cppeditor/cppmodelmanager_test.cpp +++ b/src/plugins/cppeditor/cppmodelmanager_test.cpp @@ -859,7 +859,8 @@ void ModelManagerTest::testPrecompiledHeaders() BaseEditorDocumentParser::Configuration config = parser->configuration(); config.usePrecompiledHeaders = true; parser->setConfiguration(config); - parser->update({CppModelManager::instance()->workingCopy(), nullptr, Language::Cxx, false}); + parser->update({CppModelManager::instance()->workingCopy(), nullptr, + Utils::Language::Cxx, false}); // Check if defines from pch are considered Document::Ptr document = mm->document(fileName); @@ -932,7 +933,8 @@ void ModelManagerTest::testDefinesPerEditor() BaseEditorDocumentParser::Configuration config = parser->configuration(); config.editorDefines = editorDefines.toUtf8(); parser->setConfiguration(config); - parser->update({CppModelManager::instance()->workingCopy(), nullptr, Language::Cxx, false}); + parser->update({CppModelManager::instance()->workingCopy(), nullptr, + Utils::Language::Cxx, false}); Document::Ptr doc = mm->document(main1File); QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName); diff --git a/src/plugins/cppeditor/cppparsecontext.h b/src/plugins/cppeditor/cppparsecontext.h index 9ef1fc2bc34..b38ca6c8cb0 100644 --- a/src/plugins/cppeditor/cppparsecontext.h +++ b/src/plugins/cppeditor/cppparsecontext.h @@ -25,7 +25,7 @@ #pragma once -#include "cppeditor_utils.h" +#include "cpptoolsreuse.h" #include #include diff --git a/src/plugins/cppeditor/cppprojectinfogenerator.cpp b/src/plugins/cppeditor/cppprojectinfogenerator.cpp index c9075f7144e..67ebd19f6d5 100644 --- a/src/plugins/cppeditor/cppprojectinfogenerator.cpp +++ b/src/plugins/cppeditor/cppprojectinfogenerator.cpp @@ -38,6 +38,7 @@ #include using namespace ProjectExplorer; +using namespace Utils; namespace CppEditor::Internal { @@ -81,10 +82,8 @@ ProjectInfo::ConstPtr ProjectInfoGenerator::generate() } const QVector ProjectInfoGenerator::createProjectParts( - const RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath) + const RawProjectPart &rawProjectPart, const FilePath &projectFilePath) { - using Utils::LanguageExtension; - QVector result; ProjectFileCategorizer cat(rawProjectPart.displayName, rawProjectPart.files, @@ -140,12 +139,12 @@ const QVector ProjectInfoGenerator::createProjectParts( } ProjectPart::ConstPtr ProjectInfoGenerator::createProjectPart( - const Utils::FilePath &projectFilePath, + const FilePath &projectFilePath, const RawProjectPart &rawProjectPart, const ProjectFiles &projectFiles, const QString &partName, Language language, - Utils::LanguageExtensions languageExtensions) + LanguageExtensions languageExtensions) { RawProjectPartFlags flags; ToolChainInfo tcInfo; diff --git a/src/plugins/cppeditor/cppprojectinfogenerator.h b/src/plugins/cppeditor/cppprojectinfogenerator.h index a9352c3fd65..ea775f1ee8a 100644 --- a/src/plugins/cppeditor/cppprojectinfogenerator.h +++ b/src/plugins/cppeditor/cppprojectinfogenerator.h @@ -25,7 +25,6 @@ #pragma once -#include "cppeditor_utils.h" #include "projectinfo.h" #include @@ -48,7 +47,7 @@ private: const ProjectExplorer::RawProjectPart &rawProjectPart, const ProjectFiles &projectFiles, const QString &partName, - Language language, + Utils::Language language, Utils::LanguageExtensions languageExtensions); private: diff --git a/src/plugins/cppeditor/cppprojectpartchooser.cpp b/src/plugins/cppeditor/cppprojectpartchooser.cpp index 918f05f827e..65911000e71 100644 --- a/src/plugins/cppeditor/cppprojectpartchooser.cpp +++ b/src/plugins/cppeditor/cppprojectpartchooser.cpp @@ -28,6 +28,8 @@ #include #include +using namespace Utils; + namespace CppEditor::Internal { class ProjectPartPrioritizer @@ -80,7 +82,7 @@ private: { // Prioritize QList prioritized = Utils::transform(projectParts, - [&](const ProjectPart::ConstPtr &projectPart) { + [&](const ProjectPart::ConstPtr &projectPart) { return PrioritizedProjectPart{projectPart, priority(*projectPart)}; }); @@ -115,8 +117,7 @@ private: bool isPreferredLanguage(const ProjectPart &projectPart) const { - const bool isCProjectPart = projectPart.languageVersion - <= Utils::LanguageVersion::LatestC; + const bool isCProjectPart = projectPart.languageVersion <= LanguageVersion::LatestC; return (m_languagePreference == Language::C && isCProjectPart) || (m_languagePreference == Language::Cxx && !isCProjectPart); } @@ -130,8 +131,7 @@ private: ProjectPartInfo m_info; }; -ProjectPartInfo ProjectPartChooser::choose( - const QString &filePath, +ProjectPartInfo ProjectPartChooser::choose(const QString &filePath, const ProjectPartInfo ¤tProjectPartInfo, const QString &preferredProjectPartId, const ProjectExplorer::Project *activeProject, diff --git a/src/plugins/cppeditor/cppprojectpartchooser.h b/src/plugins/cppeditor/cppprojectpartchooser.h index e515080c4bd..4b8ee2dd1f6 100644 --- a/src/plugins/cppeditor/cppprojectpartchooser.h +++ b/src/plugins/cppeditor/cppprojectpartchooser.h @@ -25,7 +25,7 @@ #pragma once -#include "cppeditor_utils.h" +#include "cpptoolsreuse.h" #include "projectpart.h" #include @@ -51,7 +51,7 @@ public: const ProjectPartInfo ¤tProjectPartInfo, const QString &preferredProjectPartId, const ProjectExplorer::Project *activeProject, - Language languagePreference, + Utils::Language languagePreference, bool projectsUpdated) const; private: diff --git a/src/plugins/cppeditor/cppsymbolinfo.h b/src/plugins/cppeditor/cppsymbolinfo.h deleted file mode 100644 index 8c3033c7610..00000000000 --- a/src/plugins/cppeditor/cppsymbolinfo.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "cppeditor_global.h" - -#include - -namespace CppEditor { - -class CPPEDITOR_EXPORT SymbolInfo -{ -public: - int startLine = 0; - int startColumn = 0; - int endLine = 0; - int endColumn = 0; - QString fileName; - bool isResultOnlyForFallBack = false; -}; - -} // namespace CppEditor diff --git a/src/plugins/cppeditor/cpptoolsreuse.h b/src/plugins/cppeditor/cpptoolsreuse.h index e9055b78b9f..b3fd7a274b4 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.h +++ b/src/plugins/cppeditor/cpptoolsreuse.h @@ -29,6 +29,7 @@ #include "clangdiagnosticconfig.h" #include "compileroptionsbuilder.h" +#include "projectpart.h" #include @@ -92,6 +93,44 @@ 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); diff --git a/src/plugins/cppeditor/projectinfo_test.cpp b/src/plugins/cppeditor/projectinfo_test.cpp index 4593ade3727..e12f8329915 100644 --- a/src/plugins/cppeditor/projectinfo_test.cpp +++ b/src/plugins/cppeditor/projectinfo_test.cpp @@ -112,7 +112,7 @@ public: ProjectPartInfo::NoHint}; QString preferredProjectPartId; Utils::FilePath activeProject; - Language languagePreference = Language::Cxx; + Utils::Language languagePreference = Utils::Language::Cxx; bool projectsChanged = false; ProjectPartChooser chooser; @@ -224,7 +224,7 @@ void ProjectPartChooserTest::testForMultipleCheckIfActiveProjectChanged() void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCProjectPart() { ProjectPartChooserTestHelper t; - t.languagePreference = Language::C; + t.languagePreference = Utils::Language::C; t.projectPartsForFile = t.createCAndCxxProjectParts(); const ProjectPart::ConstPtr cProjectPart = t.projectPartsForFile.at(0); @@ -234,7 +234,7 @@ void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCProjectPart void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCxxProjectPart() { ProjectPartChooserTestHelper t; - t.languagePreference = Language::Cxx; + t.languagePreference = Utils::Language::Cxx; t.projectPartsForFile = t.createCAndCxxProjectParts(); const ProjectPart::ConstPtr cxxProjectPart = t.projectPartsForFile.at(1);