summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolseditorsupport.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2013-08-19 16:05:29 +0200
committerErik Verbruggen <erik.verbruggen@digia.com>2013-10-01 10:33:51 +0200
commitba2d7a4fa7c29ea2d62da3d6f6835a091f604656 (patch)
tree240f8484a13829478d3b7c586eec0598c45d0872 /src/plugins/cpptools/cpptoolseditorsupport.cpp
parent447c4ed37f8904ca733d6e6253ad19bb0388f209 (diff)
downloadqt-creator-ba2d7a4fa7c29ea2d62da3d6f6835a091f604656.tar.gz
C++: Only parse with appropriate defines for open editors.
If two files from different (sub-)projects include the same header file, and the defined macros differ for both files, the header file will be parsed with only the appropriate macros for the including file. Task-number: QTCREATORBUG-9802 Task-number: QTCREATORBUG-1249 Change-Id: I560490afa287b3bb1e863bce1bb4f57af36ad56e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolseditorsupport.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp
index fc4d64b3c9..c33a4241b9 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.cpp
+++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp
@@ -169,6 +169,8 @@ QString CppEditorSupport::fileName() const
QByteArray CppEditorSupport::contents() const
{
+ QMutexLocker locker(&m_cachedContentsLock);
+
const int editorRev = editorRevision();
if (m_cachedContentsEditorRevision != editorRev && !m_fileIsBeingReloaded) {
m_cachedContentsEditorRevision = editorRev;
@@ -215,6 +217,13 @@ SemanticInfo CppEditorSupport::recalculateSemanticInfo(bool emitSignalWhenFinish
return m_lastSemanticInfo;
}
+Document::Ptr CppEditorSupport::lastSemanticInfoDocument() const
+{
+ QMutexLocker locker(&m_lastSemanticInfoLock);
+
+ return m_lastSemanticInfo.doc;
+}
+
void CppEditorSupport::recalculateSemanticInfoDetached(bool force)
{
// Block premature calculation caused by CppEditorPlugin::currentEditorChanged
@@ -236,6 +245,16 @@ CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const
return m_completionAssistProvider;
}
+QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater()
+{
+ QSharedPointer<SnapshotUpdater> updater = m_snapshotUpdater;
+ if (!updater) {
+ updater.reset(new SnapshotUpdater(fileName()));
+ m_snapshotUpdater = updater;
+ }
+ return updater;
+}
+
void CppEditorSupport::updateDocument()
{
m_revision = editorRevision();
@@ -246,6 +265,19 @@ void CppEditorSupport::updateDocument()
m_updateDocumentTimer->start(m_updateDocumentInterval);
}
+static void parse(QFutureInterface<void> &future, CppEditorSupport *support)
+{
+ future.setProgressRange(0, 1);
+
+ CppModelManager *cmm = qobject_cast<CppModelManager *>(CppModelManager::instance());
+ QSharedPointer<SnapshotUpdater> updater = support->snapshotUpdater();
+
+ updater->update(cmm->workingCopy());
+ cmm->finishedRefreshingSourceFiles(QStringList(updater->document()->fileName()));
+
+ future.setProgressValue(1);
+}
+
void CppEditorSupport::updateDocumentNow()
{
if (m_documentParser.isRunning() || m_revision != editorRevision()) {
@@ -259,8 +291,7 @@ void CppEditorSupport::updateDocumentNow()
if (m_highlightingSupport && !m_highlightingSupport->requiresSemanticInfo())
startHighlighting();
- const QStringList sourceFiles(m_textEditor->document()->filePath());
- m_documentParser = m_modelManager->updateSourceFiles(sourceFiles);
+ m_documentParser = QtConcurrent::run(&parse, this);
}
}
@@ -429,7 +460,7 @@ SemanticInfo::Source CppEditorSupport::currentSource(bool force)
int line = 0, column = 0;
m_textEditor->convertPosition(m_textEditor->editorWidget()->position(), &line, &column);
- const Snapshot snapshot = m_modelManager->snapshot();
+ const Snapshot snapshot = m_snapshotUpdater->snapshot();
QByteArray code;
if (force || m_lastSemanticInfo.revision != editorRevision())