private Statement getParentLoopBody(ASTNode node) { Statement stmt = null; ASTNode start = node; while (start != null && !(start instanceof ForStatement) && !(start instanceof DoStatement) && !(start instanceof WhileStatement) && !(start instanceof EnhancedForStatement) && !(start instanceof SwitchStatement)) { start = start.getParent(); } if (start instanceof ForStatement) { stmt = ((ForStatement) start).getBody(); } else if (start instanceof DoStatement) { stmt = ((DoStatement) start).getBody(); } else if (start instanceof WhileStatement) { stmt = ((WhileStatement) start).getBody(); } else if (start instanceof EnhancedForStatement) { stmt = ((EnhancedForStatement) start).getBody(); } if (start != null && start.getParent() instanceof LabeledStatement) { LabeledStatement labeledStatement = (LabeledStatement) start.getParent(); fEnclosingLoopLabel = labeledStatement.getLabel(); } return stmt; }
private Statement getParentLoopBody(ASTNode node) { Statement stmt= null; ASTNode start= node; while (start != null && !(start instanceof ForStatement) && !(start instanceof DoStatement) && !(start instanceof WhileStatement) && !(start instanceof EnhancedForStatement) && !(start instanceof SwitchStatement)) { start= start.getParent(); } if (start instanceof ForStatement) { stmt= ((ForStatement)start).getBody(); } else if (start instanceof DoStatement) { stmt= ((DoStatement)start).getBody(); } else if (start instanceof WhileStatement) { stmt= ((WhileStatement)start).getBody(); } else if (start instanceof EnhancedForStatement) { stmt= ((EnhancedForStatement)start).getBody(); } if (start != null && start.getParent() instanceof LabeledStatement) { LabeledStatement labeledStatement= (LabeledStatement)start.getParent(); fEnclosingLoopLabel= labeledStatement.getLabel(); } return stmt; }
private boolean keepWalkingUp(ASTNode node) { if (node == null) return false; if (isAnyInstanceOf(STOPPERS, node)) return false; if (fLabel != null && LabeledStatement.class.isInstance(node)){ LabeledStatement ls= (LabeledStatement)node; return ! areEqualLabels(ls.getLabel(), fLabel); } if (fLabel == null) { if (isAnyInstanceOf(fIsBreak ? BREAKTARGETS : CONTINUETARGETS, node)) return node.getParent() instanceof LabeledStatement; // for behavior consistency of break targets: see bug 339176 if (node instanceof LabeledStatement) return false; } return true; }
@Override public boolean visit(LabeledStatement node) { if (fDefiningLabel == null) { SimpleName label= node.getLabel(); if (fLabel == label || isSameLabel(label) && ASTNodes.isParent(fLabel, node)) { fDefiningLabel= node; fResult.add(label); } } node.getBody().accept(this); return false; }
@Override public void endVisit(LabeledStatement node) { if (skipNode(node)) { return; } FlowInfo info = assignFlowInfo(node, node.getBody()); if (info != null) { info.removeLabel(node.getLabel()); } }
@Override public boolean visit(LabeledStatement node) { if (fDefiningLabel == null) { SimpleName label = node.getLabel(); if (fLabel == label || isSameLabel(label) && ASTNodes.isParent(fLabel, node)) { fDefiningLabel = node; fResult.add(label); } } node.getBody().accept(this); return false; }
public boolean isDangligIf() { List<Statement> statements = fDeclaration.getBody().statements(); if (statements.size() != 1) return false; ASTNode p = statements.get(0); while (true) { if (p instanceof IfStatement) { return ((IfStatement) p).getElseStatement() == null; } else { ChildPropertyDescriptor childD; if (p instanceof WhileStatement) { childD = WhileStatement.BODY_PROPERTY; } else if (p instanceof ForStatement) { childD = ForStatement.BODY_PROPERTY; } else if (p instanceof EnhancedForStatement) { childD = EnhancedForStatement.BODY_PROPERTY; } else if (p instanceof DoStatement) { childD = DoStatement.BODY_PROPERTY; } else if (p instanceof LabeledStatement) { childD = LabeledStatement.BODY_PROPERTY; } else { return false; } Statement body = (Statement) p.getStructuralProperty(childD); if (body instanceof Block) { return false; } else { p = body; } } } }
public boolean isDangligIf() { List<Statement> statements= fDeclaration.getBody().statements(); if (statements.size() != 1) return false; ASTNode p= statements.get(0); while (true) { if (p instanceof IfStatement) { return ((IfStatement) p).getElseStatement() == null; } else { ChildPropertyDescriptor childD; if (p instanceof WhileStatement) { childD= WhileStatement.BODY_PROPERTY; } else if (p instanceof ForStatement) { childD= ForStatement.BODY_PROPERTY; } else if (p instanceof EnhancedForStatement) { childD= EnhancedForStatement.BODY_PROPERTY; } else if (p instanceof DoStatement) { childD= DoStatement.BODY_PROPERTY; } else if (p instanceof LabeledStatement) { childD= LabeledStatement.BODY_PROPERTY; } else { return false; } Statement body= (Statement) p.getStructuralProperty(childD); if (body instanceof Block) { return false; } else { p= body; } } } }
@Override public void endVisit(LabeledStatement node) { if (skipNode(node)) return; FlowInfo info= assignFlowInfo(node, node.getBody()); if (info != null) info.removeLabel(node.getLabel()); }
@Override public boolean visit(LabeledStatement node) { node.getLabel().accept(this); this.fBuffer.append(": ");//$NON-NLS-1$ node.getBody().accept(this); return false; }
public boolean visit(LabeledStatement node) { printIndent(); node.getLabel().accept(this); this.buffer.append(": ");//$NON-NLS-1$ node.getBody().accept(this); return false; }
/** * Labeled statement. * * identifier ':' statement */ @Override public boolean visit(final LabeledStatement node) { // visit children return true; }
@Override public boolean visit(LabeledStatement node) { //System.out.println("Found: " + node.getClass()); int oldIndent = indent; indent = 0; node.getLabel().accept(this); println(":"); indent = oldIndent; node.getBody().accept(this); return false; }
public DOMLabeledStatement(LabeledStatement statement) { this.statement = statement; }
@Override public boolean visit(LabeledStatement node) { doVisitNode(node.getBody()); return false; }
@Override public boolean visit(LabeledStatement node) { SimpleName sn = node.getLabel(); addNewBinding(sn.resolveBinding(), node); return true; }
/** {@inheritDoc} */ @Override public void endVisit(LabeledStatement node) { logger.warn("Method endVisitLabeledStatement for " + node + " for " + node + " not implemented!"); super.endVisit(node); }
/** {@inheritDoc} */ @Override public boolean visit(LabeledStatement node) { logger.warn("Method visitLabeledStatement for " + node + " not implemented!"); return super.visit(node); }
@Override public boolean visit(final LabeledStatement node) { return false; }
@Override public boolean visit(final LabeledStatement node) { // not instrumentable, may contain instrumentable nodes return true; }
@Override public boolean visit(LabeledStatement node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
@Override public boolean visit(LabeledStatement node) { add(fCreator.create(node)); return true; }
@Override public void endVisit(LabeledStatement node) { endVisitNode(node); }
@Override public boolean visit(LabeledStatement node) { return visitNode(node); }
@Override public boolean visit(SimpleName node) { // We have to be inside a method if (curMethod == null) return false; // Only replace variables IBinding binding = node.resolveBinding(); if (binding == null) { if ((node.getParent() instanceof LabeledStatement) && ((LabeledStatement) node.getParent()).getLabel().equals(node)) return false; if ((node.getParent() instanceof BreakStatement) && ((BreakStatement) node.getParent()).getLabel().equals(node)) return false; if (node.getParent() instanceof QualifiedName) return false; // This may happen System.err.println("Detected SimpleName without binding: " + node + "; Parent:" + node.getParent() + "\nThis may happen if there are compile errors"); // return false; } else if (binding.getKind() != IBinding.VARIABLE) return false; // Check if we need to add a "this" // Do this if current node is a field and we may replace a variable with // its name AST ast = node.getAST(); IVariableBinding vBinding = (IVariableBinding) binding; // Check for field acceses if (vBinding != null && vBinding.isField()) { // Add this if necessary if (renaming.containsValue(node.toString()) && !(node.getParent() instanceof FieldAccess) && !(node.getParent() instanceof QualifiedName)) { FieldAccess fa = ast.newFieldAccess(); fa.setExpression(ast.newThisExpression()); fa.setName(ast.newSimpleName(node.toString())); astRewrite.replace(node, fa, null); } return false; } String newName = renaming.get(node.toString()); if (newName == null || newName == "") return false; astRewrite.replace(node, ast.newSimpleName(newName), null); return false; }
@Override public boolean visit(LabeledStatement node) { return visit((Statement)node); }
@Override public void endVisit(LabeledStatement node) { endVisit((Statement)node); }