Пример #1
0
 protected TypeBinding internalResolveType(Scope scope, int location) {
   // handle the error here
   this.constant = Constant.NotAConstant;
   if (this.resolvedType != null) { // is a shared type reference which was already resolved
     if (this.resolvedType.isValidBinding()) {
       return this.resolvedType;
     } else {
       switch (this.resolvedType.problemId()) {
         case ProblemReasons.NotFound:
         case ProblemReasons.NotVisible:
         case ProblemReasons.InheritedNameHidesEnclosingName:
           TypeBinding type = this.resolvedType.closestMatch();
           if (type == null) return null;
           return scope
               .environment()
               .convertToRawType(type, false /*do not force conversion of enclosing types*/);
         default:
           return null;
       }
     }
   }
   boolean hasError;
   // {ObjectTeams: don't let SelectionNodeFound(null) prevent alternate searching strategies:
   SelectionNodeFound caughtException = null;
   TypeBinding type = null;
   try {
     // base import scope first:
     CompilationResult compilationResult = scope.referenceCompilationUnit().compilationResult();
     CompilationResult.CheckPoint cp = compilationResult.getCheckPoint(scope.referenceContext());
     try {
       type =
           checkResolveUsingBaseImportScope(
               scope, location, false); // apply TOLERATE strategy only as a last resort below
       // copied from below:
       if (type != null && type.isValidBinding()) {
         type =
             scope
                 .environment()
                 .convertToRawType(type, false /*do not force conversion of enclosing types*/);
         if (type.leafComponentType().isRawType()
             && (this.bits & ASTNode.IgnoreRawTypeCheck) == 0
             && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference)
                 != ProblemSeverities.Ignore) {
           scope.problemReporter().rawTypeReference(this, type);
         }
         return type;
       }
     } catch (SelectionNodeFound snf) {
       if (snf.binding != null) throw snf; // found a valid node.
       caughtException = snf;
     } finally {
       if (caughtException != null || (type == null) || !type.isValidBinding())
         compilationResult.rollBack(cp);
     }
     // ~orig~:
     type = this.resolvedType = getTypeBinding(scope);
     if (type == null) {
       return null; // detected cycle while resolving hierarchy
     }
     // :~giro~
   } catch (SelectionNodeFound snf) {
     if (snf.binding != null) throw snf; // found a valid node.
     caughtException = snf;
   }
   // a third chance trying an anchored type:
   try {
     if ((caughtException != null) || (this.resolvedType.problemId() == ProblemReasons.NotFound)) {
       // anchored type
       TypeBinding result = resolveAnchoredType(scope);
       if (result != null) // did we do any better than before?
       type = this.resolvedType = result; // if non-null but ProblemBinding report below.
     }
   } catch (SelectionNodeFound snf2) {
     caughtException = snf2; // throw the newer exception instead.
   }
   // a forth chance trying a TOLERATED base imported type:
   try {
     if ((caughtException != null) || (this.resolvedType.problemId() == ProblemReasons.NotFound)) {
       if (this.baseclassDecapsulation == DecapsulationState.TOLERATED) {
         TypeBinding result = checkResolveUsingBaseImportScope(scope, -1, true);
         if (result != null) // did we do any better than before?
         type = this.resolvedType = result; // if non-null but ProblemBinding report below.
       }
     }
   } catch (SelectionNodeFound snf2) {
     caughtException = snf2; // throw the newer exception instead.
   } finally {
     // the attempt to prevent an exception failed:
     if (caughtException != null) throw caughtException;
   }
   // SH}
   if ((hasError = !type.isValidBinding()) == true) {
     reportInvalidType(scope);
     switch (type.problemId()) {
       case ProblemReasons.NotFound:
       case ProblemReasons.NotVisible:
       case ProblemReasons.InheritedNameHidesEnclosingName:
         type = type.closestMatch();
         if (type == null) return null;
         break;
       default:
         return null;
     }
   }
   // {ObjectTeams: Split method to make tail accessible:
   return checkResolvedType(type, scope, location, hasError);
 }