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


Java ExpressionTree.accept方法代碼示例

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


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

示例1: visitReturn

import com.sun.source.tree.ExpressionTree; //導入方法依賴的package包/類
@Override
public Mirror visitReturn(ReturnTree arg0, EvaluationContext evaluationContext) {
    ExpressionTree exprTree = arg0.getExpression();
    Mirror result;
    if (exprTree == null) {
        VirtualMachine vm = evaluationContext.getDebugger().getVirtualMachine();
        if (vm == null) {
            return null;
        }
        // vm.mirrorOfVoid(); [TODO]
        result = null;
    } else {
        result = exprTree.accept(this, evaluationContext);
    }
    return new Return(result);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:EvaluatorVisitor.java

示例2: visitAssignment

import com.sun.source.tree.ExpressionTree; //導入方法依賴的package包/類
/**
 * If we're assigning to an identifier then we see if this identifier has the same name as one of the
 * non-final params in scope. We only care about assignments to an identifier.
 *
 * Thus, a = 5; would be flagged by array[0] = "foo" would not be flagged. The left hand side of the assignment
 * operation must be an identifier in order for us to flag it.
 *
 * @param assignmentTree assignment AST node
 * @param nonFinalParamsInScope params to check against the LHS of the assignment
 */
@Override
public Void visitAssignment(AssignmentTree assignmentTree, Set<Name> nonFinalParamsInScope) {
    if (nonFinalParamsInScope != null && !nonFinalParamsInScope.isEmpty()) {
        ExpressionTree variable = assignmentTree.getVariable();
        variable.accept(new SimpleTreeVisitor<Void, Void>() {
            @Override
            public Void visitIdentifier(IdentifierTree node, Void aVoid) {
                if (nonFinalParamsInScope.contains(node.getName())) {
                    // printing a message of type error counts as a compilation error
                    trees.printMessage(Diagnostic.Kind.ERROR,
                            String.format("EFFECTIVELY_FINAL: Assignment to param in `%s`", assignmentTree),
                            node, compilationUnitTree);
                }
                return null;
            }

        }, null);
    }
    return null;
}
 
開發者ID:massfords,項目名稱:effectively-final,代碼行數:31,代碼來源:EffectivelyFinalVisitor.java

示例3: evaluateCondition

import com.sun.source.tree.ExpressionTree; //導入方法依賴的package包/類
private boolean evaluateCondition(Tree arg0, EvaluationContext evaluationContext, ExpressionTree condition) {
    Mirror conditionValue = condition.accept(this, evaluationContext);
    if (conditionValue instanceof ObjectReference) {
        conditionValue = unboxIfCan(arg0, (ObjectReference) conditionValue, evaluationContext);
    }
    if (!(conditionValue instanceof BooleanValue)) {
        String type = "N/A";    // NOI18N
        if (conditionValue instanceof Value) {
            type = ((Value) conditionValue).type().name();
        }
        Assert.error(arg0, "notABoolean", condition.toString(), conditionValue, type);
    }
    return ((BooleanValue) conditionValue).value();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:EvaluatorVisitor.java


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