Closed csordasmarton closed 2 years ago
A TextDocument
has a method to get word range at a given position called getWordRangeAtPosition
. If no range information is available for a report we can use this method to get word position at the given line + column position and if the end position is larger than the current column we can set the end column position of the report to this:
So instead of this:
#include <assert.h>
int main() {
int a = 0; assert(a++ || "line 3");
^
}
we would highlight this:
#include <assert.h>
int main() {
int a = 0; assert(a++ || "line 3");
^^^^^^
}
The code for this would look similar to this:
const editors = window.visibleTextEditors.reduce(
(prev, curr) => {prev[curr.document.uri.fsPath] = curr; return prev;}, {} as {[key: string]: TextEditor});
let line = report.line - 1;
let column = report.column - 1;
const editor = editors[report.file.original_path]
if (editor) {
const range = editor.document.getWordRangeAtPosition(new Position(line, column));
if (range?.isSingleLine && column < range?.end.character) {
column = range.end.character;
}
}
Range information in plist files generated by CodeChecker with Clang Tidy analyzer are incomplete and doesn't contain range information.
For example on the following code:
the Clang Tidy output will look like this:
It is hard to see the reports in the opened file from the user perspective if I don't open the CodeChecke view but only viewing the red underscores in the code.
Maybe in this case the end range can be the end of the line: