Search in sources :

Example 16 with LexerlessGrammarBuilder

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

the class ResourceTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.RESOURCE).matches("final List<Integer> foo = 0").matches("final @Nullable List<Integer> foo = 0").matches("List<Integer> foo[] = foo");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 17 with LexerlessGrammarBuilder

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

the class InterfaceDeclarationTest method ok.

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

Example 18 with LexerlessGrammarBuilder

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

the class FormalParameterDeclsRestTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.FORMAL_PARAMETERS_DECLS_REST).matches("foo").matches("this").matches("foo , type bar").matches("this , type bar").matches("Main.this , type bar").matches(// invalid syntax but supported by our grammar
    "foo, type this").matches("... foo").matches("@Foo ... foo");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 19 with LexerlessGrammarBuilder

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

the class FormalParametersTest method ok.

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

Example 20 with LexerlessGrammarBuilder

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

the class ModifiersTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.MODIFIERS).matches("@Nullable").matches("public").matches("protected").matches("private").matches("static").matches("abstract").matches("final").matches("native").matches("synchronized").matches("transient").matches("volatile").matches("strictfp").matches("@NotNull public static @Nullable final");
}
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