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


Java ObjectCreationExpr類代碼示例

本文整理匯總了Java中org.walkmod.javalang.ast.expr.ObjectCreationExpr的典型用法代碼示例。如果您正苦於以下問題:Java ObjectCreationExpr類的具體用法?Java ObjectCreationExpr怎麽用?Java ObjectCreationExpr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectCreationExpr類屬於org.walkmod.javalang.ast.expr包,在下文中一共展示了ObjectCreationExpr類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadThisSymbol

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
private void loadThisSymbol(ObjectCreationExpr n, A arg) {
    if (AnonymousClassUtil.isAnonymousClass(n) && AnonymousClassUtil.needsSymbolData(n)) {
        ScopeLoader scopeLoader = new ScopeLoader(typeTable, expressionTypeAnalyzer, actionProvider);
        Scope scope = n.accept(scopeLoader, symbolTable);
        if (scope != null) {
            symbolTable.pushScope(scope);
        }
        if (n.getAnonymousClassBody() != null) {
            for (BodyDeclaration member : n.getAnonymousClassBody()) {
                member.accept(this, arg);
            }
        }
        if (scope != null) {
            symbolTable.popScope();
        }
    }

}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:19,代碼來源:SymbolVisitorAdapter.java

示例2: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void visit(ObjectCreationExpr n, A arg) {

    loadThisSymbol(n, arg);
    SymbolType[] argsType = argsType(n.getArgs());
    SymbolType scopeType = (SymbolType) n.getType().getSymbolData();
    symbolTable.lookUpSymbolForRead(scopeType.getClazz().getSimpleName(), n, scopeType, argsType,
            ReferenceType.METHOD);

    List<Type> typeargs = n.getTypeArgs();

    if (typeargs != null) {
        for (Type type : typeargs) {
            type.accept(this, arg);
        }
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:18,代碼來源:SymbolVisitorAdapter.java

示例3: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
public void visit(ObjectCreationExpr n, T context) {
    boolean restore = false;
    if (startingNode == null) {
        startingNode = n;
        restore = true;
    }
    List<BodyDeclaration> members = n.getAnonymousClassBody();
    if (members != null) {
        SymbolType st = symbolTable.getType("this", ReferenceType.VARIABLE);
        n.setSymbolData(st);
        String name = st.getName();
        String oldCtx = contextName;
        contextName = name;
        processMembers(members, context);
        contextName = oldCtx;
    }
    if (restore) {
        startingNode = null;
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:21,代碼來源:TypesLoaderVisitor.java

示例4: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void visit(ObjectCreationExpr n, A arg) {

    if (n.getScope() != null) {
        n.getScope().accept(this, arg);
    }
    if (n.getTypeArgs() != null) {
        for (Type t : n.getTypeArgs()) {
            t.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);

    if (!AnonymousClassUtil.isAnonymousClass(n) || AnonymousClassUtil.needsSymbolData(n)) {
        SymbolType st = (SymbolType) n.getType().getSymbolData();
        resolveConstructor(n, n.getArgs(), st, arg);
    }

    // we need to update the symbol table
    if (semanticVisitor != null) {
        n.accept(semanticVisitor, arg);
    }

}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:25,代碼來源:TypeVisitorAdapter.java

示例5: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
public R visit(ObjectCreationExpr n, A arg) {
    if (n.getScope() != null) {
        n.getScope().accept(this, arg);
    }
    if (n.getTypeArgs() != null) {
        for (Type t : n.getTypeArgs()) {
            t.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);
    if (n.getArgs() != null) {
        for (Expression e : n.getArgs()) {
            e.accept(this, arg);
        }
    }
    if (n.getAnonymousClassBody() != null) {
        for (BodyDeclaration member : n.getAnonymousClassBody()) {
            member.accept(this, arg);
        }
    }
    return null;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:23,代碼來源:GenericVisitorAdapter.java

示例6: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
public Boolean visit(ObjectCreationExpr n1, Node arg) {
    ObjectCreationExpr n2 = (ObjectCreationExpr) arg;
    if (!nodeEquals(n1.getScope(), n2.getScope())) {
        return Boolean.FALSE;
    }
    if (!nodeEquals(n1.getType(), n2.getType())) {
        return Boolean.FALSE;
    }
    if (!nodesEquals(n1.getAnonymousClassBody(), n2.getAnonymousClassBody())) {
        return Boolean.FALSE;
    }
    if (!nodesEquals(n1.getArgs(), n2.getArgs())) {
        return Boolean.FALSE;
    }
    if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
        return Boolean.FALSE;
    }
    return Boolean.TRUE;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:20,代碼來源:EqualsVisitor.java

示例7: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
public void visit(ObjectCreationExpr n, A arg) {
    if (n.getScope() != null) {
        n.getScope().accept(this, arg);
    }
    if (n.getTypeArgs() != null) {
        for (Type t : n.getTypeArgs()) {
            t.accept(this, arg);
        }
    }
    n.getType().accept(this, arg);
    if (n.getArgs() != null) {
        for (Expression e : n.getArgs()) {
            e.accept(this, arg);
        }
    }
    if (n.getAnonymousClassBody() != null) {
        for (BodyDeclaration member : n.getAnonymousClassBody()) {
            member.accept(this, arg);
        }
    }
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:22,代碼來源:VoidVisitorAdapter.java

示例8: testAddAnnotationInInnerClass

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Test
public void testAddAnnotationInInnerClass() throws ParseException {
   String code = "public class Foo {\n\tpublic void aux(){\n\t\t new X(){\n\t\t\tvoid hello(){\n\t\t\t\ty();\n\t\t\t}\n\t\t};\n\t}\n}";
   DefaultJavaParser parser = new DefaultJavaParser();
   CompilationUnit cu = parser.parse(code, false);
   CompilationUnit cu2 = parser.parse(code, false);
   MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(0);
   List<Statement> stmts = md.getBody().getStmts();
   ExpressionStmt stmt = (ExpressionStmt) stmts.get(0);
   ObjectCreationExpr oce = (ObjectCreationExpr) stmt.getExpression();

   List<BodyDeclaration> body = oce.getAnonymousClassBody();

   MethodDeclaration md2 = (MethodDeclaration) body.get(0);
   List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>();
   annotations.add(new MarkerAnnotationExpr(new NameExpr("Override")));
   md2.setAnnotations(annotations);

   List<Action> actions = getActions(cu2, cu);
   Assert.assertEquals(1, actions.size());

   assertCode(actions, code,
         "public class Foo {\n\tpublic void aux(){\n\t\t new X(){\n\t\t\[email protected]\n\t\t\tvoid hello(){\n\t\t\t\ty();\n\t\t\t}\n\t\t};\n\t}\n}");

}
 
開發者ID:walkmod,項目名稱:walkmod-javalang-plugin,代碼行數:26,代碼來源:ChangeLogVisitorTest.java

示例9: getActions

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public List<SymbolAction> getActions(ObjectCreationExpr n) {
    RemoveUnusedSymbolsAction unusedSymbols = new RemoveUnusedSymbolsAction(siblings.peek());
    actions = new LinkedList<SymbolAction>();
    actions.add(unusedSymbols);
    siblings.push(n.getAnonymousClassBody());
    return actions;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:9,代碼來源:RemoveUnusedSymbolsProvider.java

示例10: isDisabledCode

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
static boolean isDisabledCode(ObjectCreationExpr n) {
    Node child = n;
    Node node = child.getParentNode();
    while (node != null) {
        if (node instanceof IfStmt) {
            IfStmt ifs = (IfStmt) node;
            if (child == ifs.getThenStmt() && isCompilationDisabledCondition(ifs.getCondition())) {
                return true;
            }
        }
        child = node;
        node = child.getParentNode();
    }
    return false;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:16,代碼來源:ConditionalCompilationUtil.java

示例11: argTypes

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
private ArgTypes argTypes(List<Expression> args, A arg) {
    boolean hasFunctionalExpressions = false;
    SymbolType[] symbolTypes = null;
    if (args != null) {

        symbolTypes = new SymbolType[args.size()];
        int i = 0;

        for (Expression e : args) {
            if (!(e instanceof LambdaExpr) && !(e instanceof MethodReferenceExpr)) {
                e.accept(this, arg);
                SymbolType argType = null;
                if (e instanceof ObjectCreationExpr) {
                    ObjectCreationExpr aux = (ObjectCreationExpr) e;
                    argType = (SymbolType) aux.getType().getSymbolData();
                } else {
                    argType = (SymbolType) e.getSymbolData();
                }
                symbolTypes[i] = argType;
            } else {
                hasFunctionalExpressions = true;
            }
            i++;
        }
    } else {
        symbolTypes = new SymbolType[0];
    }
    return new ArgTypes(symbolTypes, hasFunctionalExpressions);
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:30,代碼來源:TypeVisitorAdapter.java

示例12: doPush

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void doPush(Symbol<?> symbol, SymbolTable table) throws Exception {
    Node node = symbol.getLocation();

    if (node instanceof TypeDeclaration || node instanceof ObjectCreationExpr) {
        if (symbol.getName().equals("this")) {
            LoadInheritedNestedClasses<?> vis = new LoadInheritedNestedClasses<Object>(table);
            node.accept(vis, null);
        }
    }

}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:13,代碼來源:LoadTypeDeclarationsAction.java

示例13: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void visit(ObjectCreationExpr n, A ctx) {
    n.accept(typeTable, null);
    ClassOrInterfaceType type = n.getType();
    List<ClassOrInterfaceType> extendsList = new LinkedList<ClassOrInterfaceType>();
    extendsList.add(type);
    loadExtendsOrImplements(extendsList);
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:9,代碼來源:LoadTypeDeclarationsAction.java

示例14: doPush

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void doPush(Symbol<?> symbol, SymbolTable table) throws Exception {

    if (symbol.getName().equals("this")) {
        Node node = symbol.getLocation();
        if (node instanceof TypeDeclaration || node instanceof ObjectCreationExpr
                || node instanceof EnumConstantDeclaration) {
            node.accept(new FieldsPopulator(table), table.getScopes().peek());
        }

    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:13,代碼來源:LoadFieldDeclarationsAction.java

示例15: visit

import org.walkmod.javalang.ast.expr.ObjectCreationExpr; //導入依賴的package包/類
@Override
public void visit(ObjectCreationExpr o, Scope scope) {
    if (!scope.hasFieldsLoaded()) {
        table.pushScope(scope);
        List<ClassOrInterfaceType> types = new LinkedList<ClassOrInterfaceType>();
        types.add(o.getType());
        loadExtendsOrImplements(types);
        loadFields(o.getAnonymousClassBody(), scope);
        table.popScope(true);
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:12,代碼來源:LoadFieldDeclarationsAction.java


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