1 /***********************************************************************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made
3 * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
4 * http://www.eclipse.org/legal/cpl-v10.html
6 * Contributors: IBM Corporation - initial API and implementation
7 **********************************************************************************************************************************/
8 package net.sourceforge.phpeclipse.internal.compiler.ast;
10 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
11 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
13 import org.eclipse.core.resources.IFile;
15 public class ImportReference extends ASTNode {
17 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
22 public final char[] includeSource;
24 public int declarationEnd;// doesn't include an potential trailing comment
26 public int declarationSourceStart;
28 public int declarationSourceEnd;
34 public ImportReference(char[][] sources, char[] sourceString, int start, int end, boolean d) { // char[][] sources , long[] poss ,
37 // sourcePositions = poss ;
38 includeSource = sourceString;
40 sourceEnd = end;//(int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFF);
41 sourceStart = start;//(int)(sourcePositions[0]>>>32) ;
48 public char[][] getImportName() {
52 public char[] getIncludeName() {
56 public StringBuffer print(int indent, StringBuffer output) {
58 return print(indent, output, true);
61 public StringBuffer print(int tab, StringBuffer output, boolean withOnDemand) {
63 /* when withOnDemand is false, only the name is printed */
64 for (int i = 0; i < tokens.length; i++) {
67 output.append(tokens[i]);
69 if (withOnDemand && onDemand) {
70 output.append(".*"); //$NON-NLS-1$
75 public String toString(int tab) {
77 return toString(tab, true);
80 public String toString(int tab, boolean withOnDemand) {
81 /* when withOnDemand is false, only the name is printed */
82 StringBuffer buffer = new StringBuffer();
83 for (int i = 0; i < tokens.length; i++) {
84 buffer.append(tokens[i]);
85 if (i < (tokens.length - 1)) {
86 buffer.append("."); //$NON-NLS-1$
89 if (withOnDemand && onDemand) {
90 buffer.append(".*"); //$NON-NLS-1$
93 buffer.append(includeSource);
94 return buffer.toString();
95 // return new String(includeSource);
98 public void traverse(ASTVisitor visitor, CompilationUnitScope scope) {
99 visitor.visit(this, scope);
100 visitor.endVisit(this, scope);
104 * @return Returns the filePath.
106 public IFile getFile() {
112 * The filePath to set.
114 public void setFile(IFile filePath) {