Added DESC_INC and IMG_INC for the image of include/require in outline (maybe we...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ExtendedStringLiteral.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 net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15
16 public class ExtendedStringLiteral extends StringLiteral {
17
18         private static final int INIT_SIZE = 30;
19
20         /** 
21          *  Build a string+char literal
22          */
23         public ExtendedStringLiteral(StringLiteral str, CharLiteral character) {
24
25                 super(str.source, str.sourceStart, str.sourceEnd);
26                 extendWith(character);
27         }
28
29         /**     
30          * Build a two-strings literal
31          * */
32         public ExtendedStringLiteral(StringLiteral str1, StringLiteral str2) {
33
34                 super(str1.source, str1.sourceStart, str1.sourceEnd);
35                 extendWith(str2);
36         }
37
38         /**
39          * Add the lit source to mine, just as if it was mine
40          */
41         public ExtendedStringLiteral extendWith(CharLiteral lit) {
42
43                 //update the source
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;
49                 return this;
50         }
51
52         /**
53          *  Add the lit source to mine, just as if it was mine
54          */
55         public ExtendedStringLiteral extendWith(StringLiteral lit) {
56
57                 //uddate the source
58                 int length = source.length;
59                 System.arraycopy(
60                         source,
61                         0,
62                         source = new char[length + lit.source.length],
63                         0,
64                         length);
65                 System.arraycopy(lit.source, 0, source, length, lit.source.length);
66                 //position at the end of all literals
67                 sourceEnd = lit.sourceEnd;
68                 return this;
69         }
70
71         public String toStringExpression() {
72
73                 String str = "ExtendedStringLiteral{" + new String(source) + "}";       //$NON-NLS-2$ //$NON-NLS-1$
74                 return str;
75         }
76
77         public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
78
79                 visitor.visit(this, scope);
80                 visitor.endVisit(this, scope);
81         }
82 }