1 package net.sourceforge.phpdt.internal.compiler.parser;
3 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
5 import org.eclipse.jface.resource.ImageDescriptor;
8 import java.util.Hashtable;
10 import java.util.Enumeration;
15 * A function declaration.
18 public class PHPFunctionDeclaration extends PHPSegmentWithChildren {
20 private final Hashtable parameters;
21 private String stringRepresentation;
24 * Create a function declaration.
25 * @param parent the parent object (it should be a php class)
26 * @param name the name of the function
27 * @param index where the function is in the file
29 public PHPFunctionDeclaration(Object parent, String name, int index) {
30 super(parent, name, index);
35 * Create a function declaration.
36 * @param parent the parent object (it should be a php class)
37 * @param name the name of the function
38 * @param index where the function is in the file
39 * @param parameters the list of parameters (it should contains only PHPVar)
41 public PHPFunctionDeclaration(Object parent, String name, int index, Hashtable parameters) {
42 super(parent, name, index);
43 this.parameters = parameters;
48 * Get the image of a class.
49 * @return the image that represents a php class
51 public ImageDescriptor getImage() {
52 return PHPUiImages.DESC_FUN;
55 public String toString() {
56 if (parameters == null) {
57 return super.toString();
59 return stringRepresentation;
62 private void createStringView() {
63 StringBuffer buff = new StringBuffer(name).append("(");
64 Enumeration vars = parameters.elements();
66 while (vars.hasMoreElements()) {
67 PHPVarDeclaration o = (PHPVarDeclaration) vars.nextElement();
72 buff.append(o.toString());
75 stringRepresentation = buff.toString();
78 public PHPVarDeclaration getParameter(String parameterName) {
79 return (PHPVarDeclaration) parameters.get(parameterName);
82 public Hashtable getParameters() {