diff options
author | Nikolai Kosjar <[email protected]> | 2018-05-15 14:31:48 +0200 |
---|---|---|
committer | Nikolai Kosjar <[email protected]> | 2018-05-16 07:10:39 +0000 |
commit | 26b09af2779e95e52509e34af6cf0668fe3832e1 (patch) | |
tree | bb93deccfeb8c3e051c668aaadaf8f34c95fd2b9 /src/plugins/clangtools/clangtoolslogfilereader.cpp | |
parent | 1773b4d8b56cfdb74f0266a1972fcf0b96e1db65 (diff) |
ClangTools: Allow applying fixits
Add a new column to the view that allows to check diagnostics with
fixits. The checked fixits can then be applied with the also new "Apply
Fixits" button in the toolbar.
Some corner cases are not yet handled:
* File is open in editor
* File changed in the mean time
Change-Id: I3d3f353a4150699a0d082f2a4348e331a4213bcf
Reviewed-by: Ivan Donchevskii <[email protected]>
Diffstat (limited to 'src/plugins/clangtools/clangtoolslogfilereader.cpp')
-rw-r--r-- | src/plugins/clangtools/clangtoolslogfilereader.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/clangtools/clangtoolslogfilereader.cpp b/src/plugins/clangtools/clangtoolslogfilereader.cpp index 388868e7e84..f0885c22fc1 100644 --- a/src/plugins/clangtools/clangtoolslogfilereader.cpp +++ b/src/plugins/clangtools/clangtoolslogfilereader.cpp @@ -141,8 +141,8 @@ static ExplainingStep buildFixIt(const CXDiagnostic cxDiagnostic, unsigned index { ExplainingStep fixItStep; CXSourceRange cxFixItRange; - fixItStep.message = "fix-it: " + fromCXString(clang_getDiagnosticFixIt(cxDiagnostic, index, - &cxFixItRange)); + fixItStep.isFixIt = true; + fixItStep.message = fromCXString(clang_getDiagnosticFixIt(cxDiagnostic, index, &cxFixItRange)); fixItStep.location = diagLocationFromSourceLocation(clang_getRangeStart(cxFixItRange)); fixItStep.ranges.push_back(fixItStep.location); fixItStep.ranges.push_back(diagLocationFromSourceLocation(clang_getRangeEnd(cxFixItRange))); @@ -184,7 +184,9 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, const QString diagnostic.explainingSteps.push_back(diagnosticStep); } - for (unsigned i = 0; i < clang_getDiagnosticNumFixIts(cxDiagnostic); ++i) + const unsigned fixItCount = clang_getDiagnosticNumFixIts(cxDiagnostic); + diagnostic.hasFixits = fixItCount != 0; + for (unsigned i = 0; i < fixItCount; ++i) diagnostic.explainingSteps.push_back(buildFixIt(cxDiagnostic, i)); diagnostic.description = fromCXString(clang_getDiagnosticSpelling(cxDiagnostic)); |