當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectCreationExpr.getBeginLine方法代碼示例

本文整理匯總了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;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:12,代碼來源:CloneVisitor.java

示例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;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:78,代碼來源:ScopeLoader.java


注:本文中的org.walkmod.javalang.ast.expr.ObjectCreationExpr.getBeginLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。