/plugins/PHPParser/tags/v1_2_1/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java

# · Java · 83 lines · 57 code · 11 blank · 15 comment · 6 complexity · 55783140a19ca35a5c14dde8981473ef MD5 · raw file

  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. import java.util.List;
  13. import gatchan.phpparser.parser.Token;
  14. import gatchan.phpparser.parser.Token;
  15. import gatchan.phpparser.parser.PHPParser;
  16. public final class StringLiteral extends Literal {
  17. private String source;
  18. private AbstractVariable[] variablesInside;
  19. public StringLiteral(Token token) {
  20. this(token.image,
  21. token.sourceStart,
  22. token.sourceEnd,
  23. token.beginLine,
  24. token.endLine,
  25. token.beginColumn,
  26. token.endColumn,
  27. null);
  28. }
  29. public StringLiteral(String source,
  30. int sourceStart,
  31. int sourceEnd,
  32. int beginLine,
  33. int endLine,
  34. int beginColumn,
  35. int endColumn) {
  36. this(source, sourceStart, sourceEnd, beginLine, endLine, beginColumn, endColumn, null);
  37. }
  38. public StringLiteral(String source,
  39. int sourceStart,
  40. int sourceEnd,
  41. int beginLine,
  42. int endLine,
  43. int beginColumn,
  44. int endColumn,
  45. AbstractVariable[] variablesInside) {
  46. super(Type.STRING, sourceStart, sourceEnd, beginLine, endLine, beginColumn, endColumn);
  47. this.source = source;
  48. this.variablesInside = variablesInside;
  49. }
  50. /**
  51. * Return the expression as String.
  52. *
  53. * @return the expression
  54. */
  55. public String toStringExpression() {
  56. return source;
  57. }
  58. public void getUsedVariable(List list) {
  59. if (variablesInside != null) {
  60. for (int i = 0; i < variablesInside.length; i++) {
  61. variablesInside[i].getUsedVariable(list);
  62. }
  63. }
  64. }
  65. public void analyzeCode(PHPParser parser) {
  66. if (variablesInside != null) {
  67. for (int i = 0; i < variablesInside.length; i++) {
  68. variablesInside[i].analyzeCode(parser);
  69. }
  70. }
  71. }
  72. }