Search in sources :

Example 6 with LexerlessGrammarBuilder

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

the class CatchClauseTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.CATCH_CLAUSE).matches("catch (Exception e) {}").matches("catch (Exception | Error e) {}");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 7 with LexerlessGrammarBuilder

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

the class VariableDeclaratorTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.VARIABLE_DECLARATOR).matches("identifier [] [] = 0").notMatches(// FIXME missing bracket token
    "identifier [] []").matches("identifier [] = {}").notMatches(// FIXME missing bracket token
    "identifier []").matches("identifier = 0").matches("identifier").matches("enum");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 8 with LexerlessGrammarBuilder

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

the class TypeParametersTest method ok.

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

Example 9 with LexerlessGrammarBuilder

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

the class TypeDeclarationTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.TYPE_DECLARATION).matches("class Foo {}").matches("enum Foo {}").matches("interface Foo {}").matches("@interface Foo {}").matches("public class Foo {}").matches("public private class Foo {}").matches(";");
}
Also used : LexerlessGrammarBuilder(org.sonar.sslr.grammar.LexerlessGrammarBuilder) Test(org.junit.Test)

Example 10 with LexerlessGrammarBuilder

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

the class FormalParameterTest method ok.

@Test
public void ok() {
    LexerlessGrammarBuilder b = JavaLexer.createGrammarBuilder();
    assertThat(b, JavaLexer.FORMAL_PARAMETER).matches("int foo").notMatches(// FIXME missing [] tokens
    "final List<Integer> foo[]").matches("@Foo int foo").notMatches("@Foo Type this").matches("final final int foo").matches("@Foo @Bar int foo").matches("@Foo final @Bar final int 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