Skip to content

Commit

Permalink
REVERT ME Make end column inclusive
Browse files Browse the repository at this point in the history
This is for consistency with PMD 6, on pmd 7 this commit
may be reverted
  • Loading branch information
oowekyala committed Sep 1, 2020
1 parent dd440eb commit 10b205b
Show file tree
Hide file tree
Showing 7 changed files with 868 additions and 865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public void tokenize(SourceCode sourceCode, Tokens tokenEntries) {
lineNo += StringUtil.lineNumberAt(image, image.length()) - 1;
lastLineStart = matcher.start() + image.length() - ecol + 1;
}
// note: remove this -1 on the 7.0.x branch, this is here because in PMD 6, end columns are inclusive
ecol = ecol - 1;
tokenEntries.add(new TokenEntry(image, sourceCode.getFileName(), bline, bcol, ecol));
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public void testMultilineString() {
assertEquals("\"oo\n\"", getTokenImage(string));
assertEquals(1, string.getBeginLine());
assertEquals(5, string.getBeginColumn());
assertEquals(2, string.getEndColumn()); // ends on line 2
assertEquals(1, string.getEndColumn()); // ends on line 2

TokenEntry semi = tokens.getTokens().get(3);
assertEquals(";", getTokenImage(semi));
assertEquals(2, semi.getBeginLine());
assertEquals(2, semi.getBeginColumn());
assertEquals(3, semi.getEndColumn());
assertEquals(2, semi.getEndColumn());
}

private Tokens compareResult(AnyTokenizer tokenizer, String source, List<String> expectedImages) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.util.Properties;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;

import net.sourceforge.pmd.cpd.PerlLanguage;
Expand All @@ -23,7 +22,7 @@ public PerlTokenizerTest() {
}

@Override
public Tokenizer newTokenizer(@NonNull Properties properties) {
public Tokenizer newTokenizer(Properties properties) {
return new PerlLanguage().getTokenizer();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
[Image] or [Truncated image[ Bcol Ecol
L5
[use] 1 4
[strict] 5 11
[;] 11 12
[use] 1 3
[strict] 5 10
[;] 11 11
L8
[my] 1 3
[$] 4 5
[what] 5 9
[=] 10 11
['fred|barney'] 12 25
[;] 25 26
[my] 1 2
[$] 4 4
[what] 5 8
[=] 10 10
['fred|barney'] 12 24
[;] 25 25
L10
[while] 1 6
[(] 7 8
[<] 8 9
[>] 9 10
[)] 10 11
[{] 12 13
[while] 1 5
[(] 7 7
[<] 8 8
[>] 9 9
[)] 10 10
[{] 12 12
L11
[chomp] 5 10
[;] 10 11
[chomp] 5 9
[;] 10 10
L18
[if] 5 7
[(] 8 9
[/] 9 10
[YOUR_PATTERN_GOES_HERE] 10 32
[/] 32 33
[)] 33 34
[{] 35 36
[if] 5 6
[(] 8 8
[/] 9 9
[YOUR_PATTERN_GOES_HERE] 10 31
[/] 32 32
[)] 33 33
[{] 35 35
L19
[print] 2 7
['Matched: |$ `\n\t<$&>$|\\n'] 8 11
[print] 2 6
['Matched: |$ `\n\t<$&>$|\\n'] 8 10
L20
[;] 11 12
[;] 11 11
L25
[}] 5 6
[else] 7 11
[{] 12 13
[}] 5 5
[else] 7 10
[{] 12 12
L26
[print] 2 7
["No match.\\n"] 8 21
[;] 21 22
[print] 2 6
["No match.\\n"] 8 20
[;] 21 21
L27
[}] 5 6
[}] 5 5
L29
[}] 1 2
[}] 1 1
EOF
Original file line number Diff line number Diff line change
@@ -1,79 +1,80 @@
[Image] or [Truncated image[ Bcol Ecol
L1
[require] 1 8
["socket"] 9 17
[require] 1 7
["socket"] 9 16
L3
[gs] 1 3
[=] 4 5
[TCPServer] 7 16
[.] 16 17
[open] 17 21
[(] 21 22
[0] 22 23
[)] 23 24
[gs] 1 2
[=] 4 4
[TCPServer] 7 15
[.] 16 16
[open] 17 20
[(] 21 21
[0] 22 22
[)] 23 23
L4
[addr] 1 5
[=] 7 8
[gs] 9 11
[.] 11 12
[addr] 12 16
[addr] 1 4
[=] 7 7
[gs] 9 10
[.] 11 11
[addr] 12 15
L5
[addr] 1 5
[.] 5 6
[shift] 6 11
[addr] 1 4
[.] 5 5
[shift] 6 10
L7
[while] 1 6
[true] 7 11
[while] 1 5
[true] 7 10
L8
[ns] 3 5
[=] 6 7
[gs] 8 10
[.] 10 11
[accept] 11 17
[ns] 3 4
[=] 6 6
[gs] 8 9
[.] 10 10
[accept] 11 16
L9
[print] 3 8
[(] 8 9
[ns] 9 11
[,] 11 12
[" is accepted"] 13 27
[)] 27 28
[print] 3 7
[(] 8 8
[ns] 9 10
[,] 11 11
[" is accepted"] 13 26
[)] 27 27
L10
[Thread] 3 9
[.] 9 10
[start] 10 15
[do] 16 18
[Thread] 3 8
[.] 9 9
[start] 10 14
[do] 16 17
L11
[s] 5 6
[=] 7 8
[ns] 9 11
[s] 5 5
[=] 7 7
[ns] 9 10
L12
[while] 5 10
[s] 11 12
[.] 12 13
[gets] 13 17
[while] 5 9
[s] 11 11
[.] 12 12
[gets] 13 16
L13
[s] 7 8
[.] 8 9
[write] 9 14
[(] 14 15
[$] 15 16
[_] 16 17
[)] 17 18
[s] 7 7
[.] 8 8
[write] 9 13
[(] 14 14
[$] 15 15
[_] 16 16
[)] 17 17
L14
[end] 5 8
[end] 5 7
L15
[print] 5 10
[(] 10 11
[s] 11 12
[,] 12 13
[" is \n gone\n [ 14 37
[)] 103 104
L16
[s] 5 6
[.] 6 7
[close] 7 12
L17
[end] 3 6
[print] 5 9
[(] 10 10
[s] 11 11
[,] 12 12
[" is \n gone\n [ 14 36
L18
[end] 1 4
[)] 37 37
L19
[s] 5 5
[.] 6 6
[close] 7 11
L20
[end] 3 5
L21
[end] 1 3
EOF
Loading

0 comments on commit 10b205b

Please sign in to comment.