A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / QualifiedTypeReference.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.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 public class QualifiedTypeReference extends TypeReference {
20         public char[][] tokens;
21
22         public long[] sourcePositions;
23
24         public QualifiedTypeReference(char[][] sources, long[] poss) {
25                 tokens = sources;
26                 sourcePositions = poss;
27                 sourceStart = (int) (sourcePositions[0] >>> 32);
28                 sourceEnd = (int) (sourcePositions[sourcePositions.length - 1] & 0x00000000FFFFFFFFL);
29         }
30
31         public QualifiedTypeReference(char[][] sources, TypeBinding type,
32                         long[] poss) {
33                 this(sources, poss);
34                 this.resolvedType = type;
35         }
36
37         public TypeReference copyDims(int dim) {
38                 // return a type reference copy of me with some dimensions
39                 // warning : the new type ref has a null binding
40
41                 return new ArrayQualifiedTypeReference(tokens, null, dim,
42                                 sourcePositions);
43         }
44
45         public TypeBinding getTypeBinding(Scope scope) {
46                 if (this.resolvedType != null)
47                         return this.resolvedType;
48                 return scope.getType(tokens);
49         }
50
51         public char[][] getTypeName() {
52
53                 return tokens;
54         }
55
56         public StringBuffer printExpression(int indent, StringBuffer output) {
57
58                 for (int i = 0; i < tokens.length; i++) {
59                         if (i > 0)
60                                 output.append('.');
61                         output.append(tokens[i]);
62                 }
63                 return output;
64         }
65
66         public String toStringExpression(int tab) {
67                 StringBuffer buffer = new StringBuffer();
68                 for (int i = 0; i < tokens.length; i++) {
69                         buffer.append(tokens[i]);
70                         if (i < (tokens.length - 1)) {
71                                 buffer.append("."); //$NON-NLS-1$
72                         }
73                 }
74                 return buffer.toString();
75         }
76
77         public void traverse(ASTVisitor visitor, BlockScope scope) {
78                 visitor.visit(this, scope);
79                 visitor.endVisit(this, scope);
80         }
81
82         public void traverse(ASTVisitor visitor, ClassScope scope) {
83                 visitor.visit(this, scope);
84                 visitor.endVisit(this, scope);
85         }
86 }