use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class MethodsResolutionLogicTest method compatibilityShouldConsiderAlsoTypeVariablesNegative.
@Test
public void compatibilityShouldConsiderAlsoTypeVariablesNegative() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolver.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
ResolvedReferenceType stringType = (ResolvedReferenceType) ReflectionFactory.typeUsageFor(String.class, typeSolver);
ResolvedReferenceType rawClassType = (ResolvedReferenceType) ReflectionFactory.typeUsageFor(Class.class, typeSolver);
assertEquals(true, rawClassType.isRawType());
ResolvedReferenceType classOfStringType = (ResolvedReferenceType) rawClassType.replaceTypeVariables(rawClassType.getTypeDeclaration().getTypeParameters().get(0), stringType);
MethodUsage mu = constructorDeclaration.getAllMethods().stream().filter(m -> m.getDeclaration().getSignature().equals("isThrows(java.lang.Class<? extends java.lang.Throwable>)")).findFirst().get();
assertEquals(false, MethodResolutionLogic.isApplicable(mu, "isThrows", ImmutableList.of(classOfStringType), typeSolver));
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class MethodsResolutionLogicTest method compatibilityShouldConsiderAlsoTypeVariablesPositive.
@Test
public void compatibilityShouldConsiderAlsoTypeVariablesPositive() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolver.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
ResolvedReferenceType runtimeException = (ResolvedReferenceType) ReflectionFactory.typeUsageFor(RuntimeException.class, typeSolver);
ResolvedReferenceType rawClassType = (ResolvedReferenceType) ReflectionFactory.typeUsageFor(Class.class, typeSolver);
ResolvedReferenceType classOfRuntimeType = (ResolvedReferenceType) rawClassType.replaceTypeVariables(rawClassType.getTypeDeclaration().getTypeParameters().get(0), runtimeException);
MethodUsage mu = constructorDeclaration.getAllMethods().stream().filter(m -> m.getDeclaration().getSignature().equals("isThrows(java.lang.Class<? extends java.lang.Throwable>)")).findFirst().get();
assertEquals(true, MethodResolutionLogic.isApplicable(mu, "isThrows", ImmutableList.of(classOfRuntimeType), typeSolver));
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class SymbolSolverTest method testSolveSymbolToInheritedPublicField.
@Test
public void testSolveSymbolToInheritedPublicField() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
SymbolReference<? extends ResolvedValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "NODE_BY_BEGIN_POSITION");
assertEquals(true, res.isSolved());
assertEquals(true, res.getCorrespondingDeclaration().isField());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class SymbolSolverTest method testSolveSymbolToDeclaredField.
@Test
public void testSolveSymbolToDeclaredField() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
SymbolReference<? extends ResolvedValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "name");
assertEquals(true, res.isSolved());
assertEquals(true, res.getCorrespondingDeclaration().isField());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class SymbolSolverTest method testSolveSymbolToInheritedPrivateField.
@Test
public void testSolveSymbolToInheritedPrivateField() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
SymbolReference<? extends ResolvedValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "parentNode");
assertEquals(false, res.isSolved());
}
Aggregations