forked from qt-creator/qt-creator
CppEditor: Clean up ModelManagerSupport creation
No need for "providers" etc. Change-Id: I4ae9e8ecd6b3554711e002f233c13fd7758f01e4 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "clangcodemodelplugin.h"
|
||||
|
||||
#include "clangconstants.h"
|
||||
#include "clangmodelmanagersupport.h"
|
||||
#include "clangutils.h"
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
@@ -115,7 +116,8 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
|
||||
this,
|
||||
&ClangCodeModelPlugin::maybeHandleBatchFileAndExit);
|
||||
|
||||
CppEditor::CppModelManager::instance()->activateClangCodeModel(&m_modelManagerSupportProvider);
|
||||
CppEditor::CppModelManager::instance()->activateClangCodeModel(
|
||||
std::make_unique<ClangModelManagerSupport>());
|
||||
|
||||
createCompilationDBButton();
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangmodelmanagersupport.h"
|
||||
#include "clangutils.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
@@ -53,7 +52,6 @@ private:
|
||||
void generateCompilationDB();
|
||||
void createCompilationDBButton();
|
||||
|
||||
ClangModelManagerSupportProvider m_modelManagerSupportProvider;
|
||||
Utils::ParameterAction *m_generateCompilationDBAction = nullptr;
|
||||
QFutureWatcher<GenerateCompilationDbResult> m_generatorWatcher;
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
namespace ClangCodeModel {
|
||||
namespace Constants {
|
||||
|
||||
const char CLANG_MODELMANAGERSUPPORT_ID[] = "ClangCodeModel.ClangCodeModel";
|
||||
const char GENERATE_COMPILATION_DB[] = "ClangCodeModel.GenerateCompilationDB";
|
||||
const char CLANG_ERROR[] = "Clang.Error";
|
||||
const char CLANG_WARNING[] = "Clang.Warning";
|
||||
|
||||
@@ -825,22 +825,5 @@ ClangModelManagerSupport *ClangModelManagerSupport::instance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
QString ClangModelManagerSupportProvider::id() const
|
||||
{
|
||||
return QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID);
|
||||
}
|
||||
|
||||
QString ClangModelManagerSupportProvider::displayName() const
|
||||
{
|
||||
//: Display name
|
||||
return QCoreApplication::translate("ClangCodeModel::Internal::ModelManagerSupport",
|
||||
"Clang");
|
||||
}
|
||||
|
||||
CppEditor::ModelManagerSupport::Ptr ClangModelManagerSupportProvider::createModelManagerSupport()
|
||||
{
|
||||
return CppEditor::ModelManagerSupport::Ptr(new ClangModelManagerSupport);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // ClangCodeModel
|
||||
|
||||
@@ -123,14 +123,5 @@ private:
|
||||
QHash<Utils::FilePath, QString> m_queuedShadowDocuments;
|
||||
};
|
||||
|
||||
class ClangModelManagerSupportProvider : public CppEditor::ModelManagerSupportProvider
|
||||
{
|
||||
public:
|
||||
QString id() const override;
|
||||
QString displayName() const override;
|
||||
|
||||
CppEditor::ModelManagerSupport::Ptr createModelManagerSupport() override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -88,22 +88,6 @@ private:
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
QString BuiltinModelManagerSupportProvider::id() const
|
||||
{
|
||||
return QLatin1String("CppEditor.BuiltinCodeModel");
|
||||
}
|
||||
|
||||
QString BuiltinModelManagerSupportProvider::displayName() const
|
||||
{
|
||||
return QCoreApplication::translate("ModelManagerSupportInternal::displayName",
|
||||
"%1 Built-in").arg(Core::Constants::IDE_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
ModelManagerSupport::Ptr BuiltinModelManagerSupportProvider::createModelManagerSupport()
|
||||
{
|
||||
return ModelManagerSupport::Ptr(new BuiltinModelManagerSupport);
|
||||
}
|
||||
|
||||
BuiltinModelManagerSupport::BuiltinModelManagerSupport()
|
||||
: m_completionAssistProvider(new InternalCompletionAssistProvider),
|
||||
m_followSymbol(new FollowSymbolUnderCursor)
|
||||
|
||||
@@ -65,13 +65,4 @@ private:
|
||||
QScopedPointer<FollowSymbolUnderCursor> m_followSymbol;
|
||||
};
|
||||
|
||||
class BuiltinModelManagerSupportProvider : public ModelManagerSupportProvider
|
||||
{
|
||||
public:
|
||||
QString id() const override;
|
||||
QString displayName() const override;
|
||||
|
||||
ModelManagerSupport::Ptr createModelManagerSupport() override;
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
||||
@@ -177,8 +177,9 @@ public:
|
||||
QSet<AbstractEditorSupport *> m_extraEditorSupports;
|
||||
|
||||
// Model Manager Supports for e.g. completion and highlighting
|
||||
ModelManagerSupport::Ptr m_builtinModelManagerSupport;
|
||||
ModelManagerSupport::Ptr m_activeModelManagerSupport;
|
||||
BuiltinModelManagerSupport m_builtinModelManagerSupport;
|
||||
std::unique_ptr<ModelManagerSupport> m_extendedModelManagerSupport;
|
||||
ModelManagerSupport *m_activeModelManagerSupport = &m_builtinModelManagerSupport;
|
||||
|
||||
// Indexing
|
||||
CppIndexingSupport *m_internalIndexingSupport;
|
||||
@@ -307,8 +308,8 @@ QString CppModelManager::editorConfigurationFileName()
|
||||
|
||||
ModelManagerSupport *CppModelManager::modelManagerSupport(Backend backend) const
|
||||
{
|
||||
return (backend == Backend::Builtin
|
||||
? d->m_builtinModelManagerSupport : d->m_activeModelManagerSupport).data();
|
||||
return backend == Backend::Builtin
|
||||
? &d->m_builtinModelManagerSupport : d->m_activeModelManagerSupport;
|
||||
}
|
||||
|
||||
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
||||
@@ -477,8 +478,7 @@ SignalSlotType CppModelManager::getSignalSlotType(const QString &filePath,
|
||||
|
||||
FollowSymbolUnderCursor &CppModelManager::builtinFollowSymbol()
|
||||
{
|
||||
return instance()->d->m_builtinModelManagerSupport.staticCast<BuiltinModelManagerSupport>()
|
||||
->followSymbolInterface();
|
||||
return instance()->d->m_builtinModelManagerSupport.followSymbolInterface();
|
||||
}
|
||||
|
||||
template<class FilterClass>
|
||||
@@ -551,7 +551,7 @@ Core::ILocatorFilter *CppModelManager::currentDocumentFilter() const
|
||||
|
||||
std::unique_ptr<AbstractOverviewModel> CppModelManager::createOverviewModel() const
|
||||
{
|
||||
return d->m_builtinModelManagerSupport->createOverviewModel();
|
||||
return d->m_builtinModelManagerSupport.createOverviewModel();
|
||||
}
|
||||
|
||||
QString CppModelManager::configurationFileName()
|
||||
@@ -620,13 +620,6 @@ void CppModelManager::initCppTools()
|
||||
std::make_unique<Internal::CppCurrentDocumentFilter>(this));
|
||||
}
|
||||
|
||||
void CppModelManager::initializeBuiltinModelManagerSupport()
|
||||
{
|
||||
d->m_builtinModelManagerSupport
|
||||
= BuiltinModelManagerSupportProvider().createModelManagerSupport();
|
||||
d->m_activeModelManagerSupport = d->m_builtinModelManagerSupport;
|
||||
}
|
||||
|
||||
CppModelManager::CppModelManager()
|
||||
: CppModelManagerBase(nullptr)
|
||||
, d(new CppModelManagerPrivate)
|
||||
@@ -691,8 +684,6 @@ CppModelManager::CppModelManager()
|
||||
qRegisterMetaType<QList<Document::DiagnosticMessage>>(
|
||||
"QList<CPlusPlus::Document::DiagnosticMessage>");
|
||||
|
||||
initializeBuiltinModelManagerSupport();
|
||||
|
||||
d->m_internalIndexingSupport = new BuiltinIndexingSupport;
|
||||
|
||||
initCppTools();
|
||||
@@ -1308,7 +1299,7 @@ bool CppModelManager::usesClangd(const TextEditor::TextDocument *document)
|
||||
|
||||
bool CppModelManager::isClangCodeModelActive() const
|
||||
{
|
||||
return d->m_activeModelManagerSupport != d->m_builtinModelManagerSupport;
|
||||
return d->m_activeModelManagerSupport != &d->m_builtinModelManagerSupport;
|
||||
}
|
||||
|
||||
void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||
@@ -1639,21 +1630,20 @@ void CppModelManager::finishedRefreshingSourceFiles(const QSet<QString> &files)
|
||||
}
|
||||
|
||||
void CppModelManager::activateClangCodeModel(
|
||||
ModelManagerSupportProvider *modelManagerSupportProvider)
|
||||
std::unique_ptr<ModelManagerSupport> &&modelManagerSupport)
|
||||
{
|
||||
QTC_ASSERT(modelManagerSupportProvider, return);
|
||||
|
||||
d->m_activeModelManagerSupport = modelManagerSupportProvider->createModelManagerSupport();
|
||||
d->m_extendedModelManagerSupport = std::move(modelManagerSupport);
|
||||
d->m_activeModelManagerSupport = d->m_extendedModelManagerSupport.get();
|
||||
}
|
||||
|
||||
CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const
|
||||
{
|
||||
return d->m_builtinModelManagerSupport->completionAssistProvider();
|
||||
return d->m_builtinModelManagerSupport.completionAssistProvider();
|
||||
}
|
||||
|
||||
TextEditor::BaseHoverHandler *CppModelManager::createHoverHandler() const
|
||||
{
|
||||
return d->m_builtinModelManagerSupport->createHoverHandler();
|
||||
return d->m_builtinModelManagerSupport.createHoverHandler();
|
||||
}
|
||||
|
||||
void CppModelManager::followSymbol(const CursorInEditor &data,
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Core {
|
||||
class IDocument;
|
||||
class IEditor;
|
||||
@@ -177,7 +179,7 @@ public:
|
||||
|
||||
void finishedRefreshingSourceFiles(const QSet<QString> &files);
|
||||
|
||||
void activateClangCodeModel(ModelManagerSupportProvider *modelManagerSupportProvider);
|
||||
void activateClangCodeModel(std::unique_ptr<ModelManagerSupport> &&modelManagerSupport);
|
||||
CppCompletionAssistProvider *completionAssistProvider() const;
|
||||
BaseEditorDocumentProcessor *createEditorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) const;
|
||||
@@ -291,7 +293,6 @@ private:
|
||||
void onCoreAboutToClose();
|
||||
void setupFallbackProjectPart();
|
||||
|
||||
void initializeBuiltinModelManagerSupport();
|
||||
void delayedGC();
|
||||
void recalculateProjectPartMappings();
|
||||
|
||||
|
||||
@@ -76,15 +76,4 @@ public:
|
||||
virtual void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit) = 0;
|
||||
};
|
||||
|
||||
class CPPEDITOR_EXPORT ModelManagerSupportProvider
|
||||
{
|
||||
public:
|
||||
virtual ~ModelManagerSupportProvider() = default;
|
||||
|
||||
virtual QString id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
|
||||
virtual ModelManagerSupport::Ptr createModelManagerSupport() = 0;
|
||||
};
|
||||
|
||||
} // CppEditor namespace
|
||||
|
||||
Reference in New Issue
Block a user