Commit 48952084 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Remove per-mimetype settings

Related to

    commit c47079f97f7d42db0c581525a2ce6fddbc0995f2
    Clang: Activate the code model with a check box

Change-Id: Ief11768ba0dd27788032e2dd3ad9b7ae39a8f52b
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 140b3948
......@@ -94,7 +94,7 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
pchManager, &PchManager::onProjectPartsUpdated);
// Register ModelManagerSupportProvider
cppModelManager->addModelManagerSupportProvider(&m_modelManagerSupportProvider);
cppModelManager->setClangModelManagerSupportProvider(&m_modelManagerSupportProvider);
initializeTextMarks();
......
......@@ -174,13 +174,8 @@ void ModelManagerSupportClang::onEditorOpened(Core::IEditor *editor)
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(document);
if (textDocument && cppModelManager()->isCppEditor(editor)) {
const QString clangSupportId = QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID);
if (cppModelManager()->isManagedByModelManagerSupport(textDocument, clangSupportId)) {
connectTextDocumentToTranslationUnit(textDocument);
connectToWidgetsMarkContextMenuRequested(editor->widget());
} else {
connectTextDocumentToUnsavedFiles(textDocument);
}
connectTextDocumentToTranslationUnit(textDocument);
connectToWidgetsMarkContextMenuRequested(editor->widget());
// TODO: Ensure that not fully loaded documents are updated?
}
......
......@@ -55,7 +55,7 @@ static const QLatin1Char kDoubleQuote('"');
static const QLatin1Char kNewLine('\n');
static const QLatin1Char kHorizontalTab('\t');
const char CLANG_MODELMANAGERSUPPORT_ID[] = "ClangCodeMode.ClangCodeMode";
const char CLANG_MODELMANAGERSUPPORT_ID[] = "ClangCodeModel.ClangCodeModel";
const char CLANG_ERROR[] = "Clang.Error";
const char CLANG_WARNING[] = "Clang.Warning";
......
......@@ -35,13 +35,11 @@
#include "../clangmodelmanagersupport.h"
#include <clangcodemodel/clangeditordocumentprocessor.h>
#include <clangcodemodel/constants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icore.h>
#include <cpptools/cppcodemodelsettings.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolsreuse.h>
#include <cpptools/cpptoolstestcase.h>
#include <cpptools/modelmanagertesthelper.h>
......@@ -857,7 +855,7 @@ private:
ActivateClangModelManagerSupport();
CppCodeModelSettingsPtr m_codeModelSettings;
QHash<QString, QString> m_previousValues;
bool m_clangCodeModelWasUsedPreviously;
};
ActivateClangModelManagerSupport::ActivateClangModelManagerSupport(
......@@ -865,22 +863,16 @@ ActivateClangModelManagerSupport::ActivateClangModelManagerSupport(
: m_codeModelSettings(codeModelSettings)
{
QTC_CHECK(m_codeModelSettings);
const QString clangModelManagerSupportId
= QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID);
foreach (const QString &mimeType, CppTools::CppCodeModelSettings::supportedMimeTypes()) {
m_previousValues.insert(mimeType,
m_codeModelSettings->modelManagerSupportIdForMimeType(mimeType));
m_codeModelSettings->setModelManagerSupportIdForMimeType(mimeType,
clangModelManagerSupportId);
}
m_clangCodeModelWasUsedPreviously = m_codeModelSettings->useClangCodeModel();
m_codeModelSettings->setUseClangCodeModel(true);
m_codeModelSettings->emitChanged();
}
ActivateClangModelManagerSupport::~ActivateClangModelManagerSupport()
{
QHash<QString, QString>::const_iterator i = m_previousValues.constBegin();
for (; i != m_previousValues.end(); ++i)
m_codeModelSettings->setModelManagerSupportIdForMimeType(i.key(), i.value());
m_codeModelSettings->setUseClangCodeModel(m_clangCodeModelWasUsedPreviously);
m_codeModelSettings->emitChanged();
}
......
......@@ -61,8 +61,6 @@ const char CPP_SNIPPETS_GROUP_ID[] = "C++";
const char CPP_PREPROCESSOR_PROJECT_PREFIX[] = "CppPreprocessorProject-";
const char CLANG_MODELMANAGERSUPPORT_ID[] = "ClangCodeMode.ClangCodeMode";
} // namespace Constants
} // namespace CppEditor
......
......@@ -181,7 +181,7 @@ void CppEditorDocument::onMimeTypeChanged()
const QString &mt = mimeType();
m_isObjCEnabled = (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
m_completionAssistProvider = mm()->completionAssistProvider(mt);
m_completionAssistProvider = mm()->completionAssistProvider();
initializeTimer();
}
......@@ -292,7 +292,7 @@ void CppEditorDocument::releaseResources()
void CppEditorDocument::initializeTimer()
{
m_processorTimer.setSingleShot(true);
if (mm()->isManagedByModelManagerSupport(this, QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID)))
if (mm()->isClangCodeModelActive())
m_processorTimer.setInterval(clangProcessDocumentIntervalInMs);
else
m_processorTimer.setInterval(processDocumentIntervalInMs);
......
......@@ -29,23 +29,22 @@
****************************************************************************/
#include "cppcodemodelsettings.h"
#include "cppmodelmanagersupport.h"
#include "cpptoolsconstants.h"
#include <QSettings>
using namespace CppTools;
static QLatin1String cppHeaderMimeType(Constants::CPP_HEADER_MIMETYPE);
static QLatin1String cHeaderMimeType(Constants::C_HEADER_MIMETYPE);
static QLatin1String clangExtraOptionsKey(Constants::CPPTOOLS_EXTRA_CLANG_OPTIONS);
static QLatin1String useClangCodeModelKey(Constants::CPPTOOLS_USE_CLANG_CODE_MODEL);
void CppCodeModelSettings::fromSettings(QSettings *s)
{
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
QVariant supporters = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY));
foreach (const QString &mimeType, supportedMimeTypes())
setIdForMimeType(supporters, mimeType);
setUseClangCodeModel(s->value(useClangCodeModelKey, false).toBool());
setExtraClangOptions(s->value(clangExtraOptionsKey, defaultExtraClangOptions()).toStringList());
QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None);
......@@ -58,66 +57,24 @@ void CppCodeModelSettings::fromSettings(QSettings *s)
void CppCodeModelSettings::toSettings(QSettings *s)
{
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
QHash<QString, QVariant> var;
foreach (const QString &mimeType, m_modelManagerSupportByMimeType.keys())
var[mimeType] = m_modelManagerSupportByMimeType[mimeType];
s->setValue(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY), QVariant(var));
s->setValue(useClangCodeModelKey, useClangCodeModel());
s->setValue(clangExtraOptionsKey, extraClangOptions());
s->setValue(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), pchUsage());
s->endGroup();
emit changed();
}
QStringList CppCodeModelSettings::supportedMimeTypes()
{
return QStringList({
QLatin1String(Constants::C_SOURCE_MIMETYPE),
QLatin1String(Constants::CPP_SOURCE_MIMETYPE),
QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE),
QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE),
QLatin1String(Constants::CPP_HEADER_MIMETYPE)
});
}
s->endGroup();
void CppCodeModelSettings::emitChanged()
{
emit changed();
}
void CppCodeModelSettings::setModelManagerSupportProviders(
const QList<ModelManagerSupportProvider *> &providers)
bool CppCodeModelSettings::useClangCodeModel() const
{
m_modelManagerSupportsByName.clear();
foreach (ModelManagerSupportProvider *provider, providers)
m_modelManagerSupportsByName[provider->displayName()] = provider->id();
return m_useClangCodeModel;
}
QString CppCodeModelSettings::modelManagerSupportIdForMimeType(const QString &mimeType) const
void CppCodeModelSettings::setUseClangCodeModel(bool useClangCodeModel)
{
if (mimeType == cHeaderMimeType)
return m_modelManagerSupportByMimeType.value(cppHeaderMimeType);
else
return m_modelManagerSupportByMimeType.value(mimeType);
}
void CppCodeModelSettings::setModelManagerSupportIdForMimeType(const QString &mimeType,
const QString &id)
{
QString theMimeType = mimeType;
if (theMimeType == cHeaderMimeType)
theMimeType = cppHeaderMimeType;
m_modelManagerSupportByMimeType.insert(theMimeType, id);
}
bool CppCodeModelSettings::hasModelManagerSupportIdForMimeType(const QString &mimeType,
const QString &id) const
{
if (mimeType == cHeaderMimeType)
return m_modelManagerSupportByMimeType.value(cppHeaderMimeType) == id;
else
return m_modelManagerSupportByMimeType.value(mimeType) == id;
m_useClangCodeModel = useClangCodeModel;
}
QStringList CppCodeModelSettings::defaultExtraClangOptions()
......@@ -147,8 +104,17 @@ void CppCodeModelSettings::setExtraClangOptions(const QStringList &extraClangOpt
m_extraClangOptions = extraClangOptions;
}
void CppCodeModelSettings::setIdForMimeType(const QVariant &var, const QString &mimeType)
CppCodeModelSettings::PCHUsage CppCodeModelSettings::pchUsage() const
{
QHash<QString, QVariant> mimeToId = var.toHash();
m_modelManagerSupportByMimeType[mimeType] = mimeToId.value(mimeType, defaultId()).toString();
return m_pchUsage;
}
void CppCodeModelSettings::setPCHUsage(CppCodeModelSettings::PCHUsage pchUsage)
{
m_pchUsage = pchUsage;
}
void CppCodeModelSettings::emitChanged()
{
emit changed();
}
......@@ -33,14 +33,14 @@
#include "cpptools_global.h"
#include <QHash>
#include <QList>
#include <QSettings>
#include <QString>
#include <QObject>
#include <QStringList>
namespace CppTools {
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
class ModelManagerSupportProvider;
namespace CppTools {
class CPPTOOLS_EXPORT CppCodeModelSettings : public QObject
{
......@@ -53,34 +53,19 @@ public:
};
public:
CppCodeModelSettings(): m_pchUsage(PchUse_None) {}
void fromSettings(QSettings *s);
void toSettings(QSettings *s);
void setModelManagerSupportProviders(const QList<ModelManagerSupportProvider *> &supporters);
QString modelManagerSupportIdForMimeType(const QString &mimeType) const;
void setModelManagerSupportIdForMimeType(const QString &mimeType, const QString &id);
bool hasModelManagerSupportIdForMimeType(const QString &mimeType, const QString &id) const;
const QHash<QString, QString> &availableModelManagerSupportProvidersByName() const
{ return m_modelManagerSupportsByName; }
QString defaultId() const
{ return m_defaultId; }
void setDefaultId(const QString &defaultId)
{ m_defaultId = defaultId; }
public:
bool useClangCodeModel() const;
void setUseClangCodeModel(bool useClangCodeModel);
static QStringList defaultExtraClangOptions();
QStringList extraClangOptions() const;
void setExtraClangOptions(const QStringList &extraClangOptions);
PCHUsage pchUsage() const { return m_pchUsage; }
void setPCHUsage(PCHUsage pchUsage) { m_pchUsage = pchUsage; }
static QStringList supportedMimeTypes();
PCHUsage pchUsage() const;
void setPCHUsage(PCHUsage pchUsage);
public: // for tests
void emitChanged();
......@@ -89,14 +74,10 @@ signals:
void changed();
private:
void setIdForMimeType(const QVariant &var, const QString &mimeType);
private:
QHash<QString, QString> m_modelManagerSupportByMimeType;
QHash<QString, QString> m_modelManagerSupportsByName;
bool m_isClangCodeModelAvailable = false;
bool m_useClangCodeModel = false;
QStringList m_extraClangOptions;
QString m_defaultId;
PCHUsage m_pchUsage;
PCHUsage m_pchUsage = PchUse_None;
};
} // namespace CppTools
......
......@@ -29,6 +29,7 @@
****************************************************************************/
#include "cppcodemodelsettingspage.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include "ui_cppcodemodelsettingspage.h"
......@@ -85,19 +86,12 @@ void CppCodeModelSettingsWidget::applyToSettings() const
m_settings->toSettings(Core::ICore::settings());
}
static bool isClangCodeModelActive(const CppCodeModelSettings &settings)
{
const QString currentCodeModelId
= settings.modelManagerSupportIdForMimeType(QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
return currentCodeModelId != settings.defaultId();
}
void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const
{
bool isClangActive = false;
const bool isClangAvailable = m_settings->availableModelManagerSupportProvidersByName().size() > 1;
const bool isClangAvailable = CppModelManager::instance()->isClangCodeModelAvailable();
if (isClangAvailable)
isClangActive = isClangCodeModelActive(*m_settings.data());
isClangActive = m_settings->useClangCodeModel();
m_ui->activateClangCodeModelPluginHint->setVisible(!isClangAvailable);
m_ui->clangSettingsGroupBox->setEnabled(isClangAvailable);
......@@ -109,23 +103,25 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const
bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
{
// Once the underlying settings are not mime type based anymore, simplify here.
// Until then, ensure that the settings are set uniformly for all the mime types
// to avoid surprises.
bool settingsChanged = false;
const QString activeCodeModelId = m_ui->clangSettingsGroupBox->isChecked()
? QLatin1String("ClangCodeMode.ClangCodeMode")
: QLatin1String("CppTools.BuiltinCodeModel");
foreach (const QString &mimeType, m_settings->supportedMimeTypes())
m_settings->setModelManagerSupportIdForMimeType(mimeType, activeCodeModelId);
const bool previouslyClangWasActive = m_settings->useClangCodeModel();
const bool nowClangIsActive = m_ui->clangSettingsGroupBox->isChecked();
if (nowClangIsActive != previouslyClangWasActive) {
m_settings->setUseClangCodeModel(nowClangIsActive);
settingsChanged = true;
}
const QString clangOptionsText = m_ui->clangOptionsToAppendTextEdit->document()->toPlainText();
const QStringList extraClangOptions = clangOptionsText.split(QLatin1Char('\n'),
QString::SkipEmptyParts);
m_settings->setExtraClangOptions(extraClangOptions);
const QStringList previousOptions = m_settings->extraClangOptions();
const QString newOptionsAsString = m_ui->clangOptionsToAppendTextEdit->document()->toPlainText();
const QStringList newOptions = newOptionsAsString.split(QLatin1Char('\n'),
QString::SkipEmptyParts);
if (newOptions != previousOptions) {
m_settings->setExtraClangOptions(newOptions);
settingsChanged = true;
}
return true;
return settingsChanged;
}
CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
......
......@@ -151,11 +151,10 @@ public:
QMap<QString, CppEditorDocumentHandle *> m_cppEditorDocuments;
QSet<AbstractEditorSupport *> m_extraEditorSupports;
// Completion & highlighting
ModelManagerSupportProviderInternal m_modelManagerSupportInternalProvider;
ModelManagerSupport::Ptr m_modelManagerSupportInternal;
QHash<QString, ModelManagerSupportProvider *> m_availableModelManagerSupports;
QHash<QString, ModelManagerSupport::Ptr> m_activeModelManagerSupports;
// Model Manager Supports for e.g. completion and highlighting
ModelManagerSupportProvider *m_clangModelManagerSupportProvider;
ModelManagerSupport::Ptr m_builtinModelManagerSupport;
ModelManagerSupport::Ptr m_activeModelManagerSupport;
// Indexing
CppIndexingSupport *m_indexingSupporter;
......@@ -293,6 +292,14 @@ CppModelManager *CppModelManager::instance()
return m_instance;
}
void CppModelManager::initializeModelManagerSupports()
{
d->m_clangModelManagerSupportProvider = nullptr;
d->m_builtinModelManagerSupport
= ModelManagerSupportProviderInternal().createModelManagerSupport();
d->m_activeModelManagerSupport = d->m_builtinModelManagerSupport;
}
CppModelManager::CppModelManager(QObject *parent)
: CppModelManagerBase(parent), d(new CppModelManagerPrivate)
{
......@@ -337,15 +344,10 @@ CppModelManager::CppModelManager(QObject *parent)
QSharedPointer<CppCodeModelSettings> codeModelSettings
= CppToolsPlugin::instance()->codeModelSettings();
codeModelSettings->setDefaultId(d->m_modelManagerSupportInternalProvider.id());
connect(codeModelSettings.data(), &CppCodeModelSettings::changed,
this, &CppModelManager::onCodeModelSettingsChanged);
d->m_modelManagerSupportInternal
= d->m_modelManagerSupportInternalProvider.createModelManagerSupport();
d->m_activeModelManagerSupports.insert(d->m_modelManagerSupportInternalProvider.id(),
d->m_modelManagerSupportInternal);
addModelManagerSupportProvider(&d->m_modelManagerSupportInternalProvider);
initializeModelManagerSupports();
d->m_internalIndexingSupport = new BuiltinIndexingSupport;
}
......@@ -665,31 +667,6 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
}
}
void CppModelManager::handleAddedModelManagerSupports(const QSet<QString> &supportIds)
{
foreach (const QString &id, supportIds) {
ModelManagerSupportProvider * const provider = d->m_availableModelManagerSupports.value(id);
if (provider) {
QTC_CHECK(!d->m_activeModelManagerSupports.contains(id));
d->m_activeModelManagerSupports.insert(id, provider->createModelManagerSupport());
}
}
}
QList<ModelManagerSupport::Ptr> CppModelManager::handleRemovedModelManagerSupports(
const QSet<QString> &supportIds)
{
QList<ModelManagerSupport::Ptr> removed;
foreach (const QString &id, supportIds) {
const ModelManagerSupport::Ptr support = d->m_activeModelManagerSupports.value(id);
d->m_activeModelManagerSupports.remove(id);
removed << support;
}
return removed;
}
void CppModelManager::closeCppEditorDocuments()
{
QList<Core::IDocument *> cppDocumentsToClose;
......@@ -964,12 +941,15 @@ bool CppModelManager::isCppEditor(Core::IEditor *editor) const
return editor->context().contains(ProjectExplorer::Constants::LANG_CXX);
}
bool CppModelManager::isManagedByModelManagerSupport(Core::IDocument *document, const QString &id) const
bool CppModelManager::isClangCodeModelAvailable() const
{
auto documentMimeTupe = document->mimeType();
auto codeModelSettings = CppToolsPlugin::instance()->codeModelSettings();
return d->m_clangModelManagerSupportProvider != nullptr;
}
return codeModelSettings->hasModelManagerSupportIdForMimeType(documentMimeTupe, id);
bool CppModelManager::isClangCodeModelActive() const
{
return isClangCodeModelAvailable()
&& d->m_activeModelManagerSupport != d->m_builtinModelManagerSupport;
}
void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
......@@ -1053,43 +1033,25 @@ void CppModelManager::onCurrentEditorChanged(Core::IEditor *editor)
}
}
static const QSet<QString> activeModelManagerSupportsFromSettings()
{
QSet<QString> result;
QSharedPointer<CppCodeModelSettings> codeModelSettings
= CppToolsPlugin::instance()->codeModelSettings();
const QStringList mimeTypes = codeModelSettings->supportedMimeTypes();
foreach (const QString &mimeType, mimeTypes) {
const QString id = codeModelSettings->modelManagerSupportIdForMimeType(mimeType);
if (!id.isEmpty())
result << id;
}
return result;
}
void CppModelManager::onCodeModelSettingsChanged()
{
const QSet<QString> currentCodeModelSupporters = d->m_activeModelManagerSupports.keys().toSet();
const QSet<QString> newCodeModelSupporters = activeModelManagerSupportsFromSettings();
const bool isClangActive = isClangCodeModelActive();
const QSharedPointer<CppCodeModelSettings> settings
= CppToolsPlugin::instance()->codeModelSettings();
QSet<QString> added = newCodeModelSupporters;
added.subtract(currentCodeModelSupporters);
added.remove(d->m_modelManagerSupportInternalProvider.id());
handleAddedModelManagerSupports(added);
ModelManagerSupport::Ptr newCodeModelSupport;
QSet<QString> removed = currentCodeModelSupporters;
removed.subtract(newCodeModelSupporters);
removed.remove(d->m_modelManagerSupportInternalProvider.id());
const QList<ModelManagerSupport::Ptr> supportsToDelete
= handleRemovedModelManagerSupports(removed);
QTC_CHECK(removed.size() == supportsToDelete.size());
if (isClangCodeModelAvailable()) {
if (!isClangActive && settings->useClangCodeModel())
newCodeModelSupport = d->m_clangModelManagerSupportProvider->createModelManagerSupport();
else if (isClangActive && !settings->useClangCodeModel())
newCodeModelSupport = d->m_builtinModelManagerSupport;
}
if (!added.isEmpty() || !removed.isEmpty())
if (newCodeModelSupport) {
closeCppEditorDocuments();
// supportsToDelete goes out of scope and deletes the supports
d->m_activeModelManagerSupport = newCodeModelSupport;
}
}
void CppModelManager::onAboutToLoadSession()
......@@ -1201,44 +1163,26 @@ void CppModelManager::finishedRefreshingSourceFiles(const QSet<QString> &files)
emit sourceFilesRefreshed(files);
}
void CppModelManager::addModelManagerSupportProvider(
void CppModelManager::setClangModelManagerSupportProvider(
ModelManagerSupportProvider *modelManagerSupportProvider)
{
QTC_ASSERT(modelManagerSupportProvider, return);
d->m_availableModelManagerSupports[modelManagerSupportProvider->id()]
= modelManagerSupportProvider;
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
cms->setModelManagerSupportProviders(d->m_availableModelManagerSupports.values());
QTC_CHECK(d->m_clangModelManagerSupportProvider == nullptr);
onCodeModelSettingsChanged();
}
d->m_clangModelManagerSupportProvider = modelManagerSupportProvider;
ModelManagerSupport::Ptr CppModelManager::modelManagerSupportForMimeType(
const QString &mimeType) const
{
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
const QString &id = cms->modelManagerSupportIdForMimeType(mimeType);
return d->m_activeModelManagerSupports.value(id, d->m_modelManagerSupportInternal);
onCodeModelSettingsChanged();
}
CppCompletionAssistProvider *CppModelManager::completionAssistProvider(
const QString &mimeType) const
CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const
{
if (mimeType.isEmpty())
return 0;
ModelManagerSupport::Ptr cms = modelManagerSupportForMimeType(mimeType);
QTC_ASSERT(cms, return 0);
return cms->completionAssistProvider();
return d->m_activeModelManagerSupport->completionAssistProvider();
}
BaseEditorDocumentProcessor *CppModelManager::editorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) const
{
QTC_ASSERT(baseTextDocument, return 0);
ModelManagerSupport::Ptr cms = modelManagerSupportForMimeType(baseTextDocument->mimeType());
QTC_ASSERT(cms, return 0);
return cms->editorDocumentProcessor(baseTextDocument);
return d->m_activeModelManagerSupport->editorDocumentProcessor(baseTextDocument);
}
void CppModelManager::setIndexingSupport(CppIndexingSupport *indexingSupport)
......
......@@ -121,7 +121,8 @@ public:
void emitAbstractEditorSupportRemoved(const QString &filePath);
bool isCppEditor(Core::IEditor *editor) const;
bool isManagedByModelManagerSupport(Core::IDocument *document, const QString &id) const;
bool isClangCodeModelAvailable() const;
bool isClangCodeModelActive() const;
QSet<AbstractEditorSupport*> abstractEditorSupports() const;
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
......@@ -143,8 +144,8 @@ public:
void finishedRefreshingSourceFiles(const QSet<QString> &files);
void addModelManagerSupportProvider(ModelManagerSupportProvider *modelManagerSupportProvider);
CppCompletionAssistProvider *completionAssistProvider(const QString &mimeType) const;
void setClangModelManagerSupportProvider(ModelManagerSupportProvider *modelManagerSupportProvider);
CppCompletionAssistProvider *completionAssistProvider() const;
BaseEditorDocumentProcessor *editorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) const;
......@@ -205,6 +206,7 @@ private slots:
void onCoreAboutToClose();
private:
void initializeModelManagerSupports();