use of com.sun.source.tree.ParenthesizedTree in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitSwitchExpression17.
/**
* Visit a switch expression.
*
* @param javacTree switch expression tree
* @param javaParserNode java parser node
* @return null
*/
public Void visitSwitchExpression17(Tree javacTree, Node javaParserNode) {
SwitchExpr node = castNode(SwitchExpr.class, javaParserNode, javacTree);
processSwitchExpression(javacTree, node);
// Switch expressions are always parenthesized in javac but never in JavaParser.
ExpressionTree expression = ((ParenthesizedTree) TreeUtils.switchExpressionTreeGetExpression(javacTree)).getExpression();
expression.accept(this, node.getSelector());
visitLists(TreeUtils.switchExpressionTreeGetCases(javacTree), node.getEntries());
return null;
}
use of com.sun.source.tree.ParenthesizedTree in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitIf.
@Override
public Void visitIf(IfTree javacTree, Node javaParserNode) {
IfStmt node = castNode(IfStmt.class, javaParserNode, javacTree);
processIf(javacTree, node);
assert javacTree.getCondition().getKind() == Tree.Kind.PARENTHESIZED;
ExpressionTree condition = ((ParenthesizedTree) javacTree.getCondition()).getExpression();
condition.accept(this, node.getCondition());
javacTree.getThenStatement().accept(this, node.getThenStmt());
visitOptional(javacTree.getElseStatement(), node.getElseStmt());
return null;
}
use of com.sun.source.tree.ParenthesizedTree in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitSwitch.
@Override
public Void visitSwitch(SwitchTree javacTree, Node javaParserNode) {
SwitchStmt node = castNode(SwitchStmt.class, javaParserNode, javacTree);
processSwitch(javacTree, node);
// Switch expressions are always parenthesized in javac but never in JavaParser.
ExpressionTree expression = ((ParenthesizedTree) javacTree.getExpression()).getExpression();
expression.accept(this, node.getSelector());
visitLists(javacTree.getCases(), node.getEntries());
return null;
}
use of com.sun.source.tree.ParenthesizedTree in project checker-framework by typetools.
the class GuiEffectTypeFactory method getAnnotatedType.
@Override
public AnnotatedTypeMirror getAnnotatedType(Tree tree) {
AnnotatedTypeMirror typeMirror = super.getAnnotatedType(tree);
if (typeMirror.hasAnnotation(UI.class)) {
return typeMirror;
}
// containing such class/lambda
if (isDirectlyMarkedUIThroughInference(tree)) {
typeMirror.replaceAnnotation(AnnotationBuilder.fromClass(elements, UI.class));
} else if (tree.getKind() == Tree.Kind.PARENTHESIZED) {
ParenthesizedTree parenthesizedTree = (ParenthesizedTree) tree;
return this.getAnnotatedType(parenthesizedTree.getExpression());
} else if (tree.getKind() == Tree.Kind.CONDITIONAL_EXPRESSION) {
ConditionalExpressionTree cet = (ConditionalExpressionTree) tree;
boolean isTrueOperandUI = (cet.getTrueExpression() != null && this.getAnnotatedType(cet.getTrueExpression()).hasAnnotation(UI.class));
boolean isFalseOperandUI = (cet.getFalseExpression() != null && this.getAnnotatedType(cet.getFalseExpression()).hasAnnotation(UI.class));
if (isTrueOperandUI || isFalseOperandUI) {
typeMirror.replaceAnnotation(AnnotationBuilder.fromClass(elements, UI.class));
}
}
// (i.e. are there any other operators that take new or lambda expressions as operands)
return typeMirror;
}
Aggregations