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

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


  this.visitIfNeeded(methodDeclaration);

  if (isInRange) {
    if (methodDeclaration instanceof AnnotationMethodDeclaration) {
      AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
      Expression expression = annotationMethodDeclaration.defaultValue;
      if (expression != null) {
        this.requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
        return;
      }
    }
View Full Code Here


          break;
        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;
          }
          break;
        case ASSIGN_TO_NONNULL:
          int nullStatus = flowInfo.nullStatus(local);
          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
View Full Code Here

  checkType |= (this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING);
  int checkTypeWithoutHideNullWarning = checkType & ~FlowContext.HIDE_NULL_COMPARISON_WARNING_MASK;
  switch (checkTypeWithoutHideNullWarning) {
    case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
    case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
      Expression reference = (Expression)location;
      if (flowInfo.isDefinitelyNonNull(local)) {
        if (checkTypeWithoutHideNullWarning == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
          if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
            scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
          }
View Full Code Here

  // all related catch blocks are marked as reachable... instead of those only
  // until the point where it is safely handled (Smarter - see comment at the end)
  FlowContext traversedContext = this;
  ArrayList abruptlyExitedLoops = null;
  if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7 && location instanceof ThrowStatement) {
    Expression throwExpression = ((ThrowStatement)location).exception;
    LocalVariableBinding throwArgBinding = throwExpression.localVariableBinding();
    if (throwExpression instanceof SingleNameReference // https://bugs.eclipse.org/bugs/show_bug.cgi?id=350361
        && throwArgBinding instanceof CatchParameterBinding && throwArgBinding.isEffectivelyFinal()) {
      CatchParameterBinding parameter = (CatchParameterBinding) throwArgBinding;
      checkExceptionHandlers(parameter.getPreciseTypes(), location, flowInfo, scope);
      return;
View Full Code Here

      //$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 reference = (Expression)location;
      if (flowInfo.isDefinitelyNull(local)) {
        switch(checkTypeWithoutHideNullWarning & CONTEXT_MASK) {
          case FlowContext.IN_COMPARISON_NULL:
            if (((checkTypeWithoutHideNullWarning & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning
              scope.problemReporter().localVariableNullReference(local, reference);
View Full Code Here

public boolean expressionNonNullComparison(Expression expr, boolean checkForNull) {
  int problemId = 0;
  Binding binding = null;
  String[] arguments = null;
  int start = 0, end = 0;
  Expression location = expr;

  if (expr.resolvedType != null) {
    long tagBits = expr.resolvedType.tagBits & TagBits.AnnotationNullMASK;
    if (tagBits == TagBits.AnnotationNonNull) {
      problemId = IProblem.RedundantNullCheckAgainstNonNullType;
View Full Code Here

    if (args.length != 1) {
      reportRebindProblem(site, "GWT.create() should take exactly one argument");
      return;
    }

    Expression arg = args[0];
    if (!(arg instanceof ClassLiteralAccess)) {
      reportRebindProblem(site, "Only class literals may be used as arguments to GWT.create()");
      return;
    }
View Full Code Here

      if (x.initializer != null) {
        newArray.initializers = new ArrayList();
        if (x.initializer.expressions != null) {
          for (int i = 0; i < x.initializer.expressions.length; i++) {
            Expression expression = x.initializer.expressions[i];
            newArray.initializers.add(dispProcessExpression(expression));
          }
        }
      } else {
        newArray.dims = new ArrayList();
        for (int i = 0; i < x.dimensions.length; i++) {
          Expression dimension = x.dimensions[i];
          // can be null if index expression was empty
          if (dimension == null) {
            newArray.dims.add(program.getLiteralAbsentArrayDimension());
          } else {
            newArray.dims.add(dispProcessExpression(dimension));
View Full Code Here

      JNewArray newArray = new JNewArray(program, info, type);

      newArray.initializers = new ArrayList();
      if (x.expressions != null) {
        for (int i = 0; i < x.expressions.length; i++) {
          Expression expression = x.expressions[i];
          newArray.initializers.add(dispProcessExpression(expression));
        }
      }

      return newArray;
View Full Code Here

  this.visitIfNeeded(methodDeclaration);

  if (isInRange) {
    if (methodDeclaration instanceof AnnotationMethodDeclaration) {
      AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
      Expression expression = annotationMethodDeclaration.defaultValue;
      if (expression != null) {
        this.requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
        return;
      }
    }
View Full Code Here

TOP

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

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.