public void resolveJavadoc() {

    if (this.binding == null) return;
    if (this.javadoc != null) {
      this.javadoc.resolve(this.scope);
      return;
    }
    if (this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) {
      // Set javadoc visibility
      int javadocVisibility = this.binding.modifiers & ExtraCompilerModifiers.AccVisibilityMASK;
      ClassScope classScope = this.scope.classScope();
      ProblemReporter reporter = this.scope.problemReporter();
      int severity = reporter.computeSeverity(IProblem.JavadocMissing);
      if (severity != ProblemSeverities.Ignore) {
        if (classScope != null) {
          javadocVisibility =
              Util.computeOuterMostVisibility(classScope.referenceType(), javadocVisibility);
        }
        int javadocModifiers =
            (this.binding.modifiers & ~ExtraCompilerModifiers.AccVisibilityMASK)
                | javadocVisibility;
        reporter.javadocMissing(this.sourceStart, this.sourceEnd, severity, javadocModifiers);
      }
    }
  }
 ProblemReporter problemReporter(MethodBinding currentMethod) {
   ProblemReporter reporter = problemReporter();
   if (currentMethod.declaringClass
       == type) // only report against the currentMethod if its implemented by the type
   reporter.referenceContext = currentMethod.sourceMethod();
   return reporter;
 }
 public void checkTypeArgumentRedundancy(
     ParameterizedTypeBinding allocationType,
     ReferenceBinding enclosingType,
     TypeBinding[] argumentTypes,
     final BlockScope scope) {
   ProblemReporter reporter = scope.problemReporter();
   if ((reporter.computeSeverity(IProblem.RedundantSpecificationOfTypeArguments)
           == ProblemSeverities.Ignore)
       || scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_7) return;
   if (allocationType.arguments == null) return; // raw binding
   if (this.genericTypeArguments != null)
     return; // diamond can't occur with explicit type args for constructor
   if (argumentTypes == Binding.NO_PARAMETERS
       && this.typeExpected instanceof ParameterizedTypeBinding) {
     ParameterizedTypeBinding expected = (ParameterizedTypeBinding) this.typeExpected;
     if (expected.arguments != null
         && allocationType.arguments.length == expected.arguments.length) {
       // check the case when no ctor takes no params and inference uses the expected type directly
       // eg. X<String> x = new X<String>()
       int i;
       for (i = 0; i < allocationType.arguments.length; i++) {
         if (allocationType.arguments[i] != expected.arguments[i]) break;
       }
       if (i == allocationType.arguments.length) {
         reporter.redundantSpecificationOfTypeArguments(this.type, allocationType.arguments);
         return;
       }
     }
   }
   TypeBinding[] inferredTypes =
       inferElidedTypes(allocationType.genericType(), enclosingType, argumentTypes, scope);
   if (inferredTypes == null) {
     return;
   }
   for (int i = 0; i < inferredTypes.length; i++) {
     if (inferredTypes[i] != allocationType.arguments[i]) return;
   }
   reporter.redundantSpecificationOfTypeArguments(this.type, allocationType.arguments);
 }
 public boolean isSuppressed(CategorizedProblem problem) {
   if (this.suppressWarningsCount == 0) return false;
   int irritant = ProblemReporter.getIrritant(problem.getID());
   if (irritant == 0) return false;
   int start = problem.getSourceStart();
   int end = problem.getSourceEnd();
   nextSuppress:
   for (int iSuppress = 0, suppressCount = this.suppressWarningsCount;
       iSuppress < suppressCount;
       iSuppress++) {
     long position = this.suppressWarningScopePositions[iSuppress];
     int startSuppress = (int) (position >>> 32);
     int endSuppress = (int) position;
     if (start < startSuppress) continue nextSuppress;
     if (end > endSuppress) continue nextSuppress;
     if (this.suppressWarningIrritants[iSuppress].isSet(irritant)) return true;
   }
   return false;
 }
 public void finalizeProblems() {
   if (this.suppressWarningsCount == 0) return;
   int removed = 0;
   CategorizedProblem[] problems = this.compilationResult.problems;
   int problemCount = this.compilationResult.problemCount;
   IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount];
   CompilerOptions options = this.scope.compilerOptions();
   boolean hasMandatoryErrors = false;
   nextProblem:
   for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
     CategorizedProblem problem = problems[iProblem];
     int problemID = problem.getID();
     int irritant = ProblemReporter.getIrritant(problemID);
     boolean isError = problem.isError();
     if (isError) {
       if (irritant == 0) {
         // tolerate unused warning tokens when mandatory errors
         hasMandatoryErrors = true;
         continue;
       }
       if (!options.suppressOptionalErrors) {
         continue;
       }
     }
     int start = problem.getSourceStart();
     int end = problem.getSourceEnd();
     nextSuppress:
     for (int iSuppress = 0, suppressCount = this.suppressWarningsCount;
         iSuppress < suppressCount;
         iSuppress++) {
       long position = this.suppressWarningScopePositions[iSuppress];
       int startSuppress = (int) (position >>> 32);
       int endSuppress = (int) position;
       if (start < startSuppress) continue nextSuppress;
       if (end > endSuppress) continue nextSuppress;
       if (!this.suppressWarningIrritants[iSuppress].isSet(irritant)) continue nextSuppress;
       // discard suppressed warning
       removed++;
       problems[iProblem] = null;
       this.compilationResult.removeProblem(problem);
       if (foundIrritants[iSuppress] == null) {
         foundIrritants[iSuppress] = new IrritantSet(irritant);
       } else {
         foundIrritants[iSuppress].set(irritant);
       }
       continue nextProblem;
     }
   }
   // compact remaining problems
   if (removed > 0) {
     for (int i = 0, index = 0; i < problemCount; i++) {
       CategorizedProblem problem;
       if ((problem = problems[i]) != null) {
         if (i > index) {
           problems[index++] = problem;
         } else {
           index++;
         }
       }
     }
   }
   // flag SuppressWarnings which had no effect (only if no (mandatory) error got detected within
   // unit
   if (!hasMandatoryErrors) {
     int severity = options.getSeverity(CompilerOptions.UnusedWarningToken);
     if (severity != ProblemSeverities.Ignore) {
       boolean unusedWarningTokenIsWarning = (severity & ProblemSeverities.Error) == 0;
       for (int iSuppress = 0, suppressCount = this.suppressWarningsCount;
           iSuppress < suppressCount;
           iSuppress++) {
         Annotation annotation = this.suppressWarningAnnotations[iSuppress];
         if (annotation == null) continue; // implicit annotation
         IrritantSet irritants = this.suppressWarningIrritants[iSuppress];
         if (unusedWarningTokenIsWarning && irritants.areAllSet())
           continue; // @SuppressWarnings("all") also suppresses unused warning token
         if (irritants != foundIrritants[iSuppress]) { // mismatch, some warning tokens were unused
           MemberValuePair[] pairs = annotation.memberValuePairs();
           pairLoop:
           for (int iPair = 0, pairCount = pairs.length; iPair < pairCount; iPair++) {
             MemberValuePair pair = pairs[iPair];
             if (CharOperation.equals(pair.name, TypeConstants.VALUE)) {
               Expression value = pair.value;
               if (value instanceof ArrayInitializer) {
                 ArrayInitializer initializer = (ArrayInitializer) value;
                 Expression[] inits = initializer.expressions;
                 if (inits != null) {
                   for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) {
                     Constant cst = inits[iToken].constant;
                     if (cst != Constant.NotAConstant
                         && cst.typeID() == TypeIds.T_JavaLangString) {
                       IrritantSet tokenIrritants =
                           CompilerOptions.warningTokenToIrritants(cst.stringValue());
                       if (tokenIrritants != null
                           && !tokenIrritants
                               .areAllSet() // no complaint against @SuppressWarnings("all")
                           && options.isAnyEnabled(
                               tokenIrritants) // if irritant is effectively enabled
                           && (foundIrritants[iSuppress] == null
                               || !foundIrritants[iSuppress].isAnySet(
                                   tokenIrritants))) { // if irritant had no matching problem
                         if (unusedWarningTokenIsWarning) {
                           int start = value.sourceStart, end = value.sourceEnd;
                           nextSuppress:
                           for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
                             long position = this.suppressWarningScopePositions[jSuppress];
                             int startSuppress = (int) (position >>> 32);
                             int endSuppress = (int) position;
                             if (start < startSuppress) continue nextSuppress;
                             if (end > endSuppress) continue nextSuppress;
                             if (this.suppressWarningIrritants[jSuppress].areAllSet())
                               break pairLoop; // suppress all?
                           }
                         }
                         this.scope.problemReporter().unusedWarningToken(inits[iToken]);
                       }
                     }
                   }
                 }
               } else {
                 Constant cst = value.constant;
                 if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
                   IrritantSet tokenIrritants =
                       CompilerOptions.warningTokenToIrritants(cst.stringValue());
                   if (tokenIrritants != null
                       && !tokenIrritants
                           .areAllSet() // no complaint against @SuppressWarnings("all")
                       && options.isAnyEnabled(
                           tokenIrritants) // if irritant is effectively enabled
                       && (foundIrritants[iSuppress] == null
                           || !foundIrritants[iSuppress].isAnySet(
                               tokenIrritants))) { // if irritant had no matching problem
                     if (unusedWarningTokenIsWarning) {
                       int start = value.sourceStart, end = value.sourceEnd;
                       nextSuppress:
                       for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
                         long position = this.suppressWarningScopePositions[jSuppress];
                         int startSuppress = (int) (position >>> 32);
                         int endSuppress = (int) position;
                         if (start < startSuppress) continue nextSuppress;
                         if (end > endSuppress) continue nextSuppress;
                         if (this.suppressWarningIrritants[jSuppress].areAllSet())
                           break pairLoop; // suppress all?
                       }
                     }
                     this.scope.problemReporter().unusedWarningToken(value);
                   }
                 }
               }
               break pairLoop;
             }
           }
         }
       }
     }
   }
 }
