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


Java ASTNode.CONDITIONAL_EXPRESSION屬性代碼示例

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


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

示例1: expressionTypeNeedsParentheses

private static boolean expressionTypeNeedsParentheses(Expression expression) {
	int type= expression.getNodeType();
	return type == ASTNode.INFIX_EXPRESSION
			|| type == ASTNode.CONDITIONAL_EXPRESSION
			|| type == ASTNode.PREFIX_EXPRESSION
			|| type == ASTNode.POSTFIX_EXPRESSION
			|| type == ASTNode.CAST_EXPRESSION
			|| type == ASTNode.INSTANCEOF_EXPRESSION
			|| type == ASTNode.ARRAY_CREATION
			|| type == ASTNode.ASSIGNMENT;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:11,代碼來源:NecessaryParenthesesChecker.java

示例2: needsInnerParantheses

private static boolean needsInnerParantheses(ASTNode nodeToCast) {
	int nodeType= nodeToCast.getNodeType();

	// nodes have weaker precedence than cast
	return nodeType == ASTNode.INFIX_EXPRESSION || nodeType == ASTNode.CONDITIONAL_EXPRESSION
			|| nodeType == ASTNode.ASSIGNMENT || nodeType == ASTNode.INSTANCEOF_EXPRESSION;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:7,代碼來源:CastCorrectionProposal.java

示例3: parseExpression

private void parseExpression(MethodInfo methodInfo, Expression expression) {
    if (expression == null) {
        return;
    }//System.out.println(expression.toString()+" "+Annotation.nodeClassForType(expression.getNodeType()));
    if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
        List<Expression> expressions = ((ArrayInitializer) expression).expressions();
        for (Expression expression2 : expressions) {
            parseExpression(methodInfo, expression2);
        }
    }
    if (expression.getNodeType() == ASTNode.CAST_EXPRESSION) {
        parseExpression(methodInfo, ((CastExpression) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION) {
        parseExpression(methodInfo, ((ConditionalExpression) expression).getExpression());
        parseExpression(methodInfo, ((ConditionalExpression) expression).getElseExpression());
        parseExpression(methodInfo, ((ConditionalExpression) expression).getThenExpression());
    }
    if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) {
        parseExpression(methodInfo, ((InfixExpression) expression).getLeftOperand());
        parseExpression(methodInfo, ((InfixExpression) expression).getRightOperand());
    }
    if (expression.getNodeType() == ASTNode.INSTANCEOF_EXPRESSION) {
        parseExpression(methodInfo, ((InstanceofExpression) expression).getLeftOperand());
    }
    if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) {
        parseExpression(methodInfo, ((ParenthesizedExpression) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
        parseExpression(methodInfo, ((PostfixExpression) expression).getOperand());
    }
    if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
        parseExpression(methodInfo, ((PrefixExpression) expression).getOperand());
    }
    if (expression.getNodeType() == ASTNode.THIS_EXPRESSION) {
        parseExpression(methodInfo, ((ThisExpression) expression).getQualifier());
    }
    if (expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
        List<Expression> arguments = ((MethodInvocation) expression).arguments();
        IMethodBinding methodBinding = ((MethodInvocation) expression).resolveMethodBinding();
        if (methodBinding != null)
            methodInfo.methodCalls.add(methodBinding);
        for (Expression exp : arguments)
            parseExpression(methodInfo, exp);
        parseExpression(methodInfo, ((MethodInvocation) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
        parseExpression(methodInfo, ((Assignment) expression).getLeftHandSide());
        parseExpression(methodInfo, ((Assignment) expression).getRightHandSide());
    }
    if (expression.getNodeType() == ASTNode.QUALIFIED_NAME) {
        if (((QualifiedName) expression).getQualifier().resolveTypeBinding() != null) {
            String name = ((QualifiedName) expression).getQualifier().resolveTypeBinding().getQualifiedName() + "." + ((QualifiedName) expression).getName().getIdentifier();
            methodInfo.fieldUsesSet.add(name);
        }
        parseExpression(methodInfo, ((QualifiedName) expression).getQualifier());
    }
}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:58,代碼來源:JavaASTVisitor.java


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