CppTools/Clang: Remove InMemoryInfo

...nowadays we only need the working copy.

Change-Id: I30924b3c5dc68b428d6c10f6ba015b0640b476d2
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-12-15 12:32:01 +01:00
parent 802f9f47e9
commit 9abfd73204
15 changed files with 19 additions and 45 deletions

View File

@@ -40,7 +40,7 @@ ClangEditorDocumentParser::ClangEditorDocumentParser(const QString &filePath)
setConfiguration(config); setConfiguration(config);
} }
void ClangEditorDocumentParser::updateHelper(const BaseEditorDocumentParser::InMemoryInfo &) void ClangEditorDocumentParser::updateHelper(const CppTools::WorkingCopy &)
{ {
State state_ = state(); State state_ = state();
state_.projectPart = determineProjectPart(filePath(), configuration(), state_); state_.projectPart = determineProjectPart(filePath(), configuration(), state_);

View File

@@ -43,7 +43,7 @@ public:
ClangEditorDocumentParser(const QString &filePath); ClangEditorDocumentParser(const QString &filePath);
private: private:
void updateHelper(const BaseEditorDocumentParser::InMemoryInfo &) override; void updateHelper(const CppTools::WorkingCopy &) override;
}; };
} // namespace ClangCodeModel } // namespace ClangCodeModel

View File

@@ -104,9 +104,8 @@ void ClangEditorDocumentProcessor::run()
m_parserRevision = revision(); m_parserRevision = revision();
connect(&m_parserWatcher, &QFutureWatcher<void>::finished, connect(&m_parserWatcher, &QFutureWatcher<void>::finished,
this, &ClangEditorDocumentProcessor::onParserFinished); this, &ClangEditorDocumentProcessor::onParserFinished);
const QFuture<void> future = QtConcurrent::run(&runParser, const CppTools::WorkingCopy workingCopy = CppTools::CppModelManager::instance()->workingCopy();
parser(), const QFuture<void> future = QtConcurrent::run(&runParser, parser(), workingCopy);
ClangEditorDocumentParser::InMemoryInfo(true));
m_parserWatcher.setFuture(future); m_parserWatcher.setFuture(future);
// Run builtin processor // Run builtin processor

View File

@@ -32,7 +32,6 @@
#include "baseeditordocumentprocessor.h" #include "baseeditordocumentprocessor.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include "cpptoolsreuse.h"
#include "editordocumenthandle.h" #include "editordocumenthandle.h"
namespace CppTools { namespace CppTools {
@@ -82,10 +81,10 @@ void BaseEditorDocumentParser::setConfiguration(const Configuration &configurati
m_configuration = configuration; m_configuration = configuration;
} }
void BaseEditorDocumentParser::update(const InMemoryInfo &info) void BaseEditorDocumentParser::update(const WorkingCopy &workingCopy)
{ {
QMutexLocker locker(&m_updateIsRunning); QMutexLocker locker(&m_updateIsRunning);
updateHelper(info); updateHelper(workingCopy);
} }
BaseEditorDocumentParser::State BaseEditorDocumentParser::state() const BaseEditorDocumentParser::State BaseEditorDocumentParser::state() const
@@ -148,11 +147,4 @@ ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart(const QString &f
return projectPart; return projectPart;
} }
BaseEditorDocumentParser::InMemoryInfo::InMemoryInfo(bool withModifiedFiles)
: workingCopy(CppTools::CppModelManager::instance()->workingCopy())
{
if (withModifiedFiles)
modifiedFiles = CppTools::modifiedFiles();
}
} // namespace CppTools } // namespace CppTools

View File

