use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class JavaParserAPIIntegrationTest method parameterDeclarationResolve.
@Test
public void parameterDeclarationResolve() throws IOException {
File f = adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java"));
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();
ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) cu.getType(0);
assertEquals("CompilationUnit", classDeclaration.getNameAsString());
MethodDeclaration methodDeclaration = classDeclaration.getMethodsByName("setComments").get(0);
Parameter declaration = methodDeclaration.getParameter(0);
ResolvedParameterDeclaration resolvedDeclaration = declaration.resolve();
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class JavaParserAPIIntegrationTest method constructorDeclarationResolve.
@Test
public void constructorDeclarationResolve() throws IOException {
File f = adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java"));
CompilationUnit cu = parseWithSymbolResolution(f);
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = (ClassOrInterfaceDeclaration) cu.getType(0);
ConstructorDeclaration constructorDeclaration = classOrInterfaceDeclaration.getDefaultConstructor().get();
ResolvedConstructorDeclaration resolvedConstructorDeclaration = constructorDeclaration.resolve();
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class JavaParserAPIIntegrationTest method classDeclarationResolve.
@Test
public void classDeclarationResolve() throws IOException {
File f = adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java"));
CompilationUnit cu = parseWithSymbolResolution(f);
ClassOrInterfaceDeclaration declaration = (ClassOrInterfaceDeclaration) cu.getType(0);
declaration.resolve();
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class Issue144 method issue144.
@Test(expected = UnsolvedSymbolException.class)
public void issue144() {
CompilationUnit cu = parseSampleWithStandardExtension("issue144/HelloWorld");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "HelloWorld");
ExpressionStmt expressionStmt = (ExpressionStmt) clazz.getMethodsByName("main").get(0).getBody().get().getStatement(0);
MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
Expression firstParameter = methodCallExpr.getArgument(0);
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
javaParserFacade.solve(firstParameter).isSolved();
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class Issue144 method issue144WithReflectionTypeSolver.
@Test
public void issue144WithReflectionTypeSolver() {
CompilationUnit cu = parseSampleWithStandardExtension("issue144/HelloWorld");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "HelloWorld");
ExpressionStmt expressionStmt = (ExpressionStmt) clazz.getMethodsByName("main").get(0).getBody().get().getStatement(0);
MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
Expression firstParameter = methodCallExpr.getArgument(0);
JavaParserFacade javaParserFacade = JavaParserFacade.get(new ReflectionTypeSolver(true));
assertEquals(true, javaParserFacade.solve(firstParameter).isSolved());
}
Aggregations