use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method staticMethodCallsFromInnerClasses.
@Test
public void staticMethodCallsFromInnerClasses() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("InnerClassDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr methodCall = Navigator.findMethodCall(mainMethod, "methodCall").get();
MethodCallExpr innerMethodCall = Navigator.findMethodCall(mainMethod, "innerMethodCall").get();
MethodCallExpr innerInnerMethodCall = Navigator.findMethodCall(mainMethod, "innerInnerMethodCall").get();
assertEquals(true, javaParserFacade.solve(methodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerInnerMethodCall).isSolved());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method staticFieldCallsFromInnerClasses.
@Test
public void staticFieldCallsFromInnerClasses() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("InnerStaticClassFieldDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr methodCallWithNestedStaticFieldParam = Navigator.findMethodCall(mainMethod, "parseInt").get();
assertEquals(true, javaParserFacade.solve(methodCallWithNestedStaticFieldParam).isSolved());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class Issue1364 method setup.
@Before
public void setup() {
ClassOrInterfaceDeclaration fakeObject = new ClassOrInterfaceDeclaration();
fakeObject.setName(new SimpleName("java.lang.Object"));
TypeSolver typeSolver = new TypeSolver() {
@Override
public TypeSolver getParent() {
return null;
}
@Override
public void setParent(TypeSolver parent) {
}
@Override
public SymbolReference<ResolvedReferenceTypeDeclaration> tryToSolveType(String name) {
if ("java.lang.Object".equals(name)) {
// custom handling
return SymbolReference.solved(new JavaParserClassDeclaration(fakeObject, this));
}
return SymbolReference.unsolved(ResolvedReferenceTypeDeclaration.class);
}
};
ParserConfiguration config = new ParserConfiguration();
config.setSymbolResolver(new JavaSymbolSolver(typeSolver));
javaParser = new JavaParser(config);
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class Issue113 method issue113superClassIsResolvedCorrectly.
@Test
public void issue113superClassIsResolvedCorrectly() throws FileNotFoundException {
String pathToSourceFile = adaptPath("src/test/resources/issue113/com/foo/Widget.java");
CompilationUnit cu = JavaParser.parse(new File(pathToSourceFile));
JavaParserClassDeclaration jssExtendedWidget = new JavaParserClassDeclaration(cu.getClassByName("Widget").get(), typeSolver);
ResolvedReferenceType superClass = jssExtendedWidget.getSuperClass();
assertEquals("com.foo.base.Widget", superClass.getQualifiedName());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class SymbolSolverTest method testSolveSymbolUnexisting.
@Test
public void testSolveSymbolUnexisting() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
SymbolReference<? extends ResolvedValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "unexisting");
assertEquals(false, res.isSolved());
}
Aggregations