@@ -63,13 +63,7 @@ public:
Configuration configuration() const; Configuration configuration() const;
void setConfiguration(const Configuration &configuration); void setConfiguration(const Configuration &configuration);
struct CPPTOOLS_EXPORT InMemoryInfo { void update(const WorkingCopy &workingCopy);
InMemoryInfo(bool withModifiedFiles);
WorkingCopy workingCopy;
Utils::FileNameList modifiedFiles;
};
void update(const InMemoryInfo &info);
ProjectPart::Ptr projectPart() const; ProjectPart::Ptr projectPart() const;
@@ -88,7 +82,7 @@ protected:
mutable QMutex m_stateAndConfigurationMutex; mutable QMutex m_stateAndConfigurationMutex;
private: private:
virtual void updateHelper(const InMemoryInfo &inMemoryInfo) = 0; virtual void updateHelper(const WorkingCopy &workingCopy) = 0;
const QString m_filePath; const QString m_filePath;
Configuration m_configuration; Configuration m_configuration;

View File

@@ -76,7 +76,7 @@ BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &fil
void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future, void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
BaseEditorDocumentParser::Ptr parser, BaseEditorDocumentParser::Ptr parser,
BaseEditorDocumentParser::InMemoryInfo info) const WorkingCopy workingCopy)
{ {
future.setProgressRange(0, 1); future.setProgressRange(0, 1);
if (future.isCanceled()) { if (future.isCanceled()) {
@@ -84,7 +84,7 @@ void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
return; return;
} }
parser->update(info); parser->update(workingCopy);
CppModelManager::instance() CppModelManager::instance()
->finishedRefreshingSourceFiles(QSet<QString>() << parser->filePath()); ->finishedRefreshingSourceFiles(QSet<QString>() << parser->filePath());

View File

@@ -89,7 +89,7 @@ signals:
protected: protected:
static void runParser(QFutureInterface<void> &future, static void runParser(QFutureInterface<void> &future,
BaseEditorDocumentParser::Ptr parser, BaseEditorDocumentParser::Ptr parser,
BaseEditorDocumentParser::InMemoryInfo info); const CppTools::WorkingCopy workingCopy);
// Convenience // Convenience
QString filePath() const { return m_baseTextDocument->filePath().toString(); } QString filePath() const { return m_baseTextDocument->filePath().toString(); }

View File

@@ -60,7 +60,7 @@ BuiltinEditorDocumentParser::BuiltinEditorDocumentParser(const QString &filePath
qRegisterMetaType<CPlusPlus::Snapshot>("CPlusPlus::Snapshot"); qRegisterMetaType<CPlusPlus::Snapshot>("CPlusPlus::Snapshot");
} }
void BuiltinEditorDocumentParser::updateHelper(const InMemoryInfo &info) void BuiltinEditorDocumentParser::updateHelper(const WorkingCopy &theWorkingCopy)
{ {
if (filePath().isEmpty()) if (filePath().isEmpty())
return; return;
@@ -70,7 +70,7 @@ void BuiltinEditorDocumentParser::updateHelper(const InMemoryInfo &info)
State baseState = state(); State baseState = state();
ExtraState state = extraState(); ExtraState state = extraState();
WorkingCopy workingCopy = info.workingCopy; WorkingCopy workingCopy = theWorkingCopy;
bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged_ = false; bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged_ = false;

View File

@@ -64,7 +64,7 @@ public:
static Ptr get(const QString &filePath); static Ptr get(const QString &filePath);
private: private:
void updateHelper(const InMemoryInfo &info) override; void updateHelper(const WorkingCopy &workingCopy) override;
void addFileAndDependencies(CPlusPlus::Snapshot *snapshot, void addFileAndDependencies(CPlusPlus::Snapshot *snapshot,
QSet<Utils::FileName> *toRemove, QSet<Utils::FileName> *toRemove,
const Utils::FileName &fileName) const; const Utils::FileName &fileName) const;

View File

@@ -210,7 +210,7 @@ void BuiltinEditorDocumentProcessor::run()
{ {
m_parserFuture = QtConcurrent::run(&runParser, m_parserFuture = QtConcurrent::run(&runParser,
parser(), parser(),
BuiltinEditorDocumentParser::InMemoryInfo(false)); CppModelManager::instance()->workingCopy());
} }
BaseEditorDocumentParser::Ptr BuiltinEditorDocumentProcessor::parser() BaseEditorDocumentParser::Ptr BuiltinEditorDocumentProcessor::parser()

View File

@@ -160,7 +160,7 @@ void indexFindErrors(QFutureInterface<void> &future, const ParseParams params)
// Parse the file as precisely as possible // Parse the file as precisely as possible
BuiltinEditorDocumentParser parser(file); BuiltinEditorDocumentParser parser(file);
parser.setReleaseSourceAndAST(false); parser.setReleaseSourceAndAST(false);
parser.update(BuiltinEditorDocumentParser::InMemoryInfo(false)); parser.update(CppModelManager::instance()->workingCopy());
CPlusPlus::Document::Ptr document = parser.document(); CPlusPlus::Document::Ptr document = parser.document();
QTC_ASSERT(document, return); QTC_ASSERT(document, return);

View File

@@ -2188,7 +2188,7 @@ void CppCompletionAssistInterface::getCppSpecifics() const
m_gotCppSpecifics = true; m_gotCppSpecifics = true;
if (m_parser) { if (m_parser) {
m_parser->update(BuiltinEditorDocumentParser::InMemoryInfo(false)); m_parser->update(CppTools::CppModelManager::instance()->workingCopy());
m_snapshot = m_parser->snapshot(); m_snapshot = m_parser->snapshot();
m_headerPaths = m_parser->headerPaths(); m_headerPaths = m_parser->headerPaths();
} }

View File

@@ -917,7 +917,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
BaseEditorDocumentParser::Configuration config = parser->configuration(); BaseEditorDocumentParser::Configuration config = parser->configuration();
config.usePrecompiledHeaders = true; config.usePrecompiledHeaders = true;
parser->setConfiguration(config); parser->setConfiguration(config);
parser->update(BuiltinEditorDocumentParser::InMemoryInfo(false)); parser->update(CppModelManager::instance()->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);
@@ -1000,7 +1000,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
BaseEditorDocumentParser::Configuration config = parser->configuration(); BaseEditorDocumentParser::Configuration config = parser->configuration();
config.editorDefines = editorDefines.toUtf8(); config.editorDefines = editorDefines.toUtf8();
parser->setConfiguration(config); parser->setConfiguration(config);
parser->update(BuiltinEditorDocumentParser::InMemoryInfo(false)); parser->update(CppModelManager::instance()->workingCopy());
Document::Ptr doc = mm->document(main1File); Document::Ptr doc = mm->document(main1File);
QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName); QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName);

View File

@@ -289,11 +289,4 @@ bool skipFileDueToSizeLimit(const QFileInfo &fileInfo, int limitInMB)
return false; return false;
} }
Utils::FileNameList modifiedFiles()
{
Utils::FileNameList files = Utils::transform(Core::DocumentManager::modifiedDocuments(),
[](Core::IDocument *d) -> Utils::FileName { return d->filePath(); });
return Utils::filteredUnique(files);
}
} // CppTools } // CppTools

View File

@@ -37,8 +37,6 @@
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QChar; class QChar;
class QFileInfo; class QFileInfo;
@@ -54,8 +52,6 @@ class LookupContext;
namespace CppTools { namespace CppTools {
Utils::FileNameList CPPTOOLS_EXPORT modifiedFiles();
void CPPTOOLS_EXPORT moveCursorToEndOfIdentifier(QTextCursor *tc); void CPPTOOLS_EXPORT moveCursorToEndOfIdentifier(QTextCursor *tc);
void CPPTOOLS_EXPORT moveCursorToStartOfIdentifier(QTextCursor *tc); void CPPTOOLS_EXPORT moveCursorToStartOfIdentifier(QTextCursor *tc);