forked from qt-creator/qt-creator
C++: make highlighting/completion plugable.
Change-Id: I990fdf5411153041c6b4c62f31b453342d59de53 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -34,6 +34,10 @@
|
||||
#include <cplusplus/Overview.h>
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cppcompletionsupport.h"
|
||||
#include "cppcompletionsupportinternal.h"
|
||||
#include "cpphighlightingsupport.h"
|
||||
#include "cpphighlightingsupportinternal.h"
|
||||
#include "abstracteditorsupport.h"
|
||||
#ifndef ICHECK_BUILD
|
||||
# include "cpptoolsconstants.h"
|
||||
@@ -730,10 +734,18 @@ CppModelManager::CppModelManager(QObject *parent)
|
||||
|
||||
connect(Core::ICore::editorManager(), SIGNAL(editorAboutToClose(Core::IEditor *)),
|
||||
this, SLOT(editorAboutToClose(Core::IEditor *)));
|
||||
|
||||
m_completionFallback = new CppCompletionSupportInternalFactory;
|
||||
m_completionFactory = m_completionFallback;
|
||||
m_highlightingFallback = new CppHighlightingSupportInternalFactory;
|
||||
m_highlightingFactory = m_highlightingFallback;
|
||||
}
|
||||
|
||||
CppModelManager::~CppModelManager()
|
||||
{ }
|
||||
{
|
||||
delete m_completionFallback;
|
||||
delete m_highlightingFallback;
|
||||
}
|
||||
|
||||
Snapshot CppModelManager::snapshot() const
|
||||
{
|
||||
@@ -1395,20 +1407,36 @@ void CppModelManager::finishedRefreshingSourceFiles(const QStringList &files)
|
||||
|
||||
CppCompletionSupport *CppModelManager::completionSupport(Core::IEditor *editor) const
|
||||
{
|
||||
if (CppEditorSupport *es = editorSupport(qobject_cast<TextEditor::ITextEditor *>(editor)))
|
||||
return es->completionSupport();
|
||||
if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor))
|
||||
return m_completionFactory->completionSupport(textEditor);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CppModelManager::setCompletionSupportFactory(CppCompletionSupportFactory *completionFactory)
|
||||
{
|
||||
if (completionFactory)
|
||||
m_completionFactory = completionFactory;
|
||||
else
|
||||
m_completionFactory = m_completionFallback;
|
||||
}
|
||||
|
||||
CppHighlightingSupport *CppModelManager::highlightingSupport(Core::IEditor *editor) const
|
||||
{
|
||||
if (CppEditorSupport *es = editorSupport(qobject_cast<TextEditor::ITextEditor *>(editor)))
|
||||
return es->highlightingSupport();
|
||||
if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor))
|
||||
return m_highlightingFactory->highlightingSupport(textEditor);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CppModelManager::setHighlightingSupportFactory(CppHighlightingSupportFactory *highlightingFactory)
|
||||
{
|
||||
if (highlightingFactory)
|
||||
m_highlightingFactory = highlightingFactory;
|
||||
else
|
||||
m_highlightingFactory = m_highlightingFallback;
|
||||
}
|
||||
|
||||
void CppModelManager::setExtraDiagnostics(const QString &fileName, int kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics)
|
||||
{
|
||||
|
Reference in New Issue
Block a user