@Test
public void testReferencesToInnerClasses() throws Exception {
compile(true, "public class OuterClass { public class InnerClass { } }");
SymbolTable symTable = getSymbolTable();
ASTSymbolTypeResolver.getInstance().setSymbolTable(symTable);
symTable.pushScope();
SymbolType st = new SymbolType(getClassLoader().loadClass("OuterClass"));
symTable.pushSymbol("outerObject", ReferenceType.VARIABLE, st, null);
org.walkmod.javalang.ast.expr.Expression expr = (org.walkmod.javalang.ast.expr.Expression) ASTManager
.parse(Expression.class, "outerObject.new InnerClass()");
HashMap<String, Object> ctx = new HashMap<String, Object>();
expr.accept(expressionAnalyzer, ctx);
SymbolType type = (SymbolType) expr.getSymbolData();
Assert.assertNotNull(type);
Assert.assertEquals("OuterClass$InnerClass", type.getName());
}
TypeVisitorAdapterTest.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:javalang-compiler
作者:
评论列表
文章目录