*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / GlobalStatement.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
4 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import org.eclipse.jface.text.Position;
7
8 import java.util.List;
9 import java.util.ArrayList;
10
11 /**
12  * A GlobalStatement statement in php.
13  * @author Matthieu Casanova
14  */
15 public class GlobalStatement extends Statement implements Outlineable {
16
17   /** An array of the variables called by this global statement. */
18   public AbstractVariable[] variables;
19
20   private Object parent;
21
22   private Position position;
23
24   public GlobalStatement(final Object parent,
25                          final AbstractVariable[] variables,
26                          final int sourceStart,
27                          final int sourceEnd) {
28     super(sourceStart, sourceEnd);
29     this.variables = variables;
30     this.parent = parent;
31     position = new Position(sourceStart, sourceEnd);
32   }
33
34   public String toString() {
35     final StringBuffer buff = new StringBuffer("global ");//$NON-NLS-1$
36     for (int i = 0; i < variables.length; i++) {
37       if (i != 0) {
38         buff.append(", ");//$NON-NLS-1$
39       }
40       buff.append(variables[i]);
41     }
42     return buff.toString();
43   }
44
45   public String toString(final int tab) {
46     return tabString(tab) + toString();
47   }
48
49   /**
50    * This will return the image for the outline of the object.
51    * @return an image
52    */
53   public ImageDescriptor getImage() {
54     return PHPUiImages.DESC_INC;
55   }
56
57   public Object getParent() {
58     return parent;
59   }
60
61   public Position getPosition() {
62     return position;
63   }
64
65   /**
66    * Get the variables from outside (parameters, globals ...)
67    * @return the variables from outside
68    */
69   public List getOutsideVariable() {
70     final ArrayList list = new ArrayList(variables.length);
71     for (int i = 0; i < variables.length; i++) {
72       list.addAll(variables[i].getModifiedVariable());
73     }
74     return list;
75   }
76
77   /**
78    * get the modified variables.
79    * @return the variables modified
80    */
81   public List getModifiedVariable() {
82     return new ArrayList(1);
83   }
84
85   /**
86    * Get the variables used.
87    * @return the variables used
88    */
89   public List getUsedVariable() {
90     return new ArrayList(1);
91   }
92 }