blob: 5ba5808b7d533cf7581ec87824bad6f7c9219475 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 xored software, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Vladimir Belov)
*******************************************************************************/
package org.eclipse.dltk.javascript.ast;
import org.eclipse.dltk.ast.ASTVisitor;
public class LabelledStatement extends Statement implements ISourceableBlock {
private Label label;
private int colon = -1;
private Statement statement;
public LabelledStatement(JSNode parent) {
super(parent);
}
/**
* @see org.eclipse.dltk.ast.ASTNode#traverse(org.eclipse.dltk.ast.ASTVisitor)
*/
@Override
public void traverse(ASTVisitor visitor) throws Exception {
if (visitor.visit(this)) {
if (label != null)
label.traverse(visitor);
if (statement != null)
statement.traverse(visitor);
visitor.endvisit(this);
}
}
public Label getLabel() {
return this.label;
}
public void setLabel(Label label) {
this.label = label;
}
public Statement getStatement() {
return this.statement;
}
public void setStatement(Statement statement) {
this.statement = statement;
}
public int getColonPosition() {
return this.colon;
}
public void setColonPosition(int colon) {
this.colon = colon;
}
@Override
public String toSourceString(String indentationString) {
final StringBuilder buffer = new StringBuilder();
buffer.append(indentationString);
buffer.append(toSourceString(label, indentationString));
buffer.append(":\n");
buffer.append(toSourceString(statement, indentationString + INDENT));
return buffer.toString();
}
public boolean isBlock() {
return true;
}
}