Skip to content

Commit 375acb4

Browse files
committed
fixes
1 parent dc58568 commit 375acb4

File tree

5 files changed

+73
-17
lines changed

5 files changed

+73
-17
lines changed

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ dependencies {
5555

5656
testImplementation("org.junit.jupiter", "junit-jupiter-engine", "5.11.4")
5757
testImplementation("org.mockito", "mockito-core", "5.21.0")
58+
59+
testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.0.2")
5860
}
5961

6062
tasks.withType<JavaCompile> {

src/test/java/com/github/_1c_syntax/bsl/parser/testing/demo/DemoEmptyLexer.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,26 @@
2323

2424
import org.antlr.v4.runtime.CharStream;
2525
import org.antlr.v4.runtime.Lexer;
26+
import org.antlr.v4.runtime.Vocabulary;
27+
import org.antlr.v4.runtime.VocabularyImpl;
28+
import org.jspecify.annotations.NullMarked;
2629

30+
@NullMarked
2731
public class DemoEmptyLexer extends Lexer {
2832

33+
public static final String[] ruleNames = new String[0];
34+
public static final Vocabulary VOCABULARY = new VocabularyImpl(ruleNames, new String[0]);
35+
36+
@Override
37+
public String[] getChannelNames() {
38+
return new String[0];
39+
}
40+
41+
@Override
42+
public String[] getModeNames() {
43+
return new String[0];
44+
}
45+
2946
public DemoEmptyLexer(CharStream input) {
3047
super(input);
3148
}
@@ -35,8 +52,13 @@ public String[] getRuleNames() {
3552
return new String[0];
3653
}
3754

55+
@Override
56+
public Vocabulary getVocabulary() {
57+
return VOCABULARY;
58+
}
59+
3860
@Override
3961
public String getGrammarFileName() {
40-
return null;
62+
return "empty";
4163
}
4264
}

src/test/java/com/github/_1c_syntax/bsl/parser/testing/demo/DemoEmptyParser.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,32 @@
2323

2424
import org.antlr.v4.runtime.Parser;
2525
import org.antlr.v4.runtime.TokenStream;
26+
import org.antlr.v4.runtime.Vocabulary;
27+
import org.antlr.v4.runtime.VocabularyImpl;
28+
import org.jspecify.annotations.NullMarked;
2629

27-
30+
@NullMarked
2831
public class DemoEmptyParser extends Parser {
2932

33+
public static final String[] ruleNames = new String[0];
34+
public static final Vocabulary VOCABULARY = new VocabularyImpl(ruleNames, new String[0]);
35+
3036
public DemoEmptyParser(TokenStream input) {
3137
super(input);
3238
}
3339

3440
@Override
35-
public String[] getTokenNames() {
41+
public String[] getRuleNames() {
3642
return new String[0];
3743
}
3844

3945
@Override
40-
public String[] getRuleNames() {
41-
return new String[0];
46+
public Vocabulary getVocabulary() {
47+
return VOCABULARY;
4248
}
4349

4450
@Override
4551
public String getGrammarFileName() {
46-
return null;
52+
return "empty";
4753
}
4854
}

src/test/java/com/github/_1c_syntax/bsl/parser/testing/demo/DemoLexer.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,33 @@
2121
*/
2222
package com.github._1c_syntax.bsl.parser.testing.demo;
2323

24+
import org.antlr.v4.parse.BlockSetTransformer;
2425
import org.antlr.v4.runtime.CharStream;
2526
import org.antlr.v4.runtime.Lexer;
27+
import org.antlr.v4.runtime.Vocabulary;
28+
import org.antlr.v4.runtime.VocabularyImpl;
29+
import org.jspecify.annotations.NullMarked;
2630

31+
@NullMarked
2732
public class DemoLexer extends Lexer {
2833

34+
public static final String[] tokenNames = new String[]{"token1", "token2"};;
35+
public static final Vocabulary VOCABULARY = new VocabularyImpl(new String[0], tokenNames);
36+
37+
@Override
38+
public String[] getChannelNames() {
39+
return new String[0];
40+
}
41+
42+
@Override
43+
public String[] getModeNames() {
44+
return new String[0];
45+
}
46+
47+
public String[] getTokenNames() {
48+
return tokenNames;
49+
}
50+
2951
public DemoLexer(CharStream input) {
3052
super(input);
3153
}
@@ -36,12 +58,12 @@ public String[] getRuleNames() {
3658
}
3759

3860
@Override
39-
public String[] getTokenNames() {
40-
return new String[]{"token1", "token2"};
61+
public Vocabulary getVocabulary() {
62+
return VOCABULARY;
4163
}
4264

4365
@Override
4466
public String getGrammarFileName() {
45-
return null;
67+
return "fake";
4668
}
4769
}

src/test/java/com/github/_1c_syntax/bsl/parser/testing/demo/DemoParser.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,37 @@
2626
import org.antlr.v4.runtime.RecognitionException;
2727
import org.antlr.v4.runtime.RuleVersion;
2828
import org.antlr.v4.runtime.TokenStream;
29+
import org.antlr.v4.runtime.Vocabulary;
30+
import org.antlr.v4.runtime.VocabularyImpl;
2931
import org.antlr.v4.runtime.tree.ParseTree;
32+
import org.jspecify.annotations.NullMarked;
3033

3134
import java.util.Collections;
3235
import java.util.List;
3336

34-
37+
@NullMarked
3538
public class DemoParser extends Parser {
3639

3740
public static final String[] ruleNames = new String[]{"rule1", "rule2"};
41+
public static final Vocabulary VOCABULARY = new VocabularyImpl(ruleNames, new String[0]);
3842

3943
public DemoParser(TokenStream input) {
4044
super(input);
4145
}
4246

4347
@Override
44-
public String[] getTokenNames() {
45-
return new String[0];
48+
public String[] getRuleNames() {
49+
return ruleNames;
4650
}
4751

4852
@Override
49-
public String[] getRuleNames() {
50-
return ruleNames;
53+
public Vocabulary getVocabulary() {
54+
return VOCABULARY;
5155
}
5256

5357
@Override
5458
public String getGrammarFileName() {
55-
return null;
59+
return "fake";
5660
}
5761

5862
@Override
@@ -75,12 +79,12 @@ private static final class DemoRuleContext extends ParserRuleContext {
7579
private final List<ParseTree> children;
7680

7781
DemoRuleContext(int state) {
78-
super(new ParserRuleContext(), state);
82+
super(new ParserRuleContext(null, 1), state);
7983
children = Collections.emptyList();
8084
}
8185

8286
DemoRuleContext(int state, DemoRuleContext... children) {
83-
super(new ParserRuleContext(), state);
87+
super(new ParserRuleContext(null, 1), state);
8488
this.children = List.of(children);
8589
}
8690

0 commit comments

Comments
 (0)