本文整理汇总了Java中org.walkmod.javalang.ast.expr.ObjectCreationExpr.getBeginLine方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectCreationExpr.getBeginLine方法的具体用法?Java ObjectCreationExpr.getBeginLine怎么用?Java ObjectCreationExpr.getBeginLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.walkmod.javalang.ast.expr.ObjectCreationExpr
的用法示例。
在下文中一共展示了ObjectCreationExpr.getBeginLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入方法依赖的package包/类
@Override
public Node visit(ObjectCreationExpr _n, Object _arg) {
Expression scope = cloneNodes(_n.getScope(), _arg);
ClassOrInterfaceType type_ = cloneNodes(_n.getType(), _arg);
List<Type> typeArgs = visit(_n.getTypeArgs(), _arg);
List<Expression> args = visit(_n.getArgs(), _arg);
List<BodyDeclaration> anonymousBody = visit(_n.getAnonymousClassBody(), _arg);
ObjectCreationExpr r = new ObjectCreationExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(),
_n.getEndColumn(), scope, type_, typeArgs, args, anonymousBody);
return r;
}
示例2: visit
import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //导入方法依赖的package包/类
@Override
public Scope visit(ObjectCreationExpr n, SymbolTable symbolTable) {
List<BodyDeclaration> body = n.getAnonymousClassBody();
if (body != null) {
SymbolType st = ASTSymbolTypeResolver.getInstance().valueOf(n.getType());
Scope scope = new Scope();
symbolTable.pushScope(scope);
List<BodyDeclaration> members = n.getAnonymousClassBody();
boolean anonymousClass = members != null;
if (anonymousClass) {
List<SymbolAction> actions = new LinkedList<SymbolAction>();
actions.add(new LoadTypeParamsAction());
actions.add(new LoadTypeDeclarationsAction(typeTable));
actions.add(new LoadFieldDeclarationsAction(actionProvider));
actions.add(new LoadMethodDeclarationsAction(actionProvider, expressionTypeAnalyzer));
actions.add(new LoadEnumConstantLiteralsAction());
if (actionProvider != null) {
actions.addAll(actionProvider.getActions(n));
}
Symbol<?> superSymbol =
symbolTable.pushSymbol("super", ReferenceType.VARIABLE, st, n, (List<SymbolAction>) null);
if (st == null) {
throw new RuntimeException("Error resolving " + n.getType().toString() + " in " + n.toString()
+ ", line: " + n.getBeginLine());
}
Class<?> superTypeClass = st.getClazz();
Symbol<?> superType = symbolTable.findSymbol(superTypeClass.getCanonicalName(), ReferenceType.TYPE);
if (superType != null) {
superSymbol.setInnerScope(superType.getInnerScope());
}
String name = symbolTable.generateAnonymousClass();
SymbolType type = SymbolType.anonymousClassOf(name);
try {
type.getClazz();
} catch (TypeNotFoundException e) {
// The java compiler does not generate classes for code disabled via conditional compilation.
// For definition of conditional compilation see
// JLS 14.21. Unreachable Statements,
// http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.21
if (ConditionalCompilationUtil.isDisabledCode(n)) {
// if we have symbol data of base type we keep that.
final SymbolType base = (SymbolType) n.getSymbolData();
type = base != null ? base.markDisabledCode() : new SymbolType(Object.class).markDisabledCode();
} else {
throw e;
}
}
Symbol<?> anonymousType = symbolTable.pushSymbol(name, ReferenceType.TYPE, type, n);
anonymousType.setInnerScope(scope);
Symbol<ObjectCreationExpr> thisSymbol =
new Symbol<ObjectCreationExpr>("this", type, n, ReferenceType.VARIABLE, false, actions);
scope.setRootSymbol(thisSymbol);
thisSymbol.setInnerScope(scope);
symbolTable.pushSymbol(thisSymbol);
for (BodyDeclaration member : members) {
if (member instanceof TypeDeclaration) {
process((TypeDeclaration) member, symbolTable);
}
}
}
symbolTable.popScope(true);
return scope;
}
return null;
}