forked from qt-creator/qt-creator
CppTools: Rename SnapshotUpdater to BuiltinEditorDocumentParser
Change-Id: I554b5e9e3f1ef7c167fa45b5cd0c230fdf63073b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
7e71a299ef
commit
7d35212f60
@@ -1362,7 +1362,7 @@ void CppCodeModelInspectorDialog::refresh()
|
|||||||
if (editor) {
|
if (editor) {
|
||||||
editorSupport = cmmi->cppEditorSupport(editor);
|
editorSupport = cmmi->cppEditorSupport(editor);
|
||||||
if (editorSupport) {
|
if (editorSupport) {
|
||||||
const CPlusPlus::Snapshot editorSnapshot = editorSupport->snapshotUpdater()->snapshot();
|
const CPlusPlus::Snapshot editorSnapshot = editorSupport->documentParser()->snapshot();
|
||||||
m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot));
|
m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot));
|
||||||
const QString editorSnapshotTitle
|
const QString editorSnapshotTitle
|
||||||
= QString::fromLatin1("Current Editor's Snapshot (%1 Documents)")
|
= QString::fromLatin1("Current Editor's Snapshot (%1 Documents)")
|
||||||
@@ -1413,7 +1413,7 @@ void CppCodeModelInspectorDialog::refresh()
|
|||||||
|
|
||||||
// Project Parts
|
// Project Parts
|
||||||
const ProjectPart::Ptr editorsProjectPart = editorSupport
|
const ProjectPart::Ptr editorsProjectPart = editorSupport
|
||||||
? editorSupport->snapshotUpdater()->projectPart()
|
? editorSupport->documentParser()->projectPart()
|
||||||
: ProjectPart::Ptr();
|
: ProjectPart::Ptr();
|
||||||
|
|
||||||
const QList<ProjectInfo> projectInfos = cmmi->projectInfos();
|
const QList<ProjectInfo> projectInfos = cmmi->projectInfos();
|
||||||
|
|||||||
@@ -1020,10 +1020,10 @@ void CppEditorWidget::onFilePathChanged()
|
|||||||
additionalDirectives = ProjectExplorer::SessionManager::value(
|
additionalDirectives = ProjectExplorer::SessionManager::value(
|
||||||
projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
|
projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
|
||||||
|
|
||||||
QSharedPointer<SnapshotUpdater> updater
|
QSharedPointer<BuiltinEditorDocumentParser> parser
|
||||||
= d->m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
|
= d->m_modelManager->cppEditorSupport(editor())->documentParser();
|
||||||
updater->setProjectPart(d->m_modelManager->projectPartForProjectFile(projectFile));
|
parser->setProjectPart(d->m_modelManager->projectPartForProjectFile(projectFile));
|
||||||
updater->setEditorDefines(additionalDirectives);
|
parser->setEditorDefines(additionalDirectives);
|
||||||
}
|
}
|
||||||
d->m_preprocessorButton->setProperty("highlightWidget", !additionalDirectives.trimmed().isEmpty());
|
d->m_preprocessorButton->setProperty("highlightWidget", !additionalDirectives.trimmed().isEmpty());
|
||||||
d->m_preprocessorButton->update();
|
d->m_preprocessorButton->update();
|
||||||
@@ -1088,12 +1088,12 @@ void CppEditorWidget::showPreProcessorWidget()
|
|||||||
|
|
||||||
CppPreProcessorDialog preProcessorDialog(this, textDocument()->filePath(), projectParts);
|
CppPreProcessorDialog preProcessorDialog(this, textDocument()->filePath(), projectParts);
|
||||||
if (preProcessorDialog.exec() == QDialog::Accepted) {
|
if (preProcessorDialog.exec() == QDialog::Accepted) {
|
||||||
QSharedPointer<SnapshotUpdater> updater
|
QSharedPointer<BuiltinEditorDocumentParser> parser
|
||||||
= d->m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
|
= d->m_modelManager->cppEditorSupport(editor())->documentParser();
|
||||||
const QString &additionals = preProcessorDialog.additionalPreProcessorDirectives();
|
const QString &additionals = preProcessorDialog.additionalPreProcessorDirectives();
|
||||||
updater->setProjectPart(preProcessorDialog.projectPart());
|
parser->setProjectPart(preProcessorDialog.projectPart());
|
||||||
updater->setEditorDefines(additionals.toUtf8());
|
parser->setEditorDefines(additionals.toUtf8());
|
||||||
updater->update(d->m_modelManager->workingCopy());
|
parser->update(d->m_modelManager->workingCopy());
|
||||||
|
|
||||||
d->m_preprocessorButton->setProperty("highlightWidget", !additionals.trimmed().isEmpty());
|
d->m_preprocessorButton->setProperty("highlightWidget", !additionals.trimmed().isEmpty());
|
||||||
d->m_preprocessorButton->update();
|
d->m_preprocessorButton->update();
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ void CppIncludeHierarchyModel::buildHierarchyIncludes_helper(const QString &file
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CppModelManagerInterface *cppMM = CppModelManagerInterface::instance();
|
CppModelManagerInterface *cppMM = CppModelManagerInterface::instance();
|
||||||
const Snapshot &snapshot = cppMM->cppEditorSupport(m_editor)->snapshotUpdater()->snapshot();
|
const Snapshot &snapshot = cppMM->cppEditorSupport(m_editor)->documentParser()->snapshot();
|
||||||
Document::Ptr doc = snapshot.document(filePath);
|
Document::Ptr doc = snapshot.document(filePath);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cppsnapshotupdater.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -36,14 +36,14 @@ using namespace CPlusPlus;
|
|||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
|
|
||||||
SnapshotUpdater::SnapshotUpdater(const QString &filePath)
|
BuiltinEditorDocumentParser::BuiltinEditorDocumentParser(const QString &filePath)
|
||||||
: BaseEditorDocumentParser(filePath)
|
: BaseEditorDocumentParser(filePath)
|
||||||
, m_forceSnapshotInvalidation(false)
|
, m_forceSnapshotInvalidation(false)
|
||||||
, m_releaseSourceAndAST(true)
|
, m_releaseSourceAndAST(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotUpdater::update(WorkingCopy workingCopy)
|
void BuiltinEditorDocumentParser::update(WorkingCopy workingCopy)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ void SnapshotUpdater::update(WorkingCopy workingCopy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotUpdater::releaseResources()
|
void BuiltinEditorDocumentParser::releaseResources()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_snapshot = Snapshot();
|
m_snapshot = Snapshot();
|
||||||
@@ -197,31 +197,32 @@ void SnapshotUpdater::releaseResources()
|
|||||||
m_forceSnapshotInvalidation = true;
|
m_forceSnapshotInvalidation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Document::Ptr SnapshotUpdater::document() const
|
Document::Ptr BuiltinEditorDocumentParser::document() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
return m_snapshot.document(filePath());
|
return m_snapshot.document(filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
Snapshot SnapshotUpdater::snapshot() const
|
Snapshot BuiltinEditorDocumentParser::snapshot() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
return m_snapshot;
|
return m_snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::HeaderPaths SnapshotUpdater::headerPaths() const
|
ProjectPart::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
return m_headerPaths;
|
return m_headerPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotUpdater::setReleaseSourceAndAST(bool onoff)
|
void BuiltinEditorDocumentParser::setReleaseSourceAndAST(bool onoff)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_releaseSourceAndAST = onoff;
|
m_releaseSourceAndAST = onoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotUpdater::addFileAndDependencies(QSet<QString> *toRemove, const QString &fileName) const
|
void BuiltinEditorDocumentParser::addFileAndDependencies(QSet<QString> *toRemove,
|
||||||
|
const QString &fileName) const
|
||||||
{
|
{
|
||||||
toRemove->insert(fileName);
|
toRemove->insert(fileName);
|
||||||
if (fileName != filePath()) {
|
if (fileName != filePath()) {
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CPPTOOLS_INTERNAL_SNAPSHOTUPDATER_H
|
#ifndef BUILTINEDITORDOCUMENTPARSER_H
|
||||||
#define CPPTOOLS_INTERNAL_SNAPSHOTUPDATER_H
|
#define BUILTINEDITORDOCUMENTPARSER_H
|
||||||
|
|
||||||
#include "baseeditordocumentparser.h"
|
#include "baseeditordocumentparser.h"
|
||||||
#include "cpptools_global.h"
|
#include "cpptools_global.h"
|
||||||
@@ -43,10 +43,10 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT SnapshotUpdater : public BaseEditorDocumentParser
|
class CPPTOOLS_EXPORT BuiltinEditorDocumentParser : public BaseEditorDocumentParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SnapshotUpdater(const QString &filePath);
|
BuiltinEditorDocumentParser(const QString &filePath);
|
||||||
|
|
||||||
void update(WorkingCopy workingCopy) QTC_OVERRIDE;
|
void update(WorkingCopy workingCopy) QTC_OVERRIDE;
|
||||||
void releaseResources();
|
void releaseResources();
|
||||||
@@ -75,4 +75,4 @@ private:
|
|||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|
||||||
#endif // CPPTOOLS_INTERNAL_SNAPSHOTUPDATER_H
|
#endif // BUILTINEDITORDOCUMENTPARSER_H
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "builtinindexingsupport.h"
|
#include "builtinindexingsupport.h"
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppchecksymbols.h"
|
#include "cppchecksymbols.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cppprojectfile.h"
|
#include "cppprojectfile.h"
|
||||||
#include "cppsnapshotupdater.h"
|
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
#include "cpptoolsplugin.h"
|
#include "cpptoolsplugin.h"
|
||||||
@@ -136,17 +136,17 @@ void indexFindErrors(QFutureInterface<void> &future, const ParseParams params)
|
|||||||
qDebug("FindErrorsIndexing: \"%s\"", qPrintable(file));
|
qDebug("FindErrorsIndexing: \"%s\"", qPrintable(file));
|
||||||
|
|
||||||
// Parse the file as precisely as possible
|
// Parse the file as precisely as possible
|
||||||
SnapshotUpdater updater(file);
|
BuiltinEditorDocumentParser parser(file);
|
||||||
updater.setReleaseSourceAndAST(false);
|
parser.setReleaseSourceAndAST(false);
|
||||||
updater.update(params.workingCopy);
|
parser.update(params.workingCopy);
|
||||||
CPlusPlus::Document::Ptr document = updater.document();
|
CPlusPlus::Document::Ptr document = parser.document();
|
||||||
QTC_ASSERT(document, return);
|
QTC_ASSERT(document, return);
|
||||||
|
|
||||||
// Write diagnostic messages
|
// Write diagnostic messages
|
||||||
taskFileWriter.process(document);
|
taskFileWriter.process(document);
|
||||||
|
|
||||||
// Look up symbols
|
// Look up symbols
|
||||||
CPlusPlus::LookupContext context(document, updater.snapshot());
|
CPlusPlus::LookupContext context(document, parser.snapshot());
|
||||||
CheckSymbols::go(document, context, QList<CheckSymbols::Result>()).waitForFinished();
|
CheckSymbols::go(document, context, QList<CheckSymbols::Result>()).waitForFinished();
|
||||||
|
|
||||||
document->releaseSourceAndAST();
|
document->releaseSourceAndAST();
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
#include "cppcompletionassist.h"
|
#include "cppcompletionassist.h"
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppdoxygen.h"
|
#include "cppdoxygen.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cppmodelmanagerinterface.h"
|
#include "cppmodelmanagerinterface.h"
|
||||||
#include "cppsnapshotupdater.h"
|
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
#include "cpptoolseditorsupport.h"
|
#include "cpptoolseditorsupport.h"
|
||||||
#include "cpptoolsreuse.h"
|
#include "cpptoolsreuse.h"
|
||||||
@@ -1959,10 +1959,10 @@ void CppCompletionAssistInterface::getCppSpecifics() const
|
|||||||
|
|
||||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||||
if (CppEditorSupport *supp = modelManager->cppEditorSupport(m_editor)) {
|
if (CppEditorSupport *supp = modelManager->cppEditorSupport(m_editor)) {
|
||||||
if (QSharedPointer<SnapshotUpdater> updater = supp->snapshotUpdater()) {
|
if (QSharedPointer<BuiltinEditorDocumentParser> parser = supp->documentParser()) {
|
||||||
updater->update(m_workingCopy);
|
parser->update(m_workingCopy);
|
||||||
m_snapshot = updater->snapshot();
|
m_snapshot = parser->snapshot();
|
||||||
m_headerPaths = updater->headerPaths();
|
m_headerPaths = parser->headerPaths();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -947,16 +947,15 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
|||||||
while (sup->lastSemanticInfoDocument().isNull())
|
while (sup->lastSemanticInfoDocument().isNull())
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
const QSharedPointer<SnapshotUpdater> updater = sup->snapshotUpdater();
|
sup->documentParser()->setUsePrecompiledHeaders(true);
|
||||||
updater->setUsePrecompiledHeaders(true);
|
sup->documentParser()->update(mm->workingCopy());
|
||||||
updater->update(mm->workingCopy());
|
|
||||||
|
|
||||||
// Check if defines from pch are considered
|
// Check if defines from pch are considered
|
||||||
Document::Ptr document = mm->document(fileName);
|
Document::Ptr document = mm->document(fileName);
|
||||||
QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName);
|
QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName);
|
||||||
|
|
||||||
// Check if declarations from pch are considered
|
// Check if declarations from pch are considered
|
||||||
CPlusPlus::LookupContext context(document, updater->snapshot());
|
CPlusPlus::LookupContext context(document, sup->documentParser()->snapshot());
|
||||||
const CPlusPlus::Identifier *identifier
|
const CPlusPlus::Identifier *identifier
|
||||||
= document->control()->identifier(firstClassInPchFile.data());
|
= document->control()->identifier(firstClassInPchFile.data());
|
||||||
const QList<CPlusPlus::LookupItem> results = context.lookup(identifier,
|
const QList<CPlusPlus::LookupItem> results = context.lookup(identifier,
|
||||||
@@ -1031,8 +1030,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
|||||||
while (sup->lastSemanticInfoDocument().isNull())
|
while (sup->lastSemanticInfoDocument().isNull())
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
sup->snapshotUpdater()->setEditorDefines(editorDefines.toUtf8());
|
sup->documentParser()->setEditorDefines(editorDefines.toUtf8());
|
||||||
sup->snapshotUpdater()->update(mm->workingCopy());
|
sup->documentParser()->update(mm->workingCopy());
|
||||||
|
|
||||||
Document::Ptr doc = mm->document(main1File);
|
Document::Ptr doc = mm->document(main1File);
|
||||||
QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName);
|
QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName);
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
#include "cpptoolsplugin.h"
|
#include "cpptoolsplugin.h"
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cppsourceprocessertesthelper.h"
|
#include "cppsourceprocessertesthelper.h"
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cppsnapshotupdater.h"
|
|
||||||
#include "cpptoolseditorsupport.h"
|
#include "cpptoolseditorsupport.h"
|
||||||
#include "cpptoolstestcase.h"
|
#include "cpptoolstestcase.h"
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
|
|||||||
const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
|
const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
|
||||||
const QStringList sourceFiles = QStringList() << fileName1 << fileName2;
|
const QStringList sourceFiles = QStringList() << fileName1 << fileName2;
|
||||||
|
|
||||||
// Create global snapshot (needed in SnapshotUpdater)
|
// Create global snapshot (needed in BuiltinEditorDocumentParser)
|
||||||
TestCase testCase;
|
TestCase testCase;
|
||||||
testCase.parseFiles(sourceFiles);
|
testCase.parseFiles(sourceFiles);
|
||||||
|
|
||||||
@@ -144,9 +144,10 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
|
|||||||
CppEditorSupport *cppEditorSupport = CppModelManagerInterface::instance()
|
CppEditorSupport *cppEditorSupport = CppModelManagerInterface::instance()
|
||||||
->cppEditorSupport(editor);
|
->cppEditorSupport(editor);
|
||||||
QVERIFY(cppEditorSupport);
|
QVERIFY(cppEditorSupport);
|
||||||
QSharedPointer<SnapshotUpdater> snapshotUpdater = cppEditorSupport->snapshotUpdater();
|
QSharedPointer<BuiltinEditorDocumentParser> documentParser
|
||||||
QVERIFY(snapshotUpdater);
|
= cppEditorSupport->documentParser();
|
||||||
Snapshot snapshot = snapshotUpdater->snapshot();
|
QVERIFY(documentParser);
|
||||||
|
Snapshot snapshot = documentParser->snapshot();
|
||||||
QCOMPARE(snapshot.size(), 3); // Configuration file included
|
QCOMPARE(snapshot.size(), 3); // Configuration file included
|
||||||
|
|
||||||
// Check includes
|
// Check includes
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ include(../../qtcreatorplugin.pri)
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
abstracteditorsupport.h \
|
abstracteditorsupport.h \
|
||||||
baseeditordocumentparser.h \
|
baseeditordocumentparser.h \
|
||||||
|
builtineditordocumentparser.h \
|
||||||
builtinindexingsupport.h \
|
builtinindexingsupport.h \
|
||||||
commentssettings.h \
|
commentssettings.h \
|
||||||
completionsettingspage.h \
|
completionsettingspage.h \
|
||||||
@@ -41,7 +42,6 @@ HEADERS += \
|
|||||||
cppqtstyleindenter.h \
|
cppqtstyleindenter.h \
|
||||||
cpprefactoringchanges.h \
|
cpprefactoringchanges.h \
|
||||||
cppsemanticinfo.h \
|
cppsemanticinfo.h \
|
||||||
cppsnapshotupdater.h \
|
|
||||||
cppsourceprocessor.h \
|
cppsourceprocessor.h \
|
||||||
cpptools_global.h \
|
cpptools_global.h \
|
||||||
cpptoolsconstants.h \
|
cpptoolsconstants.h \
|
||||||
@@ -64,6 +64,7 @@ HEADERS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
abstracteditorsupport.cpp \
|
abstracteditorsupport.cpp \
|
||||||
baseeditordocumentparser.cpp \
|
baseeditordocumentparser.cpp \
|
||||||
|
builtineditordocumentparser.cpp \
|
||||||
builtinindexingsupport.cpp \
|
builtinindexingsupport.cpp \
|
||||||
commentssettings.cpp \
|
commentssettings.cpp \
|
||||||
completionsettingspage.cpp \
|
completionsettingspage.cpp \
|
||||||
@@ -100,7 +101,6 @@ SOURCES += \
|
|||||||
cppqtstyleindenter.cpp \
|
cppqtstyleindenter.cpp \
|
||||||
cpprefactoringchanges.cpp \
|
cpprefactoringchanges.cpp \
|
||||||
cppsemanticinfo.cpp \
|
cppsemanticinfo.cpp \
|
||||||
cppsnapshotupdater.cpp \
|
|
||||||
cppsourceprocessor.cpp \
|
cppsourceprocessor.cpp \
|
||||||
cpptoolseditorsupport.cpp \
|
cpptoolseditorsupport.cpp \
|
||||||
cpptoolsplugin.cpp \
|
cpptoolsplugin.cpp \
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ QtcPlugin {
|
|||||||
files: [
|
files: [
|
||||||
"abstracteditorsupport.cpp", "abstracteditorsupport.h",
|
"abstracteditorsupport.cpp", "abstracteditorsupport.h",
|
||||||
"baseeditordocumentparser.cpp", "baseeditordocumentparser.h",
|
"baseeditordocumentparser.cpp", "baseeditordocumentparser.h",
|
||||||
|
"builtineditordocumentparser.cpp", "builtineditordocumentparser.h",
|
||||||
"builtinindexingsupport.cpp", "builtinindexingsupport.h",
|
"builtinindexingsupport.cpp", "builtinindexingsupport.h",
|
||||||
"commentssettings.cpp", "commentssettings.h",
|
"commentssettings.cpp", "commentssettings.h",
|
||||||
"completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",
|
"completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",
|
||||||
@@ -61,7 +62,6 @@ QtcPlugin {
|
|||||||
"cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
|
"cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
|
||||||
"cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
|
"cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
|
||||||
"cppsemanticinfo.cpp", "cppsemanticinfo.h",
|
"cppsemanticinfo.cpp", "cppsemanticinfo.h",
|
||||||
"cppsnapshotupdater.cpp", "cppsnapshotupdater.h",
|
|
||||||
"cppsourceprocessor.cpp", "cppsourceprocessor.h",
|
"cppsourceprocessor.cpp", "cppsourceprocessor.h",
|
||||||
"cpptools.qrc",
|
"cpptools.qrc",
|
||||||
"cpptools_global.h",
|
"cpptools_global.h",
|
||||||
|
|||||||
@@ -171,11 +171,11 @@ CppEditorSupport::CppEditorSupport(CppModelManager *modelManager, BaseTextEditor
|
|||||||
|
|
||||||
CppEditorSupport::~CppEditorSupport()
|
CppEditorSupport::~CppEditorSupport()
|
||||||
{
|
{
|
||||||
m_documentParser.cancel();
|
m_documentParserFuture.cancel();
|
||||||
m_highlighter.cancel();
|
m_highlighter.cancel();
|
||||||
m_futureSemanticInfo.cancel();
|
m_futureSemanticInfo.cancel();
|
||||||
|
|
||||||
m_documentParser.waitForFinished();
|
m_documentParserFuture.waitForFinished();
|
||||||
m_highlighter.waitForFinished();
|
m_highlighter.waitForFinished();
|
||||||
m_futureSemanticInfo.waitForFinished();
|
m_futureSemanticInfo.waitForFinished();
|
||||||
}
|
}
|
||||||
@@ -259,12 +259,12 @@ CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const
|
|||||||
return m_completionAssistProvider;
|
return m_completionAssistProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater()
|
QSharedPointer<BuiltinEditorDocumentParser> CppEditorSupport::documentParser()
|
||||||
{
|
{
|
||||||
QSharedPointer<SnapshotUpdater> updater = snapshotUpdater_internal();
|
QSharedPointer<BuiltinEditorDocumentParser> updater = documentParser_internal();
|
||||||
if (!updater || updater->filePath() != fileName()) {
|
if (!updater || updater->filePath() != fileName()) {
|
||||||
updater = QSharedPointer<SnapshotUpdater>(new SnapshotUpdater(fileName()));
|
updater = QSharedPointer<BuiltinEditorDocumentParser>(new BuiltinEditorDocumentParser(fileName()));
|
||||||
setSnapshotUpdater_internal(updater);
|
setDocumentParser_internal(updater);
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
||||||
updater->setUsePrecompiledHeaders(cms->pchUsage() != CppCodeModelSettings::PchUse_None);
|
updater->setUsePrecompiledHeaders(cms->pchUsage() != CppCodeModelSettings::PchUse_None);
|
||||||
@@ -282,7 +282,7 @@ void CppEditorSupport::updateDocument()
|
|||||||
m_updateDocumentTimer->start(m_updateDocumentInterval);
|
m_updateDocumentTimer->start(m_updateDocumentInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater,
|
static void parse(QFutureInterface<void> &future, QSharedPointer<BuiltinEditorDocumentParser> updater,
|
||||||
WorkingCopy workingCopy)
|
WorkingCopy workingCopy)
|
||||||
{
|
{
|
||||||
future.setProgressRange(0, 1);
|
future.setProgressRange(0, 1);
|
||||||
@@ -300,7 +300,7 @@ static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater
|
|||||||
|
|
||||||
void CppEditorSupport::updateDocumentNow()
|
void CppEditorSupport::updateDocumentNow()
|
||||||
{
|
{
|
||||||
if (m_documentParser.isRunning() || m_revision != editorRevision()) {
|
if (m_documentParserFuture.isRunning() || m_revision != editorRevision()) {
|
||||||
m_updateDocumentTimer->start(m_updateDocumentInterval);
|
m_updateDocumentTimer->start(m_updateDocumentInterval);
|
||||||
} else {
|
} else {
|
||||||
m_updateDocumentTimer->stop();
|
m_updateDocumentTimer->stop();
|
||||||
@@ -311,14 +311,14 @@ void CppEditorSupport::updateDocumentNow()
|
|||||||
if (m_highlightingSupport && !m_highlightingSupport->requiresSemanticInfo())
|
if (m_highlightingSupport && !m_highlightingSupport->requiresSemanticInfo())
|
||||||
startHighlighting();
|
startHighlighting();
|
||||||
|
|
||||||
m_documentParser = QtConcurrent::run(&parse, snapshotUpdater(),
|
m_documentParserFuture = QtConcurrent::run(&parse, documentParser(),
|
||||||
CppModelManager::instance()->workingCopy());
|
CppModelManager::instance()->workingCopy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppEditorSupport::isUpdatingDocument()
|
bool CppEditorSupport::isUpdatingDocument()
|
||||||
{
|
{
|
||||||
return m_updateDocumentTimer->isActive() || m_documentParser.isRunning();
|
return m_updateDocumentTimer->isActive() || m_documentParserFuture.isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorSupport::onDocumentUpdated(Document::Ptr doc)
|
void CppEditorSupport::onDocumentUpdated(Document::Ptr doc)
|
||||||
@@ -488,7 +488,7 @@ void CppEditorSupport::releaseResources()
|
|||||||
{
|
{
|
||||||
m_highlighter.cancel();
|
m_highlighter.cancel();
|
||||||
m_highlighter = QFuture<TextEditor::HighlightingResult>();
|
m_highlighter = QFuture<TextEditor::HighlightingResult>();
|
||||||
snapshotUpdater()->releaseResources();
|
documentParser()->releaseResources();
|
||||||
setSemanticInfo(SemanticInfo(), /*emitSignal=*/ false);
|
setSemanticInfo(SemanticInfo(), /*emitSignal=*/ false);
|
||||||
m_lastHighlightOnCompleteSemanticInfo = true;
|
m_lastHighlightOnCompleteSemanticInfo = true;
|
||||||
}
|
}
|
||||||
@@ -524,11 +524,12 @@ SemanticInfo CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::So
|
|||||||
|
|
||||||
// Otherwise reprocess document
|
// Otherwise reprocess document
|
||||||
} else {
|
} else {
|
||||||
const QSharedPointer<SnapshotUpdater> snapshotUpdater = snapshotUpdater_internal();
|
const QSharedPointer<BuiltinEditorDocumentParser> documentParser
|
||||||
QTC_ASSERT(snapshotUpdater, return newSemanticInfo);
|
= documentParser_internal();
|
||||||
newSemanticInfo.snapshot = snapshotUpdater->snapshot();
|
QTC_ASSERT(documentParser, return newSemanticInfo);
|
||||||
|
newSemanticInfo.snapshot = documentParser->snapshot();
|
||||||
if (!newSemanticInfo.snapshot.contains(source.fileName))
|
if (!newSemanticInfo.snapshot.contains(source.fileName))
|
||||||
return newSemanticInfo; // SnapshotUpdater::update() not yet started.
|
return newSemanticInfo; // BuiltinEditorDocumentParser::update() not yet started.
|
||||||
Document::Ptr doc = newSemanticInfo.snapshot.preprocessedDocument(source.code,
|
Document::Ptr doc = newSemanticInfo.snapshot.preprocessedDocument(source.code,
|
||||||
source.fileName);
|
source.fileName);
|
||||||
if (processor)
|
if (processor)
|
||||||
@@ -583,16 +584,17 @@ void CppEditorSupport::setSemanticInfo(const SemanticInfo &semanticInfo, bool em
|
|||||||
emit semanticInfoUpdated(semanticInfo);
|
emit semanticInfoUpdated(semanticInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater_internal() const
|
QSharedPointer<BuiltinEditorDocumentParser> CppEditorSupport::documentParser_internal() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_snapshotUpdaterLock);
|
QMutexLocker locker(&m_documentParserLock);
|
||||||
return m_snapshotUpdater;
|
return m_documentParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorSupport::setSnapshotUpdater_internal(const QSharedPointer<SnapshotUpdater> &updater)
|
void CppEditorSupport::setDocumentParser_internal(
|
||||||
|
const QSharedPointer<BuiltinEditorDocumentParser> &updater)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_snapshotUpdaterLock);
|
QMutexLocker locker(&m_documentParserLock);
|
||||||
m_snapshotUpdater = updater;
|
m_documentParser = updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorSupport::onMimeTypeChanged()
|
void CppEditorSupport::onMimeTypeChanged()
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
#ifndef CPPTOOLSEDITORSUPPORT_H
|
#ifndef CPPTOOLSEDITORSUPPORT_H
|
||||||
#define CPPTOOLSEDITORSUPPORT_H
|
#define CPPTOOLSEDITORSUPPORT_H
|
||||||
|
|
||||||
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cpphighlightingsupport.h"
|
#include "cpphighlightingsupport.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cppsemanticinfo.h"
|
#include "cppsemanticinfo.h"
|
||||||
#include "cppsnapshotupdater.h"
|
|
||||||
|
|
||||||
#include <cplusplus/Control.h>
|
#include <cplusplus/Control.h>
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
CppCompletionAssistProvider *completionAssistProvider() const;
|
CppCompletionAssistProvider *completionAssistProvider() const;
|
||||||
|
|
||||||
QSharedPointer<SnapshotUpdater> snapshotUpdater();
|
QSharedPointer<BuiltinEditorDocumentParser> documentParser();
|
||||||
|
|
||||||
/// Checks whether the document is (re)parsed or about to be (re)parsed.
|
/// Checks whether the document is (re)parsed or about to be (re)parsed.
|
||||||
bool isUpdatingDocument();
|
bool isUpdatingDocument();
|
||||||
@@ -202,8 +202,8 @@ private:
|
|||||||
SemanticInfo semanticInfo() const;
|
SemanticInfo semanticInfo() const;
|
||||||
void setSemanticInfo(const SemanticInfo &semanticInfo, bool emitSignal = true);
|
void setSemanticInfo(const SemanticInfo &semanticInfo, bool emitSignal = true);
|
||||||
|
|
||||||
QSharedPointer<SnapshotUpdater> snapshotUpdater_internal() const;
|
QSharedPointer<BuiltinEditorDocumentParser> documentParser_internal() const;
|
||||||
void setSnapshotUpdater_internal(const QSharedPointer<SnapshotUpdater> &updater);
|
void setDocumentParser_internal(const QSharedPointer<BuiltinEditorDocumentParser> &updater);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::CppModelManager *m_modelManager;
|
Internal::CppModelManager *m_modelManager;
|
||||||
@@ -212,7 +212,6 @@ private:
|
|||||||
QTimer *m_updateDocumentTimer;
|
QTimer *m_updateDocumentTimer;
|
||||||
int m_updateDocumentInterval;
|
int m_updateDocumentInterval;
|
||||||
unsigned m_revision;
|
unsigned m_revision;
|
||||||
QFuture<void> m_documentParser;
|
|
||||||
|
|
||||||
QTimer *m_editorGCTimer;
|
QTimer *m_editorGCTimer;
|
||||||
bool m_editorVisible;
|
bool m_editorVisible;
|
||||||
@@ -234,8 +233,9 @@ private:
|
|||||||
mutable QMutex m_lastSemanticInfoLock;
|
mutable QMutex m_lastSemanticInfoLock;
|
||||||
SemanticInfo m_lastSemanticInfo;
|
SemanticInfo m_lastSemanticInfo;
|
||||||
QFuture<void> m_futureSemanticInfo;
|
QFuture<void> m_futureSemanticInfo;
|
||||||
mutable QMutex m_snapshotUpdaterLock;
|
mutable QMutex m_documentParserLock;
|
||||||
QSharedPointer<SnapshotUpdater> m_snapshotUpdater;
|
QSharedPointer<BuiltinEditorDocumentParser> m_documentParser;
|
||||||
|
QFuture<void> m_documentParserFuture;
|
||||||
|
|
||||||
// Highlighting:
|
// Highlighting:
|
||||||
unsigned m_lastHighlightRevision;
|
unsigned m_lastHighlightRevision;
|
||||||
|
|||||||
@@ -195,10 +195,10 @@ public:
|
|||||||
|
|
||||||
// Compare
|
// Compare
|
||||||
const Document::Ptr cppDocument
|
const Document::Ptr cppDocument
|
||||||
= m_modelManager->cppEditorSupport(cppFileEditor)->snapshotUpdater()->document();
|
= m_modelManager->cppEditorSupport(cppFileEditor)->documentParser()->document();
|
||||||
QVERIFY(checkDiagsnosticMessages(cppDocument));
|
QVERIFY(checkDiagsnosticMessages(cppDocument));
|
||||||
const Document::Ptr hDocument
|
const Document::Ptr hDocument
|
||||||
= m_modelManager->cppEditorSupport(hFileEditor)->snapshotUpdater()->document();
|
= m_modelManager->cppEditorSupport(hFileEditor)->documentParser()->document();
|
||||||
QVERIFY(checkDiagsnosticMessages(hDocument));
|
QVERIFY(checkDiagsnosticMessages(hDocument));
|
||||||
|
|
||||||
QVERIFY(documentContainsFunctionDefinition(cppDocument,
|
QVERIFY(documentContainsFunctionDefinition(cppDocument,
|
||||||
|
|||||||
Reference in New Issue
Block a user