use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.
the class EnumDeclarationTest method ok.
@Test
public void ok() {
LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
assertThat(b, JavaLexer.ENUM_DECLARATION).matches("enum identifier implements Foo, Bar<Integer> {}");
}
use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.
the class EnumConstantTest method test_annotation.
@Test
public void test_annotation() {
LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
ActionParser<Tree> parser = new ActionParser<>(StandardCharsets.UTF_8, b, JavaGrammar.class, new TreeFactory(), new JavaNodeBuilder(), JavaLexer.ENUM_CONSTANT);
EnumConstantTreeImpl node = (EnumConstantTreeImpl) parser.parse("@Foo CONSTANT");
assertThat(node.modifiers().size()).isEqualTo(1);
assertThat(((IdentifierTree) ((AnnotationTreeImpl) node.modifiers().get(0)).annotationType()).identifierToken().text()).isEqualTo("Foo");
}
use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.
the class EnumConstantTest method ok.
@Test
public void ok() {
LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
assertThat(b, JavaLexer.ENUM_CONSTANT).matches("identifier").matches("identifier,").matches("@Foo identifier").matches("@Foo identifier()").matches("@Foo identifier {}").matches("@Foo identifier() {}");
}
use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.
the class LocalVariableDeclarationStatementTest method ok.
@Test
public void ok() {
LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
assertThat(b, JavaLexer.LOCAL_VARIABLE_DECLARATION_STATEMENT).matches("final int a ;").matches("@Foo List<Integer> a, b ;").matches("int a;");
}
use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.
the class BlockTest method ok.
@Test
public void ok() {
LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
assertThat(b, JavaLexer.BLOCK).matches("{ ; }").matches("{ int a; foo(); }");
}
Aggregations