Search in sources :

Example 36 with MemoryTypeSolver

use of com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver in project javaparser by javaparser.

the class MethodContextResolutionTest method solveTypeRefToLocalClass.

@Test
public void solveTypeRefToLocalClass() {
    CompilationUnit cu = parseSample("MethodWithTypes");
    ClassOrInterfaceDeclaration cd = Navigator.demandClass(cu, "Main");
    MethodDeclaration md = Navigator.demandMethod(cd, "methodWithLocalTypes");
    Context context = new MethodContext(md, typeSolver);
    SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("LocalClass", new MemoryTypeSolver());
    assertEquals(true, ref.isSolved());
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) MethodContext(com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodContext) Context(com.github.javaparser.symbolsolver.core.resolution.Context) MemoryTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) MethodContext(com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodContext) ResolvedTypeDeclaration(com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration) AbstractResolutionTest(com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest) Test(org.junit.Test)

Aggregations

MemoryTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver)36 Test (org.junit.Test)36 CompilationUnit (com.github.javaparser.ast.CompilationUnit)33 AbstractResolutionTest (com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest)33 Context (com.github.javaparser.symbolsolver.core.resolution.Context)32 CompilationUnitContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.CompilationUnitContext)25 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)24 ClassOrInterfaceDeclarationContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.ClassOrInterfaceDeclarationContext)23 ResolvedTypeDeclaration (com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration)11 Value (com.github.javaparser.symbolsolver.model.resolution.Value)9 ResolvedType (com.github.javaparser.resolution.types.ResolvedType)7 EnumDeclarationContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.EnumDeclarationContext)6 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)2 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 ResolvedReferenceTypeDeclaration (com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration)1 MethodContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodContext)1