1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.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 {
19 * Build a string+char literal
21 // public ExtendedStringLiteral(StringLiteral str, CharLiteral character) {
23 // super(str.source, str.sourceStart, str.sourceEnd);
24 // extendWith(character);
27 * Build a two-strings literal
29 public ExtendedStringLiteral(StringLiteral str1, StringLiteral str2) {
31 super(str1.source, str1.sourceStart, str1.sourceEnd);
36 * Add the lit source to mine, just as if it was mine
38 // public ExtendedStringLiteral extendWith(CharLiteral lit) {
40 // //update the source
41 // int length = source.length;
42 // System.arraycopy(source, 0, (source = new char[length + 1]), 0, length);
43 // source[length] = lit.value;
44 // //position at the end of all literals
45 // sourceEnd = lit.sourceEnd;
49 * Add the lit source to mine, just as if it was mine
51 public ExtendedStringLiteral extendWith(StringLiteral lit) {
54 int length = source.length;
55 System.arraycopy(source, 0, source = new char[length
56 + lit.source.length], 0, length);
57 System.arraycopy(lit.source, 0, source, length, lit.source.length);
58 // position at the end of all literals
59 sourceEnd = lit.sourceEnd;
63 public StringBuffer printExpression(int indent, StringBuffer output) {
66 .append("ExtendedStringLiteral{").append(source).append('}'); //$NON-NLS-1$
69 public String toStringExpression() {
71 String str = "ExtendedStringLiteral{" + new String(source) + "}"; //$NON-NLS-2$ //$NON-NLS-1$
75 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
77 visitor.visit(this, scope);
78 visitor.endVisit(this, scope);