/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.LabeledStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit(LabeledStatement labeledStatement, BlockScope scope) { this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier); this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_labeled_statement); if (this.preferences.insert_space_after_colon_in_labeled_statement) { this.scribe.space(); } if (this.preferences.insert_new_line_after_label) { this.scribe.printNewLine(); } final Statement statement = labeledStatement.statement; statement.traverse(this, scope); if (statement instanceof Expression) { this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } return false; }
public FlowContext getTargetContextForBreakLabel(char[] labelName) { FlowContext current = this, lastNonReturningSubRoutine = null; while (current != null) { if (current.isNonReturningContext()) { lastNonReturningSubRoutine = current; } char[] currentLabelName; if (((currentLabelName = current.labelName()) != null) && CharOperation.equals(currentLabelName, labelName)) { ((LabeledStatement)current.associatedNode).bits |= ASTNode.LabelUsed; if (lastNonReturningSubRoutine == null) return current; return lastNonReturningSubRoutine; } current = current.getLocalParent(); } // not found return null; }
protected void consumeStatementLabel() { // LabeledStatement ::= 'Identifier' ':' Statement // LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf //optimize push/pop Statement statement = (Statement) this.astStack[this.astPtr]; this.astStack[this.astPtr] = new LabeledStatement( this.identifierStack[this.identifierPtr], statement, this.identifierPositionStack[this.identifierPtr--], this.endStatementPosition); this.identifierLengthPtr--; }
public FlowContext getTargetContextForContinueLabel(char[] labelName) { FlowContext current = this; FlowContext lastContinuable = null; FlowContext lastNonReturningSubRoutine = null; while (current != null) { if (current.isNonReturningContext()) { lastNonReturningSubRoutine = current; } else { if (current.isContinuable()) { lastContinuable = current; } } char[] currentLabelName; if ((currentLabelName = current.labelName()) != null && CharOperation.equals(currentLabelName, labelName)) { ((LabeledStatement)current.associatedNode).bits |= ASTNode.LabelUsed; // matching label found if ((lastContinuable != null) && (current.associatedNode.concreteStatement() == lastContinuable.associatedNode)) { if (lastNonReturningSubRoutine == null) return lastContinuable; return lastNonReturningSubRoutine; } // label is found, but not a continuable location return FlowContext.NotContinuableContext; } current = current.getLocalParent(); } // not found return null; }
public void unusedLabel(LabeledStatement statement) { int severity = computeSeverity(IProblem.UnusedLabel); if (severity == ProblemSeverities.Ignore) return; String[] arguments = new String[] {new String(statement.label)}; this.handle( IProblem.UnusedLabel, arguments, arguments, severity, statement.sourceStart, statement.labelEnd); }
@Override public void endVisit(LabeledStatement x, BlockScope scope) { try { JStatement statement = pop(x.statement); if (statement == null) { push(null); return; } SourceInfo info = makeSourceInfo(x); push(new JLabeledStatement(info, getOrCreateLabel(info, x.label), statement)); } catch (Throwable e) { throw translateException(x, e); } }
@Override public boolean visit(LabeledStatement node, BlockScope scope) { fixPositions(setGeneratedBy(node, source)); return super.visit(node, scope); }
@Override public boolean visit(LabeledStatement node, BlockScope scope) { setGeneratedBy(node, source); applyOffsetASTNode(node); return super.visit(node, scope); }