示例#6
0
 public void fire() {
   MessageSend messageSend = messageSendRef.get();
   if (messageSend != null) problemReporter.errorNoMethodFor(messageSend, recType, params);
 }
示例#7
0
 public void fire() {
   MessageSend messageSend = messageSendRef.get();
   if (messageSend != null) problemReporter.invalidMethod(messageSend, method);
 }
 public void resolve(MethodScope var1) {
   if ((this.field_446 & 16) == 0) {
     if (this.binding != null && this.binding.isValidBinding()) {
       this.field_446 |= 16;
       ClassScope var2 = var1.method_582();
       if (var2 != null) {
         label338:
         {
           SourceTypeBinding var3 = var2.enclosingSourceType();
           if (var3.superclass != null) {
             FieldBinding var4 = var2.findField(var3.superclass, this.name, this, false);
             if (var4 != null && var4.isValidBinding()) {
               label334:
               {
                 if (var4 instanceof FieldBinding) {
                   FieldBinding var5 = (FieldBinding) var4;
                   if (var5.original() == this.binding || !var5.canBeSeenBy(var3, this, var1)) {
                     break label334;
                   }
                 }
                 var1.problemReporter().fieldHiding(this, var4);
                 break label338;
               }
             }
           }
           Scope var13 = var2.parent;
           if (var13.kind != 4) {
             Binding var15 = var13.getBinding(this.name, 3, this, false);
             if (var15 != null && var15.isValidBinding() && var15 != this.binding) {
               label323:
               {
                 if (var15 instanceof FieldBinding) {
                   FieldBinding var6 = (FieldBinding) var15;
                   if (var6.original() == this.binding
                       || !var6.method_431() && var3.method_226()) {
                     break label323;
                   }
                 }
                 var1.problemReporter().fieldHiding(this, var15);
               }
             }
           }
         }
       }
       if (this.type != null) {
         this.type.resolvedType = this.binding.type;
       }
       FieldBinding var12 = var1.initializedField;
       int var14 = var1.field_407;
       try {
         var1.initializedField = this.binding;
         var1.field_407 = this.binding.field_304;
         method_761(var1, this.annotations, this.binding);
         if ((this.binding.getAnnotationTagBits() & 70368744177664L) == 0L
             && (this.binding.field_300 & 1048576) != 0
             && var1.compilerOptions().field_1928 >= 3211264L) {
           var1.problemReporter().method_1675(this);
         }
         if (this.initialization == null) {
           this.binding.setConstant(Constant.NotAConstant);
         } else {
           this.binding.setConstant(Constant.NotAConstant);
           TypeBinding var17 = this.binding.type;
           this.initialization.setExpectedType(var17);
           TypeBinding var18;
           if (this.initialization instanceof ArrayInitializer) {
             if ((var18 = this.initialization.resolveTypeExpecting(var1, var17)) != null) {
               ((ArrayInitializer) this.initialization).binding = (ArrayBinding) var18;
               this.initialization.computeConversion(var1, var17, var18);
             }
           } else if ((var18 = this.initialization.resolveType(var1)) != null) {
             if (var17 != var18) {
               var1.compilationUnitScope().recordTypeConversion(var17, var18);
             }
             if (!this.initialization.isConstantValueOfTypeAssignableToType(var18, var17)
                 && (!var17.method_148() || !BaseTypeBinding.method_185(var17.id, var18.id))
                 && !var18.isCompatibleWith(var17)) {
               if (!var1.isBoxingCompatibleWith(var18, var17)
                   && (!var18.method_148()
                       || var1.compilerOptions().field_1928 < 3211264L
                       || var17.method_148()
                       || !this.initialization.isConstantValueOfTypeAssignableToType(
                           var18, var1.environment().method_486(var17)))) {
                 if ((var17.tagBits & 128L) == 0L) {
                   var1.problemReporter()
                       .typeMismatchError(var18, var17, this.initialization, (ASTNode) null);
                 }
               } else {
                 this.initialization.computeConversion(var1, var17, var18);
                 if (this.initialization instanceof CastExpression
                     && (this.initialization.field_446 & 16384) == 0) {
                   CastExpression.checkNeedForAssignedCast(
                       var1, var17, (CastExpression) this.initialization);
                 }
               }
             } else {
               this.initialization.computeConversion(var1, var17, var18);
               if (var18.method_174(var17)) {
                 var1.problemReporter().method_1806(this.initialization, var18, var17);
               }
               if (this.initialization instanceof CastExpression
                   && (this.initialization.field_446 & 16384) == 0) {
                 CastExpression.checkNeedForAssignedCast(
                     var1, var17, (CastExpression) this.initialization);
               }
             }
             if (this.binding.method_409()) {
               this.binding.setConstant(
                   this.initialization.constant.castTo(
                       (this.binding.type.id << 4) + this.initialization.constant.typeID()));
             }
           } else {
             this.binding.setConstant(Constant.NotAConstant);
           }
           if (this.binding == Assignment.method_944(this.initialization)) {
             var1.problemReporter().assignmentHasNoEffect(this, this.name);
           }
         }
         if (this.binding != null
             && this.binding.declaringClass != null
             && !this.binding.declaringClass.method_158()) {
           int var16 = this.binding.field_300 & 7;
           ProblemReporter var19 = var1.problemReporter();
           int var7 = var19.computeSeverity(-1610612250);
           if (var7 != -1) {
             if (var2 != null) {
               var16 = Util.computeOuterMostVisibility(var2.referenceType(), var16);
             }
             int var8 = this.binding.field_300 & -8 | var16;
           }
         }
       } finally {
         var1.initializedField = var12;
         var1.field_407 = var14;
         if (this.binding.constant() == null) {
           this.binding.setConstant(Constant.NotAConstant);
         }
       }
     }
   }
 }