@@ -54,8 +54,7 @@ public static TextPos2D getPmdLineAndColumnFromOffset(CodeArea codeArea, int abs
5454
5555 Position pos = codeArea .offsetToPosition (absoluteOffset , Bias .Forward );
5656
57- return new TextPos2D (getPmdLineFromRtfxParIndex (pos .getMajor ()),
58- getPmdColumnIndexFromRtfxColumn (codeArea , pos .getMajor (), pos .getMinor ()));
57+ return new TextPos2D (getPmdLineFromRtfxParIndex (pos .getMajor ()), pos .getMinor () + 1 );
5958 }
6059
6160
@@ -65,7 +64,7 @@ public static TextPos2D getPmdLineAndColumnFromOffset(CodeArea codeArea, int abs
6564 *
6665 * <ul>
6766 * <li>CodeArea counts a tab as 1 column width but displays it as 8 columns width.
68- * PMD counts it correctly as 8 columns, so the position must be offset .
67+ * PMD counts it correctly as 1 column (since PMD 6.27.0, before it was 8 columns) .
6968 * <li>PMD lines start at 1 but paragraph nums start at 0 in the code area,
7069 * same for columns.
7170 * <li>PMD's end column is inclusive and not exclusive.
@@ -76,36 +75,11 @@ public static int getOffsetFromPmdPosition(CodeArea codeArea, int line, int colu
7675 column = max (column , 1 );
7776
7877 int parIdx = getRtfxParIndexFromPmdLine (line );
79- int raw = codeArea .getAbsolutePosition (parIdx , getRtfxColumnIndexFromPmdColumn ( codeArea , parIdx , column ) );
78+ int raw = codeArea .getAbsolutePosition (parIdx , column - 1 );
8079 return clip (raw , 0 , codeArea .getLength () - 1 );
8180 }
8281
8382
84- private static int getRtfxColumnIndexFromPmdColumn (CodeArea codeArea , int parIdx , int column ) {
85- String parTxt = codeArea .getParagraph (parIdx ).getText ();
86- int end = column - 1 ;
87- for (int i = 0 ; i < end && end > 0 ; i ++) {
88- char c = parTxt .charAt (i );
89- if (c == '\t' ) {
90- end = max (end - 7 , 0 );
91- }
92- }
93- return end ;
94- }
95-
96- private static int getPmdColumnIndexFromRtfxColumn (CodeArea codeArea , int parIdx , int rtfxCol ) {
97- String parTxt = codeArea .getParagraph (parIdx ).getText ();
98- int mapped = rtfxCol ;
99- for (int i = 0 ; i < rtfxCol && i < parTxt .length (); i ++) {
100- char c = parTxt .charAt (i );
101- if (c == '\t' ) {
102- mapped += 7 ;
103- }
104- }
105- return mapped + 1 ;
106- }
107-
108-
10983 private static int clip (int val , int min , int max ) {
11084 return max (min , min (val , max ));
11185 }
0 commit comments