Search in sources :

Example 6 with EnumDeclarationContext

use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.EnumDeclarationContext 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());
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) EnumDeclarationContext(com.github.javaparser.symbolsolver.javaparsermodel.contexts.EnumDeclarationContext) Context(com.github.javaparser.symbolsolver.core.resolution.Context) MemoryTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver) EnumDeclarationContext(com.github.javaparser.symbolsolver.javaparsermodel.contexts.EnumDeclarationContext) AbstractResolutionTest(com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest) Test(org.junit.Test)

Aggregations

CompilationUnit (com.github.javaparser.ast.CompilationUnit)6 Context (com.github.javaparser.symbolsolver.core.resolution.Context)6 EnumDeclarationContext (com.github.javaparser.symbolsolver.javaparsermodel.contexts.EnumDeclarationContext)6 AbstractResolutionTest (com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest)6 MemoryTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.MemoryTypeSolver)6 Test (org.junit.Test)6 Value (com.github.javaparser.symbolsolver.model.resolution.Value)3