new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / internal / compiler / ast / ImportReference.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
15
16 public class ImportReference extends AstNode {
17         
18         public char[][] tokens;
19         public long[] sourcePositions; //each entry is using the code : (start<<32) + end
20         public boolean onDemand = true; //most of the time
21         public int declarationEnd;// doesn't include an potential trailing comment
22         public int declarationSourceStart;
23         public int declarationSourceEnd;
24         public boolean used;
25
26 public ImportReference(char[][] sources , long[] poss , boolean d) {
27         tokens = sources ;
28         sourcePositions = poss ;
29         onDemand = d;
30         sourceEnd = (int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFF);
31         sourceStart = (int)(sourcePositions[0]>>>32) ;
32 }
33 /**
34  * @return char[][]
35  */
36 public char[][] getImportName() {
37         return tokens;
38 }
39 public String toString(int tab ){
40
41         return toString(tab,true);
42 }
43 public String toString(int tab, boolean withOnDemand) {
44         /* when withOnDemand is false, only the name is printed */
45         StringBuffer buffer = new StringBuffer();
46         for (int i = 0; i < tokens.length; i++) {
47                 buffer.append(tokens[i]);
48                 if (i < (tokens.length - 1)) {
49                         buffer.append("."); //$NON-NLS-1$
50                 }
51         }
52         if (withOnDemand && onDemand) {
53                 buffer.append(".*"); //$NON-NLS-1$
54         }
55         return buffer.toString();
56 }
57 public void traverse(IAbstractSyntaxTreeVisitor visitor, CompilationUnitScope scope) {
58         visitor.visit(this, scope);
59         visitor.endVisit(this, scope);
60 }
61 }