0af2440dd0c54b8b85d6988f72d662e16eefd547
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / AbstractCase.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4 import java.util.ArrayList;
5
6 /**
7  * Superclass of case statement that we can find in a switch.
8  * @author Matthieu Casanova
9  */
10 public abstract class AbstractCase extends Statement {
11
12   /** The statements in the case. */
13   public Statement[] statements;
14
15   /**
16    * Create a case statement
17    * @param statements the statements array
18    * @param sourceStart the beginning source offset
19    * @param sourceEnd the ending offset
20    */
21   public AbstractCase(final Statement[] statements,
22                       final int sourceStart,
23                       final int sourceEnd) {
24     super(sourceStart, sourceEnd);
25     this.statements = statements;
26   }
27
28
29   /**
30    * Get the variables from outside (parameters, globals ...)
31    * @return the variables from outside
32    */
33   public List getOutsideVariable() {
34     final ArrayList list = new ArrayList();
35     for (int i = 0; i < statements.length; i++) {
36       list.addAll(statements[i].getOutsideVariable());
37     }
38     return list;
39   }
40
41   /**
42    * get the modified variables.
43    * @return the variables from we change value
44    */
45   public List getModifiedVariable() {
46     final ArrayList list = new ArrayList();
47     for (int i = 0; i < statements.length; i++) {
48       list.addAll(statements[i].getModifiedVariable());
49     }
50     return list;
51   }
52
53   /**
54    * Get the variables used.
55    * @return the variables used
56    */
57   public List getUsedVariable() {
58     final ArrayList list = new ArrayList();
59     for (int i = 0; i < statements.length; i++) {
60       list.addAll(statements[i].getUsedVariable());
61     }
62     return list;
63   }
64 }