blob: 9cac198b1ad0e5e61d62582e9701b11eab1f6427 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012 NumberFour AG
*
* 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:
* NumberFour AG - initial API and Implementation (Alex Panchenko)
*******************************************************************************/
package org.eclipse.dltk.javascript.structure;
import org.eclipse.dltk.core.ISourceNode;
import org.eclipse.dltk.javascript.ast.FunctionStatement;
import org.eclipse.dltk.javascript.typeinference.ReferenceLocation;
import org.eclipse.dltk.javascript.typeinfo.IModelBuilder.IMethod;
public class FunctionDeclaration extends FunctionNode implements IDeclaration {
public FunctionDeclaration(IParentNode parent, FunctionStatement function,
IMethod method) {
super(parent, function, method);
}
@Override
public String getName() {
return function.getFunctionName();
}
@Override
public ISourceNode getNameNode() {
return function.getIdentifier();
}
public ReferenceLocation getLocation() {
return method.getLocation();
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append(getName());
sb.append('(');
sb.append(argumentsToString());
sb.append(")");
if (getType() != null) {
sb.append(':');
sb.append(getType().getName());
}
sb.append(" function");
return sb.toString();
}
}