7ef16a1f7aefa997f15f8bde3024c605e6af3ff3
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / StringLiteral.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v0.5
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import test.Token;
14
15 import java.util.List;
16
17 public class StringLiteral extends Literal {
18   String source;
19
20   AbstractVariable[] variablesInside;
21
22   public StringLiteral(final Token token) {
23     super(token.sourceStart,token.sourceEnd);
24     source = token.image;
25   }
26
27   /**
28    * Create a new StringLiteral
29    * @param token the token
30    * @param s sourcestart
31    * @param e sourceend
32    * @deprecated
33    */
34   public StringLiteral(final String token, final int s, final int e) {
35     super(s, e);
36     source = token;
37   }
38
39   /**
40    * Create a new StringLiteral
41    * @param token the token
42    * @param s sourcestart
43    * @param e sourceend
44    * @deprecated
45    */
46   public StringLiteral(final String token,
47                        final int s,
48                        final int e,
49                        final AbstractVariable[] variablesInside) {
50     super(s, e);
51     source = token;
52     this.variablesInside = variablesInside;
53   }
54
55   /**
56    * Create a new StringLiteral
57    * @param token the token
58    * @param s sourcestart
59    * @param e sourceend
60    * @deprecated
61    */
62   public StringLiteral(final char[] token, final int s, final int e) {
63     this(new String(token),s, e);
64   }
65
66   public StringLiteral(final int s, final int e) {
67     super(s, e);
68   }
69   /**
70    * Return the expression as String.
71    * @return the expression
72    */
73   public String toStringExpression() {
74     return source;
75   }
76
77   /**
78    * @deprecated - use field instead
79    */
80   public int sourceEnd() {
81     return sourceEnd;
82   }
83
84   /**
85    * @deprecated - use field instead
86    */
87   public int sourceStart() {
88     return sourceStart;
89   }
90
91   public void getUsedVariable(final List list) {
92     if (variablesInside != null) {
93       for (int i = 0; i < variablesInside.length; i++) {
94         variablesInside[i].getUsedVariable(list);
95       }
96     }
97   }
98 }