use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class EnumDeclarationContextResolutionTest method solveSymbolReferringToDeclaredInstanceField.
@Test
public void solveSymbolReferringToDeclaredInstanceField() {
CompilationUnit cu = parseSample("AnEnum");
com.github.javaparser.ast.body.EnumDeclaration enumDeclaration = Navigator.demandEnum(cu, "MyEnum");
Context context = new EnumDeclarationContext(enumDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("i", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("int", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class EnumDeclarationContextResolutionTest method solveSymbolReferringToDeclaredStaticField.
@Test
public void solveSymbolReferringToDeclaredStaticField() {
CompilationUnit cu = parseSample("AnEnum");
com.github.javaparser.ast.body.EnumDeclaration enumDeclaration = Navigator.demandEnum(cu, "MyEnum");
Context context = new EnumDeclarationContext(enumDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("j", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("long", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class EnumDeclarationContextResolutionTest method solveSymbolAsValueReferringToDeclaredStaticField.
@Test
public void solveSymbolAsValueReferringToDeclaredStaticField() {
CompilationUnit cu = parseSample("AnEnum");
com.github.javaparser.ast.body.EnumDeclaration enumDeclaration = Navigator.demandEnum(cu, "MyEnum");
Context context = new EnumDeclarationContext(enumDeclaration, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("j", new MemoryTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("long", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class EnumDeclarationContextResolutionTest method solveSymbolReferringToValue.
@Test
public void solveSymbolReferringToValue() {
CompilationUnit cu = parseSample("AnEnum");
com.github.javaparser.ast.body.EnumDeclaration enumDeclaration = Navigator.demandEnum(cu, "MyEnum");
Context context = new EnumDeclarationContext(enumDeclaration, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("E1", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("MyEnum", ref.getCorrespondingDeclaration().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.
the class DefaultPackageTest method aClassInDefaultPackageCanBeAccessedFromOutsideTheDefaultPackageWithoutImportingIt.
@Test(expected = UnsolvedSymbolException.class)
public void aClassInDefaultPackageCanBeAccessedFromOutsideTheDefaultPackageWithoutImportingIt() {
String code = "package myPackage; class A extends B {}";
MemoryTypeSolver memoryTypeSolver = new MemoryTypeSolver();
memoryTypeSolver.addDeclaration("B", new MyClassDeclaration("B"));
ResolvedType resolvedType = JavaParserFacade.get(memoryTypeSolver).convertToUsage(JavaParser.parse(code).getClassByName("A").get().getExtendedTypes(0));
assertEquals("B", resolvedType.asReferenceType().getQualifiedName());
}
Aggregations