From d3b676b3c5cc2f90c677899773aa0bc989d5a912 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 26 Apr 2023 15:09:08 +0200 Subject: [PATCH] apply the provided column information to the highlighting --- README.md | 1 + resources/META-INF/plugin.xml | 3 ++- .../github/johnthagen/cppcheck/CppCheckInspectionImpl.java | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8a5f8ce..b11519c 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ Deployment. - Display global inspection error and omit the option if the configured `MISRA Addon JSON` does not exist. - Made plugin verbose level configurable via settings. - Display all available details for findings in tooltip. +- Apply the provided column information to the highlighting. ### 1.6.2 - 2022-01-25 diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 7c0b426..5a8666a 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -28,7 +28,8 @@ - Display `Cppcheck Path` configuration errors as global inspection errors instead of using a (hard to spot) status bar message.
- Display global inspection error and omit the option if the configured `MISRA Addon JSON` does not exist.
- Made plugin verbose level configurable via settings.
- - Display all available details for findings in tooltip. + - Display all available details for findings in tooltip.
+ - Apply the provided column information to the highlighting. ]]> diff --git a/src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java b/src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java index 24f5f10..1829f48 100644 --- a/src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java +++ b/src/com/github/johnthagen/cppcheck/CppCheckInspectionImpl.java @@ -190,7 +190,6 @@ public List parseOutput(@NotNull final PsiFile psiFile, final String fileName = locations.get(0).file; int lineNumber = locations.get(0).line; - // TODO: use in ProblemDescriptor final int column = locations.get(0).column; if (verboseLevel >= 4) { @@ -214,10 +213,10 @@ public List parseOutput(@NotNull final PsiFile psiFile, continue; } - // Document counts lines starting at 0, rather than 1 like in cppcheck. + // Document counts lines and columns starting at 0, rather than 1 like in cppcheck. lineNumber -= 1; - final int lineStartOffset = DocumentUtil.getFirstNonSpaceCharOffset(document, lineNumber); + final int lineStartOffset = (column == -1) ? DocumentUtil.getFirstNonSpaceCharOffset(document, lineNumber) : (document.getLineStartOffset(lineNumber) + (column -1)); final int lineEndOffset = document.getLineEndOffset(lineNumber); String details = "";