[typescript] Update lexer for PMD 7
This commit is contained in:
@ -5,17 +5,14 @@
|
|||||||
package net.sourceforge.pmd.lang.typescript.cpd;
|
package net.sourceforge.pmd.lang.typescript.cpd;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.CharStream;
|
import org.antlr.v4.runtime.CharStream;
|
||||||
|
import org.antlr.v4.runtime.Lexer;
|
||||||
|
|
||||||
import net.sourceforge.pmd.cpd.AntlrTokenizer;
|
import net.sourceforge.pmd.cpd.internal.AntlrTokenizer;
|
||||||
import net.sourceforge.pmd.cpd.SourceCode;
|
|
||||||
import net.sourceforge.pmd.lang.antlr.AntlrTokenManager;
|
|
||||||
import net.sourceforge.pmd.lang.typescript.ast.TypeScriptLexer;
|
import net.sourceforge.pmd.lang.typescript.ast.TypeScriptLexer;
|
||||||
|
|
||||||
public class TypescriptTokenizer extends AntlrTokenizer {
|
public class TypescriptTokenizer extends AntlrTokenizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AntlrTokenManager getLexerForSource(SourceCode sourceCode) {
|
protected Lexer getLexerForSource(CharStream charStream) {
|
||||||
CharStream charStream = AntlrTokenizer.getCharStreamFromSourceCode(sourceCode);
|
return new TypeScriptLexer(charStream);
|
||||||
return new AntlrTokenManager(new TypeScriptLexer(charStream), sourceCode.getFileName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ package net.sourceforge.pmd.lang.typescript.cpd;
|
|||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import net.sourceforge.pmd.cpd.Tokenizer;
|
import net.sourceforge.pmd.cpd.Tokenizer;
|
||||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||||
|
|
||||||
public class TypescriptTokenizerTest extends CpdTextComparisonTest {
|
class TypescriptTokenizerTest extends CpdTextComparisonTest {
|
||||||
|
|
||||||
public TypescriptTokenizerTest() {
|
TypescriptTokenizerTest() {
|
||||||
super(".ts");
|
super(".ts");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,12 +28,12 @@ public class TypescriptTokenizerTest extends CpdTextComparisonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void greeterTest() {
|
void greeterTest() {
|
||||||
doTest("greeter");
|
doTest("greeter");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void apiSampleWatchTest() {
|
void apiSampleWatchTest() {
|
||||||
doTest("APISample_Watch");
|
doTest("APISample_Watch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,35 @@
|
|||||||
[Image] or [Truncated image[ Bcol Ecol
|
[Image] or [Truncated image[ Bcol Ecol
|
||||||
L3
|
L3
|
||||||
[function] 1 8
|
[function] 1 9
|
||||||
[greeter] 10 16
|
[greeter] 10 17
|
||||||
[(] 17 17
|
[(] 17 18
|
||||||
[person] 18 23
|
[person] 18 24
|
||||||
[)] 24 24
|
[)] 24 25
|
||||||
[{] 26 26
|
[{] 26 27
|
||||||
L4
|
L4
|
||||||
[return] 3 8
|
[return] 3 9
|
||||||
["Hello, "] 10 18
|
["Hello, "] 10 19
|
||||||
[+] 20 20
|
[+] 20 21
|
||||||
[person] 22 27
|
[person] 22 28
|
||||||
[;] 28 28
|
[;] 28 29
|
||||||
L5
|
L5
|
||||||
[}] 1 1
|
[}] 1 2
|
||||||
L7
|
L7
|
||||||
[let] 1 3
|
[let] 1 4
|
||||||
[user] 5 8
|
[user] 5 9
|
||||||
[=] 10 10
|
[=] 10 11
|
||||||
["Jane User"] 12 22
|
["Jane User"] 12 23
|
||||||
[;] 23 23
|
[;] 23 24
|
||||||
L9
|
L9
|
||||||
[document] 1 8
|
[document] 1 9
|
||||||
[.] 9 9
|
[.] 9 10
|
||||||
[body] 10 13
|
[body] 10 14
|
||||||
[.] 14 14
|
[.] 14 15
|
||||||
[textContent] 15 25
|
[textContent] 15 26
|
||||||
[=] 27 27
|
[=] 27 28
|
||||||
[greeter] 29 35
|
[greeter] 29 36
|
||||||
[(] 36 36
|
[(] 36 37
|
||||||
[user] 37 40
|
[user] 37 41
|
||||||
[)] 41 41
|
[)] 41 42
|
||||||
[;] 42 42
|
[;] 42 43
|
||||||
EOF
|
EOF
|
||||||
|
Reference in New Issue
Block a user