Search in sources :

Example 1 with LexerlessGrammarBuilder

use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.

the class ClassDeclarationTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.CLASS_DECLARATION).matches("class identifier <T, U extends Foo & Bar> extends Foo implements Foo, Bar<Integer> {}").matches("class identifier <T, U extends Foo & Bar> extends Foo {}").matches("class identifier <T, U extends Foo & Bar> {}").matches("class identifier {}");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 2 with LexerlessGrammarBuilder

use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.

the class FormalParameterDeclsTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.FORMAL_PARAMETER_DECLS).matches("type foo").matches("final type foo, type bar").matches("@Foo type ... foo").matches("final final type foo").matches("@Foo @Bar type foo").matches("@Foo Foo this").matches("@Foo final @Bar final type foo");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 3 with LexerlessGrammarBuilder

use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.

the class BlockStatementsTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.BLOCK_STATEMENTS).notMatches(// FIXME should match but issue in the way we test matching
    "").matches(";").matches("int a; foo();");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 4 with LexerlessGrammarBuilder

use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.

the class VariableDeclaratorsTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.VARIABLE_DECLARATORS).matches("foo , foo[] , foo[] = {}, foo = 42").matches("foo[] = 42 , foo").matches("foo");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 5 with LexerlessGrammarBuilder

use of org.sonar.sslr.grammar.LexerlessGrammarBuilder in project sonar-java by SonarSource.

the class BlockStatementTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.BLOCK_STATEMENT).matches("int a;").matches("public class A {}").matches("private enum A {}").matches(";").matches("foo();");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 LexerlessGrammarBuilder (org.sonar.sslr.grammar.LexerlessGrammarBuilder)22 ActionParser (com.sonar.sslr.api.typed.ActionParser)1 JavaNodeBuilder (org.sonar.java.ast.parser.JavaNodeBuilder)1 TreeFactory (org.sonar.java.ast.parser.TreeFactory)1 AnnotationTreeImpl (org.sonar.java.model.declaration.AnnotationTreeImpl)1 EnumConstantTreeImpl (org.sonar.java.model.declaration.EnumConstantTreeImpl)1 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)1 Tree (org.sonar.plugins.java.api.tree.Tree)1