List of usage examples for org.eclipse.jdt.core.dom ContinueStatement setLabel
public void setLabel(SimpleName label)
From source file:java5totext.input.JDTVisitor.java
License:Open Source License
@Override public void endVisit(org.eclipse.jdt.core.dom.ContinueStatement node) { ContinueStatement element = (ContinueStatement) this.binding.get(node); this.initializeNode(element, node); if (this.binding.get(node.getLabel()) != null) element.setLabel((NamedElementRef) this.binding.get(node.getLabel())); }
From source file:org.decojer.cavaj.transformers.TrControlFlowAnalysis.java
License:Open Source License
/** * Check for given exit if it's a branching statement, that means explicitely struct leaving * with break/continue etc. (either labeled or none-labeled), or if it's a normal exit to a * potential follow.//ww w . ja v a2s . c o m * * @param struct * current struct * @param exit * exit, that means leaving the current struct * @return {@code true} - explicit struct leaving with break/continue etc. is necessary */ private boolean checkBranching(@Nonnull final Struct struct, @Nonnull final E exit) { boolean defaultBreakableConsumed = false; final BB bb = exit.getEnd(); for (Struct followStruct = struct.getParent(); followStruct != null; followStruct = followStruct .getParent()) { if (!followStruct.hasBreakTarget(bb) && !followStruct.hasContinueTarget(bb)) { if (followStruct.isDefaultBreakable()) { // none-labeled break/continue not possible anymore defaultBreakableConsumed = true; } continue; } if (followStruct == struct.getParent()) { // check directly enclosing struct for potential fall-through scenarios if (followStruct instanceof Loop && ((Loop) followStruct).hasLast(bb)) { return false; // direct fall-through to direct enclosing loop-last allowed } if (!followStruct.isDefaultBreakable()) { // fall-through to directly enclosing struct allowed (for cond, not for loop) return false; } } // create label (if not already existing or not none-labeled break/continue possible) if (followStruct.getLabel() == null && (!followStruct.isDefaultBreakable() || defaultBreakableConsumed)) { final String label = followStruct.getDefaultLabelName() + (this.labelCounter++ == 0 ? "" : this.labelCounter); followStruct.setLabel(label); if (followStruct.hasBreakTarget(bb)) { final BreakStatement breakStatement = getAst().newBreakStatement(); breakStatement.setLabel(newSimpleName(label, getAst())); exit.setBranchingStmt(breakStatement); } else { final ContinueStatement continueStatement = getAst().newContinueStatement(); continueStatement.setLabel(newSimpleName(label, getAst())); exit.setBranchingStmt(continueStatement); } } else { // cannot add breaks/continues to exit.start, e.g. direct IfStmt-breaks/backs happen if (followStruct.hasBreakTarget(bb)) { exit.setBranchingStmt(getAst().newBreakStatement()); } else { exit.setBranchingStmt(getAst().newContinueStatement()); } } return true; } return false; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public ContinueStatement convert(org.eclipse.jdt.internal.compiler.ast.ContinueStatement statement) { ContinueStatement continueStatement = new ContinueStatement(this.ast); continueStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1); if (statement.label != null) { final SimpleName name = new SimpleName(this.ast); name.internalSetIdentifier(new String(statement.label)); retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name); continueStatement.setLabel(name); }/*www. ja v a 2 s .c o m*/ return continueStatement; }
From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java
License:Open Source License
@Override public void endVisit(final org.eclipse.jdt.core.dom.ContinueStatement node) { ContinueStatement element = (ContinueStatement) this.binding.get(node); initializeNode(element, node);//from w w w . j a v a2s . c om if (node.getLabel() != null) { PendingElement label = new PendingElement(this.factory); label.setClientNode(element); label.setLinkName("label"); //$NON-NLS-1$ NamedElement target = JDTVisitorUtils.manageBindingRef(label, node.getLabel(), this); if (target != null) { element.setLabel((LabeledStatement) target); } } }
From source file:org.whole.lang.java.util.JDTTransformerVisitor.java
License:Open Source License
@Override public boolean visit(ContinueStatement node) { org.whole.lang.java.model.ContinueStatement continueStm = lf .create(JavaEntityDescriptorEnum.ContinueStatement); if (acceptChild(node.getLabel())) continueStm.setLabel((org.whole.lang.java.model.SimpleName) name); stm = continueStm;//w w w .j a v a 2s. c o m return false; }