Java Code Examples for com.sun.source.tree.ParenthesizedTree#getExpression()
The following examples show how to use
com.sun.source.tree.ParenthesizedTree#getExpression() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateElementUtilities.java From netbeans with Apache License 2.0 | 6 votes |
private static List<? extends TypeMirror> computeParenthesis(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) { ParenthesizedTree pt = (ParenthesizedTree) parent.getLeaf(); if (pt.getExpression() != error) { return null; } TreePath parentParent = parent.getParentPath(); List<? extends TypeMirror> upperTypes = resolveType(types, info, parentParent, pt, offset, null, null); if (upperTypes == null) { return null; } return upperTypes; }
Example 2
Source File: CreateElementUtilities.java From netbeans with Apache License 2.0 | 6 votes |
private static List<? extends TypeMirror> computeParenthesis(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) { ParenthesizedTree pt = (ParenthesizedTree) parent.getLeaf(); if (pt.getExpression() != error) { return null; } TreePath parentParent = parent.getParentPath(); List<? extends TypeMirror> upperTypes = resolveType(types, info, parentParent, pt, offset, null, null); if (upperTypes == null) { return null; } return upperTypes; }
Example 3
Source File: Ifs.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void performRewrite(final TransformationContext ctx) throws Exception { IfTree toRewrite = (IfTree) ctx.getPath().getLeaf(); StatementTree elseStatement = toRewrite.getElseStatement(); if (toRewrite.getCondition() == null || toRewrite.getCondition().getKind() != Tree.Kind.PARENTHESIZED) { return; } ParenthesizedTree ptt = (ParenthesizedTree)toRewrite.getCondition(); if (ptt.getExpression() == null) { return; } if (elseStatement == null) elseStatement = ctx.getWorkingCopy().getTreeMaker().Block(Collections.<StatementTree>emptyList(), false); ctx.getWorkingCopy().rewrite(toRewrite, ctx.getWorkingCopy().getTreeMaker().If(toRewrite.getCondition(), elseStatement, toRewrite.getThenStatement())); ExpressionTree negated = Utilities.negate( ctx.getWorkingCopy().getTreeMaker(), ptt.getExpression(), ptt); ctx.getWorkingCopy().rewrite(ptt.getExpression(), negated); }