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
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 public class ExtendedStringLiteral extends StringLiteral {
18 private static final int INIT_SIZE = 30;
21 * Build a string+char literal
23 public ExtendedStringLiteral(StringLiteral str, CharLiteral character) {
25 super(str.source, str.sourceStart, str.sourceEnd);
26 extendWith(character);
30 * Build a two-strings literal
32 public ExtendedStringLiteral(StringLiteral str1, StringLiteral str2) {
34 super(str1.source, str1.sourceStart, str1.sourceEnd);
39 * Add the lit source to mine, just as if it was mine
41 public ExtendedStringLiteral extendWith(CharLiteral lit) {
44 int length = source.length;
45 System.arraycopy(source, 0, (source = new char[length + 1]), 0, length);
46 source[length] = lit.value;
47 //position at the end of all literals
48 sourceEnd = lit.sourceEnd;
53 * Add the lit source to mine, just as if it was mine
55 public ExtendedStringLiteral extendWith(StringLiteral lit) {
58 int length = source.length;
62 source = new char[length + lit.source.length],
65 System.arraycopy(lit.source, 0, source, length, lit.source.length);
66 //position at the end of all literals
67 sourceEnd = lit.sourceEnd;
71 public String toStringExpression() {
73 String str = "ExtendedStringLiteral{" + new String(source) + "}"; //$NON-NLS-2$ //$NON-NLS-1$
77 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
79 visitor.visit(this, scope);
80 visitor.endVisit(this, scope);