当前位置: 首页>>代码示例>>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;未经允许,请勿转载。