com.sun.tools.javac.tree.JCTree.JCParens Java Examples
The following examples show how to use
com.sun.tools.javac.tree.JCTree.JCParens.
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: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Boolean expValue(JCTree exp) { while (exp.hasTag(PARENS)) exp = ((JCParens)exp).expr; boolean eq; switch (exp.getTag()) { case EQ: eq = true; break; case NE: eq = false; break; default: return null; } // we have a JCBinary(EQ|NE) // check if we have two literals (constants or null) JCBinary b = (JCBinary)exp; if (b.lhs.type.hasTag(BOT)) return expValueIsNull(eq, b.rhs); if (b.rhs.type.hasTag(BOT)) return expValueIsNull(eq, b.lhs); return null; }
Example #2
Source File: AbstractDiagnosticFormatter.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private String expr2String(JCExpression tree) { switch(tree.getTag()) { case PARENS: return expr2String(((JCParens)tree).expr); case LAMBDA: case REFERENCE: case CONDEXPR: return Pretty.toSimpleString(tree); default: Assert.error("unexpected tree kind " + tree.getKind()); return null; } }
Example #3
Source File: HandleNonNull.java From EasyMPermission with MIT License | 5 votes |
/** * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;}, * where the block braces are optional. If it is of this form, returns "x". * If it is not of this form, returns null. */ public String returnVarNameIfNullCheck(JCStatement stat) { if (!(stat instanceof JCIf)) return null; /* Check that the if's statement is a throw statement, possibly in a block. */ { JCStatement then = ((JCIf) stat).thenpart; if (then instanceof JCBlock) { List<JCStatement> stats = ((JCBlock) then).stats; if (stats.length() == 0) return null; then = stats.get(0); } if (!(then instanceof JCThrow)) return null; } /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { JCExpression cond = ((JCIf) stat).cond; while (cond instanceof JCParens) cond = ((JCParens) cond).expr; if (!(cond instanceof JCBinary)) return null; JCBinary bin = (JCBinary) cond; if (!CTC_EQUAL.equals(treeTag(bin))) return null; if (!(bin.lhs instanceof JCIdent)) return null; if (!(bin.rhs instanceof JCLiteral)) return null; if (!CTC_BOT.equals(typeTag(bin.rhs))) return null; return ((JCIdent) bin.lhs).name.toString(); } }
Example #4
Source File: PrettyCommentsPrinter.java From EasyMPermission with MIT License | 5 votes |
public void visitParens(JCParens tree) { try { print("("); printExpr(tree.expr); print(")"); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #5
Source File: UParens.java From Refaster with Apache License 2.0 | 4 votes |
@Override public JCParens inline(Inliner inliner) throws CouldNotResolveImportException { return inliner.maker().Parens(getExpression().inline(inliner)); }
Example #6
Source File: CRTable.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void visitParens(JCParens tree) { SourceRange sr = new SourceRange(startPos(tree), endPos(tree)); sr.mergeWith(csp(tree.expr)); result = sr; }
Example #7
Source File: JavacTreeMaker.java From EasyMPermission with MIT License | 4 votes |
public JCParens Parens(JCExpression expr) { return invoke(Parens, expr); }
Example #8
Source File: ArgumentAttr.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override ArgumentType<JCParens> dup(JCParens tree, Env<AttrContext> env) { return new ParensType(tree, env, speculativeTree, speculativeTypes); }
Example #9
Source File: ArgumentAttr.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens, Map<ResultInfo, Type> speculativeTypes) { super(tree, env, speculativeParens, speculativeTypes); }
Example #10
Source File: ArgumentAttr.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens) { this(tree, env, speculativeParens, new HashMap<>()); }
Example #11
Source File: ArgumentAttr.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public void visitParens(JCParens that) { processArg(that, speculativeTree -> new ParensType(that, env, speculativeTree)); }
Example #12
Source File: CompilationUnitBuilder.java From j2cl with Apache License 2.0 | 4 votes |
private Expression convertParens(JCParens expression) { // Preserve the parenthesis. J2CL does not yet handle properly parenthesizing the output // according to operator precedence. return convertExpression(expression.getExpression()).parenthesize(); }
Example #13
Source File: CompilationUnitBuilder.java From j2cl with Apache License 2.0 | 4 votes |
private Expression convertConditionRemovingOuterParentheses(JCExpression expression) { return convertExpression(((JCParens) expression).getExpression()); }
Example #14
Source File: MemberEnter.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visitParens(JCParens tree) { tree.expr.accept(this); }
Example #15
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Visitor method for parenthesized expressions. * If the subexpression has changed, omit the parens. */ public void visitParens(JCParens tree) { JCTree expr = translate(tree.expr); result = ((expr == tree.expr) ? tree : expr); }
Example #16
Source File: TransTypes.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void visitParens(JCParens tree) { tree.expr = translate(tree.expr, pt); tree.type = erasure(tree.expr.type); result = tree; }
Example #17
Source File: ArgumentAttr.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override ArgumentType<JCParens> dup(JCParens tree, Env<AttrContext> env) { return new ParensType(tree, env, speculativeTree, speculativeTypes); }
Example #18
Source File: ArgumentAttr.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens, Map<ResultInfo, Type> speculativeTypes) { super(tree, env, speculativeParens, speculativeTypes); }
Example #19
Source File: ArgumentAttr.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens) { this(tree, env, speculativeParens, new HashMap<>()); }
Example #20
Source File: ArgumentAttr.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visitParens(JCParens that) { processArg(that, speculativeTree -> new ParensType(that, env, speculativeTree)); }