import eclipse 3.1 M4 compiler
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / QualifiedTypeReference.java
index b37276b..d3518a0 100644 (file)
@@ -12,6 +12,7 @@ package org.eclipse.jdt.internal.compiler.ast;
 
 import org.eclipse.jdt.internal.compiler.ASTVisitor;
 import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
 
 public class QualifiedTypeReference extends TypeReference {
 
@@ -25,24 +26,65 @@ public class QualifiedTypeReference extends TypeReference {
                sourceStart = (int) (sourcePositions[0]>>>32) ;
                sourceEnd = (int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFFL ) ;
        }
-       
-       public QualifiedTypeReference(char[][] sources , TypeBinding type , long[] poss) {
                
-               this(sources,poss);
-               this.resolvedType = type;
-       }
-       
        public TypeReference copyDims(int dim){
                //return a type reference copy of me with some dimensions
                //warning : the new type ref has a null binding
-               return new ArrayQualifiedTypeReference(tokens,null,dim,sourcePositions) ;
+               return new ArrayQualifiedTypeReference(tokens, dim, sourcePositions);
        }
-       
-       public TypeBinding getTypeBinding(Scope scope) {
+
+       protected TypeBinding findNextTypeBinding(int tokenIndex, Scope scope, PackageBinding packageBinding) {
+               try {
+                   if (this.resolvedType == null) {
+                               this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding);
+                   } else {
+                           this.resolvedType = scope.getMemberType(this.tokens[tokenIndex], (ReferenceBinding) this.resolvedType);
+                               if (this.resolvedType instanceof ProblemReferenceBinding) {
+                                       ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) this.resolvedType;
+                                       this.resolvedType = new ProblemReferenceBinding(
+                                               org.eclipse.jdt.core.compiler.CharOperation.subarray(this.tokens, 0, tokenIndex + 1),
+                                               problemBinding.original,
+                                               this.resolvedType.problemId());
+                               }
+                       }
+                   return this.resolvedType;
+               } catch (AbortCompilation e) {
+                       e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
+                       throw e;
+               }
+       }
+
+       protected TypeBinding getTypeBinding(Scope scope) {
                
                if (this.resolvedType != null)
                        return this.resolvedType;
-               return scope.getType(tokens);
+
+               Binding binding = scope.getPackage(this.tokens);
+               if (binding != null && !binding.isValidBinding())
+                       return (ReferenceBinding) binding; // not found
+
+           PackageBinding packageBinding = binding == null ? null : (PackageBinding) binding;
+           boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
+           ReferenceBinding qualifiedType = null;
+               for (int i = packageBinding == null ? 0 : packageBinding.compoundName.length, max = this.tokens.length; i < max; i++) {
+                       findNextTypeBinding(i, scope, packageBinding);
+                       if (!this.resolvedType.isValidBinding())
+                               return this.resolvedType;
+                       
+                       if (isClassScope)
+                               if (((ClassScope) scope).detectHierarchyCycle(this.resolvedType, this, null)) // must connect hierarchy to find inherited member types
+                                       return null;
+                       ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
+                       if (currentType.isGenericType()) {
+                               qualifiedType = scope.environment().createRawType(currentType, qualifiedType);
+                       } else {
+                               qualifiedType = (qualifiedType != null && (qualifiedType.isRawType() || qualifiedType.isParameterizedType()))
+                                                                               ? scope.createParameterizedType((ReferenceBinding)currentType.erasure(), null, qualifiedType)
+                                                                               : currentType;
+                       }
+               }
+               this.resolvedType = qualifiedType;
+               return this.resolvedType;
        }
        
        public char[][] getTypeName(){