diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2016-11-22 15:17:42 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2016-11-23 11:50:39 +0000 |
commit | 6cf1f7968f8dac84825f96515ea3adbeeb6b2734 (patch) | |
tree | afc05379d59cf87f22a6395e8cf7aabe371e00aa /src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp | |
parent | e9f0f370702c90faaaacaebcd7e64c35dc2ead2c (diff) | |
download | qt-creator-6cf1f7968f8dac84825f96515ea3adbeeb6b2734.tar.gz |
Clang: Fix initial document parse with modified content
Reproduce with:
1. Create a new class named Foo with the wizard.
2. Close foo.h
3. In foo.cpp, add some class member function.
4. In foo.cpp, trigger the refactoring action "Add public Declaration"
for the just defined member function. As a result, foo.h will be
opened.
==> While the declaration was added, the header file is not yet
reparsed with the new content - this can be verified by setting
a custom color for "Function".
In this use case, the refactoring action opens the editor and
immediately modifies the document (RefactoringFile::apply).
Fix by sending the document content along for the very first
RegisterTranslationUnitForEditorMessage if the document was already
modified.
Change-Id: If20615a45b72dd0bef87e1870e403d0b277bc5d6
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp')
-rw-r--r-- | src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp index f979a33af8..54ca38d3b2 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp +++ b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp @@ -519,15 +519,10 @@ void ClangCompletionAssistProcessor::sendFileContent(const QByteArray &customFil uint(m_interface->textDocument()->revision())}}); } namespace { -CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath) -{ - return CppTools::CppModelManager::instance()->cppEditorDocument(filePath); -} - bool shouldSendDocumentForCompletion(const QString &filePath, int completionPosition) { - auto *document = cppDocument(filePath); + CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath); if (document) { auto &sendTracker = document->sendTracker(); @@ -541,7 +536,7 @@ bool shouldSendDocumentForCompletion(const QString &filePath, bool shouldSendCodeCompletion(const QString &filePath, int completionPosition) { - auto *document = cppDocument(filePath); + CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath); if (document) { auto &sendTracker = document->sendTracker(); @@ -553,7 +548,7 @@ bool shouldSendCodeCompletion(const QString &filePath, void setLastDocumentRevision(const QString &filePath) { - auto *document = cppDocument(filePath); + CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath); if (document) document->sendTracker().setLastSentRevision(int(document->revision())); @@ -562,7 +557,7 @@ void setLastDocumentRevision(const QString &filePath) void setLastCompletionPosition(const QString &filePath, int completionPosition) { - auto *document = cppDocument(filePath); + CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath); if (document) document->sendTracker().setLastCompletionPosition(completionPosition); |