X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java index aced1b6..d268e64 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java @@ -10,18 +10,18 @@ ******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.ast; -//import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; -//import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream; -//import net.sourceforge.phpdt.internal.compiler.impl.Constant; -//import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; -//import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; +import java.util.List; + +import test.Token; public class StringLiteral extends Literal { - char[] source; + String source; - public StringLiteral(char[] token, int s) { - super(s, s + token.length); - source = token; + AbstractVariable[] variablesInside; + + public StringLiteral(final Token token) { + super(token.sourceStart,token.sourceEnd); + source = token.image; } /** @@ -31,69 +31,47 @@ public class StringLiteral extends Literal { * @param e sourceend * @deprecated */ - public StringLiteral(char[] token, int s, int e) { + public StringLiteral(final String token, final int s, final int e) { super(s, e); source = token; } - public StringLiteral(int s, int e) { - super(s, e); - } - /** - * source method comment. + * Create a new StringLiteral + * @param token the token + * @param s sourcestart + * @param e sourceend + * @deprecated */ - public char[] source() { - return source; + public StringLiteral(final String token, + final int s, + final int e, + final AbstractVariable[] variablesInside) { + super(s, e); + source = token; + this.variablesInside = variablesInside; } /** - * Return the expression as String. - * @return the expression + * Create a new StringLiteral + * @param token the token + * @param s sourcestart + * @param e sourceend + * @deprecated */ - /* public String toStringExpression() { - // handle some special char..... - StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$ - for (int i = 0; i < source.length; i++) { - switch (source[i]) { - case '\b': - result.append("\\b"); //$NON-NLS-1$ - break; - case '\t': - result.append("\\t"); //$NON-NLS-1$ - break; - case '\n': - result.append("\\n"); //$NON-NLS-1$ - break; - case '\f': - result.append("\\f"); //$NON-NLS-1$ - break; - case '\r': - result.append("\\r"); //$NON-NLS-1$ - break; - case '\"': - result.append("\\\""); //$NON-NLS-1$ - break; - case '\'': - result.append("\\'"); //$NON-NLS-1$ - break; - case '\\': //take care not to display the escape as a potential real char - result.append("\\\\"); //$NON-NLS-1$ - break; - default : - result.append(source[i]); - } - } - result.append("\""); //$NON-NLS-1$ - return result.toString(); - } */ + public StringLiteral(final char[] token, final int s, final int e) { + this(new String(token),s, e); + } + public StringLiteral(final int s, final int e) { + super(s, e); + } /** * Return the expression as String. * @return the expression */ public String toStringExpression() { - return new String(source); + return source; } /** @@ -109,4 +87,12 @@ public class StringLiteral extends Literal { public int sourceStart() { return sourceStart; } + + public void getUsedVariable(final List list) { + if (variablesInside != null) { + for (int i = 0; i < variablesInside.length; i++) { + variablesInside[i].getUsedVariable(list); + } + } + } }