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.phpeclipse.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
16 public class ImportReference extends AstNode {
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;
26 public ImportReference(char[][] sources , long[] poss , boolean d) {
28 sourcePositions = poss ;
30 sourceEnd = (int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFF);
31 sourceStart = (int)(sourcePositions[0]>>>32) ;
36 public char[][] getImportName() {
39 public String toString(int tab ){
41 return toString(tab,true);
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$
52 if (withOnDemand && onDemand) {
53 buffer.append(".*"); //$NON-NLS-1$
55 return buffer.toString();
57 public void traverse(IAbstractSyntaxTreeVisitor visitor, CompilationUnitScope scope) {
58 visitor.visit(this, scope);
59 visitor.endVisit(this, scope);