summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2016-06-24 15:01:16 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2016-06-28 11:08:08 +0000
commit46840046dff74cc1f56027ce769928241f534629 (patch)
tree8a38a4c17757182353eafceb131dc8ee6d41039a /src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
parent69fa7a8ffb707803f3e41bea8383dfc1cf7a8cfe (diff)
downloadqt-creator-46840046dff74cc1f56027ce769928241f534629.tar.gz
Clang: Honor fixits own locations
...when showing the refactoring marker and generating the quick fix operations. Opening main.cpp main.cpp: #include "file.h" void f(char *s) { foo(s); } file.h: // significant line 1 // significant line 2 // significant line 3 bool foo(int fd); led to SOFT ASSERT: "textBlock.isValid()" in file clangdiagnosticmanager.cpp, line 205 and a misbehavior when applying the fixit from the tooltip. We take the line of a diagnostic to display the fixit marker if it has any fixits. But the (child) diagnostic might be issued for an other file (that's what happening here), so better take the line of the location where the fixit is meant to be applied. Same applies for generation of the quick fix entries. Change-Id: I48d38420b285d2d2f86e3faa2319513aa8b47848 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/clangcodemodel/clangdiagnosticmanager.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticmanager.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
index 0e3d70ec9d..71afe79bf1 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
+++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
@@ -352,13 +352,17 @@ void ClangDiagnosticManager::addFixItAvailableMarker(
QSet<int> &lineNumbersWithFixItMarker)
{
for (auto &&diagnostic : diagnostics) {
- const int line = int(diagnostic.location().line());
- if (!diagnostic.fixIts().isEmpty() && !lineNumbersWithFixItMarker.contains(line)) {
- const TextEditor::RefactorMarker marker
- = createFixItAvailableMarker(m_textDocument->document(), line);
+ for (auto &&fixit : diagnostic.fixIts()) {
+ const ClangBackEnd::SourceLocationContainer location = fixit.range().start();
+ const int line = int(location.line());
- lineNumbersWithFixItMarker.insert(line);
- m_fixItAvailableMarkers.append(marker);
+ if (location.filePath() == filePath() && !lineNumbersWithFixItMarker.contains(line)) {
+ const TextEditor::RefactorMarker marker
+ = createFixItAvailableMarker(m_textDocument->document(), line);
+
+ lineNumbersWithFixItMarker.insert(line);
+ m_fixItAvailableMarkers.append(marker);
+ }
}
addFixItAvailableMarker(diagnostic.children(), lineNumbersWithFixItMarker);