Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable


          if (nullStatus != FlowInfo.NON_NULL) {
            this.parent.recordNullityMismatch(scope, (Expression)location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus);
          }
          continue; // no more delegation to parent
        case EXIT_RESOURCE:
            FakedTrackingVariable trackingVar = local.closeTracker;
            if (trackingVar != null) {
              if (trackingVar.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (trackingVar.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              if (this.parent.recordExitAgainstResource(scope, flowInfo, trackingVar, location)) {
                this.nullReferences[i] = null;
                continue;
              }
            }
          break;
        case IN_UNBOXING:
          checkUnboxing(scope, (Expression) location, flowInfo);
          continue; // delegation to parent already handled in the above.
        default:
          // never happens
      }
      // https://bugs.eclipse.org/376263: avoid further deferring if the upstream info
      // already has definite information (which might get lost for deferred checking).
      if (!(this.nullCheckTypes[i] == MAY_NULL && upstreamCopy.isDefinitelyNonNull(local))) {
        this.parent.recordUsingNullReference(scope, local, location,
            this.nullCheckTypes[i], flowInfo);
      }
    }
  }
  else {
    // check inconsistent null checks on outermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      ASTNode location = this.nullReferences[i];
      // final local variable
      LocalVariableBinding local = this.nullLocals[i];
      switch (this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) {
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
          if (flowInfo.isDefinitelyNonNull(local)) {
            this.nullReferences[i] = null;
            if ((this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
              if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                scope.problemReporter().localVariableRedundantCheckOnNonNull(local, location);
              }
            } else {
              scope.problemReporter().localVariableNonNullComparedToNull(local, location);
            }
            continue;
          }
          //$FALL-THROUGH$
        case CAN_ONLY_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
        case CAN_ONLY_NULL | IN_ASSIGNMENT:
        case CAN_ONLY_NULL | IN_INSTANCEOF:
          Expression expression = (Expression) location;
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                  scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
                }
                continue;
              case FlowContext.IN_COMPARISON_NON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
                continue;
              case FlowContext.IN_ASSIGNMENT:
                scope.problemReporter().localVariableRedundantNullAssignment(local, expression);
                continue;
              case FlowContext.IN_INSTANCEOF:
                scope.problemReporter().localVariableNullInstanceof(local, expression);
                continue;
            }
          } else if (flowInfo.isPotentiallyNull(local)) {
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
              case FlowContext.IN_COMPARISON_NON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
            }
          }
          break;
        case MAY_NULL:
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariableNullReference(local, location);
            continue;
          }
          if (flowInfo.isPotentiallyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariablePotentialNullReference(local, location);
            continue;
          }
          break;
        case ASSIGN_TO_NONNULL:
          int nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            char[][] annotationName = scope.environment().getNonNullAnnotationName();
            scope.problemReporter().nullityMismatch((Expression) location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus, annotationName);
          }
          break;
        case EXIT_RESOURCE:
          nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            FakedTrackingVariable closeTracker = local.closeTracker;
            if (closeTracker != null) {
              if (closeTracker.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (closeTracker.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              nullStatus = closeTracker.findMostSpecificStatus(flowInfo, scope, null);
              closeTracker.recordErrorLocation(this.nullReferences[i], nullStatus);
              closeTracker.reportRecordedErrors(scope, nullStatus);
              this.nullReferences[i] = null;
              continue;
            }
          }
          break;
View Full Code Here


          if (nullStatus != FlowInfo.NON_NULL) {
            this.parent.recordNullityMismatch(scope, (Expression)location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus);
          }
          break;
        case EXIT_RESOURCE:
            FakedTrackingVariable trackingVar = local.closeTracker;
            if (trackingVar != null) {
              if (trackingVar.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (trackingVar.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              if (this.parent.recordExitAgainstResource(scope, flowInfo, trackingVar, location)) {
                this.nullReferences[i] = null;
                continue;
              }
            }
          break;
        case IN_UNBOXING:
          checkUnboxing(scope, (Expression) location, flowInfo);
          continue; // delegation to parent already handled in the above.
        default:
          // never happens
      }
      // https://bugs.eclipse.org/376263: avoid further deferring if the upstream info
      // already has definite information (which might get lost for deferred checking).
      if (!(this.nullCheckTypes[i] == MAY_NULL && upstreamCopy.isDefinitelyNonNull(local))) {
        this.parent.recordUsingNullReference(scope, local, location,
            this.nullCheckTypes[i], flowInfo);
      }
    }
  }
  else {
    // check inconsistent null checks on outermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      ASTNode location = this.nullReferences[i];
      // final local variable
      LocalVariableBinding local = this.nullLocals[i];
      switch (this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) {
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
          if (flowInfo.isDefinitelyNonNull(local)) {
            this.nullReferences[i] = null;
            if ((this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
              if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                scope.problemReporter().localVariableRedundantCheckOnNonNull(local, location);
              }
            } else {
              scope.problemReporter().localVariableNonNullComparedToNull(local, location);
            }
            continue;
          }
          //$FALL-THROUGH$
        case CAN_ONLY_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
        case CAN_ONLY_NULL | IN_ASSIGNMENT:
        case CAN_ONLY_NULL | IN_INSTANCEOF:
          Expression expression = (Expression) location;
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                  scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
                }
                continue;
              case FlowContext.IN_COMPARISON_NON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
                continue;
              case FlowContext.IN_ASSIGNMENT:
                scope.problemReporter().localVariableRedundantNullAssignment(local, expression);
                continue;
              case FlowContext.IN_INSTANCEOF:
                scope.problemReporter().localVariableNullInstanceof(local, expression);
                continue;
            }
          } else if (flowInfo.isPotentiallyNull(local)) {
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
              case FlowContext.IN_COMPARISON_NON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
            }
          }
          break;
        case MAY_NULL:
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariableNullReference(local, location);
            continue;
          }
          if (flowInfo.isPotentiallyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariablePotentialNullReference(local, location);
            continue;
          }
          break;
        case ASSIGN_TO_NONNULL:
          int nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            char[][] annotationName = scope.environment().getNonNullAnnotationName();
            scope.problemReporter().nullityMismatch((Expression) location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus, annotationName);
          }
          break;
        case EXIT_RESOURCE:
          nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            FakedTrackingVariable closeTracker = local.closeTracker;
            if (closeTracker != null) {
              if (closeTracker.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (closeTracker.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              nullStatus = closeTracker.findMostSpecificStatus(flowInfo, scope, null);
              closeTracker.recordErrorLocation(this.nullReferences[i], nullStatus);
              closeTracker.reportRecordedErrors(scope, nullStatus);
              this.nullReferences[i] = null;
              continue;
            }
          }
          break;
View Full Code Here

          if (nullStatus != FlowInfo.NON_NULL) {
            this.parent.recordNullityMismatch(scope, (Expression)location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus);
          }
          break;
        case EXIT_RESOURCE:
            FakedTrackingVariable trackingVar = local.closeTracker;
            if (trackingVar != null) {
              if (trackingVar.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (trackingVar.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              if (this.parent.recordExitAgainstResource(scope, flowInfo, trackingVar, location)) {
                this.nullReferences[i] = null;
                continue;
              }
            }
          break;
        default:
          // never happens
      }
      this.parent.recordUsingNullReference(scope, local, location,
          this.nullCheckTypes[i], flowInfo);
    }
  }
  else {
    // check inconsistent null checks on outermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      ASTNode location = this.nullReferences[i];
      // final local variable
      LocalVariableBinding local = this.nullLocals[i];
      switch (this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) {
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
          if (flowInfo.isDefinitelyNonNull(local)) {
            this.nullReferences[i] = null;
            if ((this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
              if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                scope.problemReporter().localVariableRedundantCheckOnNonNull(local, location);
              }
            } else {
              scope.problemReporter().localVariableNonNullComparedToNull(local, location);
            }
            continue;
          }
          //$FALL-THROUGH$
        case CAN_ONLY_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_NULL | IN_COMPARISON_NON_NULL:
        case CAN_ONLY_NULL | IN_ASSIGNMENT:
        case CAN_ONLY_NULL | IN_INSTANCEOF:
          Expression expression = (Expression) location;
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                  scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
                }
                continue;
              case FlowContext.IN_COMPARISON_NON_NULL:
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariableNullReference(local, expression);
                  continue;
                }
                scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
                continue;
              case FlowContext.IN_ASSIGNMENT:
                scope.problemReporter().localVariableRedundantNullAssignment(local, expression);
                continue;
              case FlowContext.IN_INSTANCEOF:
                scope.problemReporter().localVariableNullInstanceof(local, expression);
                continue;
            }
          } else if (flowInfo.isPotentiallyNull(local)) {
            switch(this.nullCheckTypes[i] & CONTEXT_MASK) {
              case FlowContext.IN_COMPARISON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
              case FlowContext.IN_COMPARISON_NON_NULL:
                this.nullReferences[i] = null;
                if (((this.nullCheckTypes[i] & CHECK_MASK & ~HIDE_NULL_COMPARISON_WARNING_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
                  scope.problemReporter().localVariablePotentialNullReference(local, expression);
                  continue;
                }
                break;
            }
          }
          break;
        case MAY_NULL:
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariableNullReference(local, location);
            continue;
          }
          if (flowInfo.isPotentiallyNull(local)) {
            this.nullReferences[i] = null;
            scope.problemReporter().localVariablePotentialNullReference(local, location);
            continue;
          }
          break;
        case ASSIGN_TO_NONNULL:
          int nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            char[][] annotationName = scope.environment().getNonNullAnnotationName();
            scope.problemReporter().nullityMismatch((Expression) location, this.providedExpectedTypes[i][0], this.providedExpectedTypes[i][1], nullStatus, annotationName);
          }
          break;
        case EXIT_RESOURCE:
          nullStatus = flowInfo.nullStatus(local);
          if (nullStatus != FlowInfo.NON_NULL) {
            FakedTrackingVariable closeTracker = local.closeTracker;
            if (closeTracker != null) {
              if (closeTracker.hasDefinitelyNoResource(flowInfo)) {
                continue; // no resource - no warning.
              }
              if (closeTracker.isClosedInFinallyOfEnclosing(scope)) {
                continue;
              }
              nullStatus = closeTracker.findMostSpecificStatus(flowInfo, scope, null);
              closeTracker.recordErrorLocation(this.nullReferences[i], nullStatus);
              closeTracker.reportRecordedErrors(scope, nullStatus);
              this.nullReferences[i] = null;
              continue;
            }
          }
          break;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.