01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.ASTVisitor;
13: import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14: import org.eclipse.jdt.internal.compiler.lookup.*;
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 int declarationEnd; // doesn't include an potential trailing comment
21: public int declarationSourceStart;
22: public int declarationSourceEnd;
23: public int modifiers; // 1.5 addition for static imports
24: public Annotation[] annotations;
25:
26: public ImportReference(char[][] tokens, long[] sourcePositions,
27: boolean onDemand, int modifiers) {
28:
29: this .tokens = tokens;
30: this .sourcePositions = sourcePositions;
31: if (onDemand) {
32: this .bits |= ASTNode.OnDemand;
33: }
34: this .sourceEnd = (int) (sourcePositions[sourcePositions.length - 1] & 0x00000000FFFFFFFF);
35: this .sourceStart = (int) (sourcePositions[0] >>> 32);
36: this .modifiers = modifiers;
37: }
38:
39: public boolean isStatic() {
40: return (this .modifiers & ClassFileConstants.AccStatic) != 0;
41: }
42:
43: /**
44: * @return char[][]
45: */
46: public char[][] getImportName() {
47:
48: return tokens;
49: }
50:
51: public StringBuffer print(int indent, StringBuffer output) {
52:
53: return print(indent, output, true);
54: }
55:
56: public StringBuffer print(int tab, StringBuffer output,
57: boolean withOnDemand) {
58:
59: /* when withOnDemand is false, only the name is printed */
60: for (int i = 0; i < tokens.length; i++) {
61: if (i > 0)
62: output.append('.');
63: output.append(tokens[i]);
64: }
65: if (withOnDemand && ((this .bits & ASTNode.OnDemand) != 0)) {
66: output.append(".*"); //$NON-NLS-1$
67: }
68: return output;
69: }
70:
71: public void traverse(ASTVisitor visitor, CompilationUnitScope scope) {
72: // annotations are traversed during the compilation unit traversal using a class scope
73: visitor.visit(this, scope);
74: visitor.endVisit(this, scope);
75: }
76: }
|