use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue84 method variadicIssue.
@Test
public void variadicIssue() {
CompilationUnit cu = parseSample("Issue84");
final MethodCallExpr methodCall = Navigator.findMethodCall(cu, "variadicMethod").get();
final JavaParserFacade javaParserFacade = JavaParserFacade.get(new ReflectionTypeSolver());
final ResolvedType type = javaParserFacade.getType(methodCall);
assertEquals(String.class.getCanonicalName(), type.asReferenceType().getQualifiedName());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue144 method issue144WithCombinedTypeSolver.
@Test
public void issue144WithCombinedTypeSolver() {
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 CombinedTypeSolver(typeSolver, new ReflectionTypeSolver(true)));
assertEquals(true, javaParserFacade.solve(firstParameter).isSolved());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue116 method arrayTypeIsNotPartOfTheTree.
@Test
public void arrayTypeIsNotPartOfTheTree() {
CompilationUnit cu = parseSample("Issue116");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "JavaTest");
MethodDeclaration methodDeclaration = Navigator.demandMethod(clazz, "foo");
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
com.github.javaparser.ast.type.Type typeNode = methodDeclaration.getParameters().get(0).getType();
ResolvedType type = javaParserFacade.convert(typeNode, typeNode);
assertEquals("java.lang.String[]", type.describe());
ExpressionStmt expressionStmt = (ExpressionStmt) methodDeclaration.getBody().get().getStatements().get(0);
Expression argRef = expressionStmt.getExpression();
assertEquals("java.lang.String[]", javaParserFacade.getType(argRef).describe());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue156 method testFieldAccessThroughClassAndThis.
@Test
public void testFieldAccessThroughClassAndThis() {
CompilationUnit cu = parseSample("Issue156");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Issue156");
List<MethodCallExpr> methods = clazz.getChildNodes().get(2).getChildNodes().get(1).findAll(MethodCallExpr.class);
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
assertEquals("char", javaParserFacade.getType(methods.get(0)).describe());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue18 method typeDeclarationSuperClassImplicitlyIncludeObject.
@Test
public void typeDeclarationSuperClassImplicitlyIncludeObject() {
CompilationUnit cu = parseSample("Issue18");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Foo");
MethodDeclaration methodDeclaration = Navigator.demandMethod(clazz, "bar");
ExpressionStmt expr = (ExpressionStmt) methodDeclaration.getBody().get().getStatements().get(1);
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
ResolvedType type = javaParserFacade.getType(expr.getExpression());
assertEquals("java.lang.Object", type.describe());
}
Aggregations