blob: 66ebec2ef201ea14dc20112467caef539e6a9331 [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 SetMethod extends Method {
private Keyword setKeyword;
private Identifier argument;
public SetMethod(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 (setKeyword != null)
setKeyword.traverse(visitor);
if (getName() != null)
getName().traverse(visitor);
if (argument != null)
argument.traverse(visitor);
if (getBody() != null)
getBody().traverse(visitor);
visitor.endvisit(this);
}
}
public Identifier getArgument() {
return this.argument;
}
public void setArgument(Identifier argument) {
this.argument = argument;
}
public Keyword getSetKeyword() {
return this.setKeyword;
}
public void setSetKeyword(Keyword keyword) {
this.setKeyword = keyword;
}
@Override
public String toSourceString(String indentationString) {
final StringBuilder buffer = new StringBuilder();
buffer.append(Keywords.SET);
buffer.append(" ");
buffer.append(toSourceString(getName(), indentationString));
buffer.append(" (");
buffer.append(toSourceString(argument, indentationString));
buffer.append(")\n");
buffer.append(toSourceString(getBody(), indentationString));
return buffer.toString();
}
}