Search in sources :

Example 11 with ParserConfiguration

use of com.github.javaparser.ParserConfiguration in project javaparser by javaparser.

the class JavaParserAPIIntegrationTest method annotationMemberDeclarationResolve.

@Test
public void annotationMemberDeclarationResolve() throws IOException {
    File f = adaptPath(new File("src/test/resources/Annotations.java.txt"));
    ParserConfiguration parserConfiguration = new ParserConfiguration();
    parserConfiguration.setSymbolResolver(new JavaSymbolSolver(typeSolver));
    CompilationUnit cu = new JavaParser(parserConfiguration).parse(ParseStart.COMPILATION_UNIT, new StreamProvider(new FileInputStream(f))).getResult().get();
    AnnotationDeclaration declaration = (AnnotationDeclaration) cu.getType(2);
    assertEquals("MyAnnotationWithFields", declaration.getNameAsString());
    AnnotationMemberDeclaration memberDeclaration = (AnnotationMemberDeclaration) declaration.getMember(0);
    ResolvedAnnotationMemberDeclaration resolvedDeclaration = memberDeclaration.resolve();
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) JavaParser(com.github.javaparser.JavaParser) StreamProvider(com.github.javaparser.StreamProvider) File(java.io.File) FileInputStream(java.io.FileInputStream) ParserConfiguration(com.github.javaparser.ParserConfiguration) Test(org.junit.Test)

Aggregations

ParserConfiguration (com.github.javaparser.ParserConfiguration)11 JavaParser (com.github.javaparser.JavaParser)9 CompilationUnit (com.github.javaparser.ast.CompilationUnit)5 StreamProvider (com.github.javaparser.StreamProvider)3 FileInputStream (java.io.FileInputStream)3 Path (java.nio.file.Path)3 Test (org.junit.Test)3 SourceZip (com.github.javaparser.utils.SourceZip)2 File (java.io.File)2 When (org.jbehave.core.annotations.When)2 JavaParser.parseVariableDeclarationExpr (com.github.javaparser.JavaParser.parseVariableDeclarationExpr)1 ParseProblemException (com.github.javaparser.ParseProblemException)1 ParseResult (com.github.javaparser.ParseResult)1 COMPILATION_UNIT (com.github.javaparser.ParseStart.COMPILATION_UNIT)1 Providers.provider (com.github.javaparser.Providers.provider)1 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)1 SimpleName (com.github.javaparser.ast.expr.SimpleName)1 VariableDeclarationExpr (com.github.javaparser.ast.expr.VariableDeclarationExpr)1 Java5Validator (com.github.javaparser.ast.validator.Java5Validator)1 PrettyPrinter (com.github.javaparser.printer.PrettyPrinter)1