Commit 9246e78d authored by Erik Verbruggen's avatar Erik Verbruggen

C++: started to make indexing plug-able.

Change-Id: Iff35840d73882a212dd77b54e4223c0b4111ac1c
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 80b73725
......@@ -58,6 +58,7 @@ namespace CppTools {
class CppCompletionAssistProvider;
class CppHighlightingSupport;
class CppHighlightingSupportFactory;
class CppIndexingSupport;
}
namespace CPlusPlus {
......@@ -220,6 +221,8 @@ public:
virtual CppTools::CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const = 0;
virtual void setHighlightingSupportFactory(CppTools::CppHighlightingSupportFactory *highlightingFactory) = 0;
virtual void addIndexingSupport(CppTools::CppIndexingSupport *indexingSupport) = 0;
Q_SIGNALS:
void documentUpdated(CPlusPlus::Document::Ptr doc);
void sourceFilesRefreshed(const QStringList &files);
......
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cppindexingsupport.h"
namespace CppTools {
CppIndexingSupport::~CppIndexingSupport()
{
}
} // namespace CppTools
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPTOOLS_CPPINDEXINGSUPPORT_H
#define CPPTOOLS_CPPINDEXINGSUPPORT_H
#include "cpptools_global.h"
#include <QFuture>
#include <QStringList>
namespace CppTools {
class CPPTOOLS_EXPORT CppIndexingSupport
{
public:
virtual ~CppIndexingSupport() = 0;
virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles) = 0;
};
} // namespace CppTools
#endif // CPPTOOLS_CPPINDEXINGSUPPORT_H
This diff is collapsed.
......@@ -96,8 +96,6 @@ public:
virtual CPlusPlus::Snapshot snapshot() const;
virtual void GC();
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
virtual bool isCppEditor(Core::IEditor *editor) const;
CppEditorSupport *editorSupport(TextEditor::ITextEditor *editor) const
......@@ -133,30 +131,7 @@ public:
virtual CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const;
virtual void setHighlightingSupportFactory(CppHighlightingSupportFactory *highlightingFactory);
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
void aboutToRemoveFiles(const QStringList &files);
public Q_SLOTS:
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
virtual void updateModifiedSourceFiles();
private Q_SLOTS:
// this should be executed in the GUI thread.
void onDocumentUpdated(CPlusPlus::Document::Ptr doc);
void onExtraDiagnosticsUpdated(const QString &fileName);
void onAboutToRemoveProject(ProjectExplorer::Project *project);
void onAboutToUnloadSession();
void onProjectAdded(ProjectExplorer::Project *project);
void postEditorUpdate();
void updateEditorSelections();
private:
void updateEditor(CPlusPlus::Document::Ptr doc);
WorkingCopy buildWorkingCopyList();
virtual void addIndexingSupport(CppIndexingSupport *indexingSupport);
QStringList projectFiles()
{
......@@ -182,16 +157,37 @@ private:
return m_definedMacros;
}
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
void aboutToRemoveFiles(const QStringList &files);
public Q_SLOTS:
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
virtual void updateModifiedSourceFiles();
private Q_SLOTS:
// this should be executed in the GUI thread.
void onDocumentUpdated(CPlusPlus::Document::Ptr doc);
void onExtraDiagnosticsUpdated(const QString &fileName);
void onAboutToRemoveProject(ProjectExplorer::Project *project);
void onAboutToUnloadSession();
void onProjectAdded(ProjectExplorer::Project *project);
void postEditorUpdate();
void updateEditorSelections();
private:
void updateEditor(CPlusPlus::Document::Ptr doc);
WorkingCopy buildWorkingCopyList();
void ensureUpdated();
QStringList internalProjectFiles() const;
QStringList internalIncludePaths() const;
QStringList internalFrameworkPaths() const;
QByteArray internalDefinedMacros() const;
static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc,
QStringList files);
private:
static QMutex m_modelManagerMutex;
static CppModelManager *m_modelManagerInstance;
......@@ -233,12 +229,8 @@ private:
QTimer *m_updateEditorSelectionsTimer;
QFutureSynchronizer<void> m_synchronizer;
unsigned m_revision;
CppFindReferences *m_findReferences;
bool m_indexerEnabled;
bool m_dumpFileNameWhileParsing;
mutable QMutex protectExtraDiagnostics;
QHash<QString, QHash<int, QList<CPlusPlus::Document::DiagnosticMessage> > > m_extraDiagnostics;
......@@ -249,6 +241,8 @@ private:
CppCompletionAssistProvider *m_completionFallback;
CppHighlightingSupportFactory *m_highlightingFactory;
CppHighlightingSupportFactory *m_highlightingFallback;
QList<CppIndexingSupport *> m_indexingSupporters;
CppIndexingSupport *m_internalIndexingSupport;
};
class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client
......
......@@ -47,7 +47,8 @@ HEADERS += completionsettingspage.h \
cppsemanticinfo.h \
cppcompletionassistprovider.h \
ModelManagerInterface.h \
TypeHierarchyBuilder.h
TypeHierarchyBuilder.h \
cppindexingsupport.h
SOURCES += completionsettingspage.cpp \
cppclassesfilter.cpp \
......@@ -86,7 +87,8 @@ SOURCES += completionsettingspage.cpp \
cppsemanticinfo.cpp \
cppcompletionassistprovider.cpp \
ModelManagerInterface.cpp \
TypeHierarchyBuilder.cpp
TypeHierarchyBuilder.cpp \
cppindexingsupport.cpp
FORMS += completionsettingspage.ui \
cppfilesettingspage.ui \
......
......@@ -124,7 +124,7 @@ void CppEditorSupport::updateDocumentNow()
QStringList sourceFiles(_textEditor->document()->fileName());
_cachedContents = _textEditor->contents().toUtf8();
_documentParser = _modelManager->refreshSourceFiles(sourceFiles);
_documentParser = _modelManager->updateSourceFiles(sourceFiles);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment