private static boolean isAllowedStatementInMap(JCStatement statement) { if (statement instanceof JCExpressionStatement) { JCExpressionStatement exprStat = (JCExpressionStatement) statement; if (exprStat.getExpression() instanceof JCAssign) { return true; } if (exprStat.getExpression() instanceof JCMethodInvocation) { JCMethodInvocation inv = (JCMethodInvocation) exprStat.getExpression(); String methodName; if (inv.meth instanceof JCFieldAccess) { methodName = ((JCFieldAccess) inv.meth).name.toString(); } else { methodName = inv.meth.toString(); } if (JSweetConfig.INDEXED_GET_FUCTION_NAME.equals(methodName) || JSweetConfig.INDEXED_SET_FUCTION_NAME.equals(methodName)) { return true; } } } return false; }
if (expression) { JCExpressionStatement expressionTree = (JCExpressionStatement) block.getStatements().get(0); startPosition = expressionTree.getStartPosition(); endPosition = state.getEndPosition(expressionTree.getExpression()); } else { startPosition = block.getStartPosition();
JCTree.JCExpression expression = exprStmt.getExpression(); Tree.Kind expressionKind = expression.getKind(); JCTree expressionTree = expression.getTree();
if (expression) { JCExpressionStatement expressionTree = (JCExpressionStatement) block.getStatements().get(0); startPosition = expressionTree.getStartPosition(); endPosition = state.getEndPosition(expressionTree.getExpression()); } else { startPosition = block.getStartPosition();
return Description.NO_MATCH; if (expr.getStartPosition() > ((JCTree) info.innerIf()).getStartPosition()) { return Description.NO_MATCH; if (!(expr.getExpression() instanceof JCAssign)) { return Description.NO_MATCH; JCAssign assign = (JCAssign) expr.getExpression(); if (!Objects.equals(ASTHelpers.getSymbol(assign.getVariable()), info.sym())) { return Description.NO_MATCH;
f.rawStatement(toTree(node.getStatement())); for (JCExpressionStatement upd : node.getUpdate()) { Node updateNode = toTree(upd.getExpression()); setConversionPositionInfo(updateNode, "exec", getPosition(upd)); f.rawUpdates().addToEnd(updateNode); for (JCStatement init : initializers) { if (init instanceof JCExpressionStatement) { Node initNode = toTree(((JCExpressionStatement) init).getExpression()); setConversionPositionInfo(initNode, "exec", getPosition(init)); f.rawExpressionInits().addToEnd(initNode);
f.rawStatement(toTree(node.getStatement())); for (JCExpressionStatement upd : node.getUpdate()) { Node updateNode = toTree(upd.getExpression()); setConversionPositionInfo(updateNode, "exec", getPosition(upd)); f.rawUpdates().addToEnd(updateNode); for (JCStatement init : initializers) { if (init instanceof JCExpressionStatement) { Node initNode = toTree(((JCExpressionStatement) init).getExpression()); setConversionPositionInfo(initNode, "exec", getPosition(init)); f.rawExpressionInits().addToEnd(initNode);
f.rawStatement(toTree(node.getStatement())); for (JCExpressionStatement upd : node.getUpdate()) { Node updateNode = toTree(upd.getExpression()); setConversionPositionInfo(updateNode, "exec", getPosition(upd)); f.rawUpdates().addToEnd(updateNode); for (JCStatement init : initializers) { if (init instanceof JCExpressionStatement) { Node initNode = toTree(((JCExpressionStatement) init).getExpression()); setConversionPositionInfo(initNode, "exec", getPosition(init)); f.rawExpressionInits().addToEnd(initNode);
JCTree inlineBody(Inliner inliner) throws CouldNotResolveImportException { if (getBody() instanceof UPlaceholderExpression) { UPlaceholderExpression body = (UPlaceholderExpression) getBody(); Optional<List<JCStatement>> blockBinding = inliner.getOptionalBinding(body.placeholder().blockKey()); if (blockBinding.isPresent()) { // this lambda is of the form args -> blockPlaceholder(); List<JCStatement> blockInlined = UPlaceholderExpression.copier(body.arguments(), inliner) .copy(blockBinding.get(), inliner); if (blockInlined.size() == 1) { if (blockInlined.get(0) instanceof JCReturn) { return ((JCReturn) blockInlined.get(0)).getExpression(); } else if (blockInlined.get(0) instanceof JCExpressionStatement) { return ((JCExpressionStatement) blockInlined.get(0)).getExpression(); } } return inliner.maker().Block(0, blockInlined); } } return getBody().inline(inliner); }
private boolean isSynthetic(JCTree tree) { if (tree.getKind() == Kind.METHOD) { //filter synthetic constructors return (((JCMethodDecl)tree).mods.flags & Flags.GENERATEDCONSTR) != 0L; } //filter synthetic superconstructor calls if (tree.getKind() == Kind.EXPRESSION_STATEMENT && diffContext.origUnit != null) { JCExpressionStatement est = (JCExpressionStatement) tree; if (est.expr.getKind() == Kind.METHOD_INVOCATION) { JCMethodInvocation mit = (JCMethodInvocation) est.getExpression(); if (mit.meth.getKind() == Kind.IDENTIFIER) { JCIdent it = (JCIdent) mit.getMethodSelect(); return it.name == names._super && diffContext.syntheticTrees.contains(tree); } } } return false; }
@Override public void printStat(JCTree tree) throws IOException { if (tree instanceof JCExpressionStatement && ((JCExpressionStatement) tree).getExpression() instanceof JCMethodInvocation) { JCMethodInvocation invocation = (JCMethodInvocation) ((JCExpressionStatement) tree).getExpression(); JCExpression select = invocation.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitComment")) { String commentLiteral = (String) ((JCLiteral) invocation.getArguments().get(0)).getValue(); print("// " + commentLiteral); return; } } super.printStat(tree); }
public JCExpressionStatement Exec(JCExpression expr) { JCExpressionStatement tree = new JCExpressionStatement(expr); tree.pos = pos; return tree; }
public JCExpressionStatement Exec(JCExpression expr) { JCExpressionStatement tree = new JCExpressionStatement(expr); tree.pos = pos; return tree; }
public JCExpressionStatement Exec(JCExpression expr) { JCExpressionStatement tree = new JCExpressionStatement(expr); tree.pos = pos; return tree; }
@Override public void visitExec(JCExpressionStatement node) { Node expr = toTree(node.getExpression()); if (expr instanceof SuperConstructorInvocation || expr instanceof AlternateConstructorInvocation) { setConversionPositionInfo(expr, "exec", getPosition(node)); set(node, expr); return; } ExpressionStatement exec = new ExpressionStatement(); exec.rawExpression(expr); set(node, exec); }
public JCExpressionStatement Exec(JCExpression expr) { JCExpressionStatement tree = new JCExpressionStatement(expr); tree.pos = pos; return tree; }
@Override public void visitExec(JCExpressionStatement node) { Node expr = toTree(node.getExpression()); if (expr instanceof SuperConstructorInvocation || expr instanceof AlternateConstructorInvocation) { setConversionPositionInfo(expr, "exec", getPosition(node)); set(node, expr); return; } ExpressionStatement exec = new ExpressionStatement(); exec.rawExpression(expr); set(node, exec); }
@Override public void visitExec(JCExpressionStatement node) { Node expr = toTree(node.getExpression()); if (expr instanceof SuperConstructorInvocation || expr instanceof AlternateConstructorInvocation) { setConversionPositionInfo(expr, "exec", getPosition(node)); set(node, expr); return; } ExpressionStatement exec = new ExpressionStatement(); exec.rawExpression(expr); set(node, exec); }
return Description.NO_MATCH; if (expr.getStartPosition() > ((JCTree) info.innerIf()).getStartPosition()) { return Description.NO_MATCH; if (!(expr.getExpression() instanceof JCAssign)) { return Description.NO_MATCH; JCAssign assign = (JCAssign) expr.getExpression(); if (!Objects.equals(ASTHelpers.getSymbol(assign.getVariable()), info.sym())) { return Description.NO_MATCH;
JCTree inlineBody(Inliner inliner) throws CouldNotResolveImportException { if (getBody() instanceof UPlaceholderExpression) { UPlaceholderExpression body = (UPlaceholderExpression) getBody(); Optional<List<JCStatement>> blockBinding = inliner.getOptionalBinding(body.placeholder().blockKey()); if (blockBinding.isPresent()) { // this lambda is of the form args -> blockPlaceholder(); List<JCStatement> blockInlined = UPlaceholderExpression.copier(body.arguments(), inliner) .copy(blockBinding.get(), inliner); if (blockInlined.size() == 1) { if (blockInlined.get(0) instanceof JCReturn) { return ((JCReturn) blockInlined.get(0)).getExpression(); } else if (blockInlined.get(0) instanceof JCExpressionStatement) { return ((JCExpressionStatement) blockInlined.get(0)).getExpression(); } } return inliner.maker().Block(0, blockInlined); } } return getBody().inline(inliner); }