REVERT ME Make end column inclusive

This is for consistency with PMD 6, on pmd 7 this commit
may be reverted
This commit is contained in:
Clément Fournier
2020-09-01 17:59:49 +02:00
parent dd440eb14a
commit 10b205b5e2
7 changed files with 868 additions and 865 deletions

View File

@ -86,6 +86,8 @@ public class AnyTokenizer implements Tokenizer {
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 {

View File

@ -34,13 +34,13 @@ public class AnyTokenizerTest {
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) {

View File

@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.perl.cpd;
import java.util.Properties;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;
import net.sourceforge.pmd.cpd.PerlLanguage;
@ -23,7 +22,7 @@ public class PerlTokenizerTest extends CpdTextComparisonTest {
}
@Override
public Tokenizer newTokenizer(@NonNull Properties properties) {
public Tokenizer newTokenizer(Properties properties) {
return new PerlLanguage().getTokenizer();
}

View File

@ -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

View File

@ -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

View File

@ -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] 2 4
[=] 5 6
[gs] 7 9
[.] 9 10
[accept] 10 16
[ns] 2 3
[=] 5 5
[gs] 7 8
[.] 9 9
[accept] 10 15
L9
[print] 2 7
[(] 7 8
[ns] 8 10
[,] 10 11
[" is accepted"] 12 26
[)] 26 27
[print] 2 6
[(] 7 7
[ns] 8 9
[,] 10 10
[" is accepted"] 12 25
[)] 26 26
L10
[Thread] 2 8
[.] 8 9
[start] 9 14
[do] 15 17
[Thread] 2 7
[.] 8 8
[start] 9 13
[do] 15 16
L11
[s] 3 4
[=] 5 6
[ns] 7 9
[s] 3 3
[=] 5 5
[ns] 7 8
L12
[while] 3 8
[s] 9 10
[.] 10 11
[gets] 11 15
[while] 3 7
[s] 9 9
[.] 10 10
[gets] 11 14
L13
[s] 4 5
[.] 5 6
[write] 6 11
[(] 11 12
[$] 12 13
[_] 13 14
[)] 14 15
[s] 4 4
[.] 5 5
[write] 6 10
[(] 11 11
[$] 12 12
[_] 13 13
[)] 14 14
L14
[end] 3 6
[end] 3 5
L15
[print] 3 8
[(] 8 9
[s] 9 10
[,] 10 11
[" is \n\t\t gone\n\t\t [ 12 35
[)] 95 96
L16
[s] 3 4
[.] 4 5
[close] 5 10
L17
[end] 2 5
[print] 3 7
[(] 8 8
[s] 9 9
[,] 10 10
[" is \n\t\t gone\n\t\t [ 12 34
L18
[end] 1 4
[)] 35 35
L19
[s] 3 3
[.] 4 4
[close] 5 9
L20
[end] 2 4
L21
[end] 1 3
EOF