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


Java Expression.accept方法代碼示例

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


在下文中一共展示了Expression.accept方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visit

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
@Override
public void visit(EnumConstantDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
        n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
        for (AnnotationExpr a : n.getAnnotations()) {
            a.accept(this, arg);
        }
    }
    if (n.getArgs() != null) {
        for (Expression e : n.getArgs()) {
            e.accept(expressionTypeAnalyzer, arg);
        }
    }
    if (n.getClassBody() != null) {

        loadThisSymbol(n, arg);

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

示例2: visit

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

示例3: visit

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

    if (n.getValues() != null) {

        List<Expression> values = n.getValues();
        SymbolType st = null;
        for (Expression expr : values) {
            expr.accept(this, arg);
            SymbolData sd = expr.getSymbolData();
            if (st == null && sd != null) {
                st = (SymbolType) sd;
                st = st.clone();

            } else if (sd != null) {
                st = (SymbolType) st.merge(sd);
            }

        }
        if (values != null && !values.isEmpty() && st != null) {
            st.setArrayCount(st.getArrayCount() + 1);
        }

        n.setSymbolData(st);
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:27,代碼來源:TypeVisitorAdapter.java

示例4: visit

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
public void visit(ArrayInitializerExpr n, Object arg) {
    prepareComments(n);
    printPreviousComments(n, arg);
    printer.print("{");
    if (n.getValues() != null) {
        printer.print(" ");
        for (Iterator<Expression> i = n.getValues().iterator(); i.hasNext();) {
            Expression expr = i.next();
            expr.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
        printer.print(" ");
    }
    printer.print("}");
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:18,代碼來源:DumpVisitor.java

示例5: visit

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
public R visit(MethodCallExpr 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);
        }
    }
    if (n.getArgs() != null) {
        for (Expression e : n.getArgs()) {
            e.accept(this, arg);
        }
    }
    return null;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:17,代碼來源:GenericVisitorAdapter.java

示例6: printArguments

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
private void printArguments(List<Expression> args, Object arg) {
    printer.print("(");
    if (args != null) {
        for (Iterator<Expression> i = args.iterator(); i.hasNext();) {
            Expression e = i.next();
            e.accept(this, arg);
            if (i.hasNext()) {
                printer.print(", ");
            }
        }
    }
    printer.print(")");
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:14,代碼來源:DumpVisitor.java

示例7: argTypes

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的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

示例8: filter

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
@Override
public boolean filter(Class<?> candidate) {
    boolean isCompatible = true;

    List<Method> methods = new LinkedList<Method>();

    boolean returnTypeCompatible = false;
    methods.addAll(Arrays.asList(candidate.getDeclaredMethods()));

    methods.addAll(Arrays.asList(candidate.getMethods()));
    Iterator<Method> it = methods.iterator();

    while (it.hasNext() && !returnTypeCompatible) {

        Method currentMethod = it.next();

        // checking method name
        if (currentMethod.getName().equals(requiredMethod.getName())) {
            List<Expression> args = requiredMethod.getArgs();
            Class<?>[] parameterTypes = currentMethod.getParameterTypes();
            if (args != null) {
                boolean compatibleArgs = true;
                int k = 0;

                for (Expression argExpr : args) {
                    argExpr.accept(visitor, ctx);
                    SymbolType typeArg = (SymbolType) argExpr.getSymbolData();
                    if (!Types.isCompatible(typeArg.getClazz(), parameterTypes[k])) {
                        compatibleArgs = false;
                    }
                    k++;
                }
                returnTypeCompatible = compatibleArgs;
            } else {
                returnTypeCompatible = true;
            }
        }
    }

    isCompatible = returnTypeCompatible;

    return isCompatible;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:44,代碼來源:RequiredMethodPredicate.java

示例9: build

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
@Override
public MethodCallExpr build(MethodCallExpr n) throws Exception {
    List<Expression> args = n.getArgs();
    MethodSymbolData st = n.getSymbolData();
    if (args != null) {
        int i = 0;
        if (st == null) {
            Expression scope = n.getScope();
            String scopeName = "empty";
            if (scope != null) {
                scopeName = scope.getSymbolData().toString();
            }
            String argsTypeName = "empty";
            List<Expression> argExpr = n.getArgs();
            if (argExpr != null) {
                argsTypeName = "[";
                Iterator<Expression> it = argExpr.iterator();
                while (it.hasNext()) {
                    Expression arg = it.next();
                    if (arg != null && arg.getSymbolData() != null) {
                        argsTypeName += " " + arg.getSymbolData().toString();
                    } else {
                        argsTypeName += " null";
                    }
                    if (it.hasNext()) {
                        argsTypeName += ",";
                    }
                }
                argsTypeName += "]";
            }
            throw new Exception("Ops! The method call " + n.toString() + " is not resolved. The scope is ["
                    + scopeName + "] , and the args are : " + argsTypeName);
        }
        java.lang.reflect.Type[] argClasses = st.getMethod().getGenericParameterTypes();
        int paramCount = st.getMethod().getParameterTypes().length;
        for (Expression argument : args) {
            if (argument instanceof MethodReferenceExpr) {
                SymbolType aux = null;
                if (i < paramCount) {
                    aux = SymbolType.valueOf(argClasses[i], typeMapping);

                } else {
                    java.lang.reflect.Type componentType = null;
                    java.lang.reflect.Type lastArg = argClasses[argClasses.length - 1];
                    if (lastArg instanceof Class<?>) {
                        componentType = ((Class<?>) lastArg).getComponentType();
                    } else if (lastArg instanceof GenericArrayType) {
                        componentType = ((GenericArrayType) lastArg).getGenericComponentType();
                    }
                    aux = SymbolType.valueOf(componentType, typeMapping);
                }
                argument.setSymbolData(aux);
                argument.accept(visitor, ctxt);
            }
            i++;
        }
    }
    return null;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:60,代碼來源:SymbolDataOfMethodReferenceBuilder.java


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