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

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


    // notify the nodes in the syntactical order
    if (length > 0) {
      quickSort(nodes, 0, length-1);
      for (int i=0;i<length;i++) {
        ASTNode node = nodes[i];
        if (node instanceof ImportReference) {
          ImportReference importRef = (ImportReference)node;
          if (node == parsedUnit.currentPackage) {
            notifySourceElementRequestor(importRef, true);
          } else {
View Full Code Here


* Sort the given ast nodes by their positions.
*/
private static void quickSort(ASTNode[] sortedCollection, int left, int right) {
  int original_left = left;
  int original_right = right;
  ASTNode mid = sortedCollection[left +  (right - left) / 2];
  do {
    while (sortedCollection[left].sourceStart < mid.sourceStart) {
      left++;
    }
    while (mid.sourceStart < sortedCollection[right].sourceStart) {
      right--;
    }
    if (left <= right) {
      ASTNode tmp = sortedCollection[left];
      sortedCollection[left] = sortedCollection[right];
      sortedCollection[right] = tmp;
      left++;
      right--;
    }
View Full Code Here

private ASTNode getExceptionType(int index) { 
  if (this.exceptionToCatchBlockMap == null) {
    return this.catchArguments[index].type;
  }
  int catchBlock = this.exceptionToCatchBlockMap[index];
  ASTNode node = this.catchArguments[catchBlock].type;
  if (node instanceof UnionTypeReference) {
    TypeReference[] typeRefs = ((UnionTypeReference)node).typeReferences;
    for (int i = 0, len = typeRefs.length; i < len; i++) {
      TypeReference typeRef = typeRefs[i];
      if (typeRef.resolvedType == this.handledExceptions[index]) return typeRef;
View Full Code Here

    addPotentialNullInfoFrom(callerFlowInfo.unconditionalInitsWithoutSideEffect());
  if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) {
    // check only immutable null checks on innermost looping context
    for (int i = 0; i < this.nullCount; i++) {
      LocalVariableBinding local = this.nullLocals[i];
      ASTNode location = this.nullReferences[i];
      // final local variable
      switch (this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) {
        case CAN_ONLY_NON_NULL | IN_COMPARISON_NULL:
        case CAN_ONLY_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_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;
          }
          break;
        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;
          }
          if (flowInfo.isDefinitelyNull(local)) {
            this.nullReferences[i] = null;
            if ((this.nullCheckTypes[i] & ~HIDE_NULL_COMPARISON_WARNING_MASK) == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
              if ((this.nullCheckTypes[i] & HIDE_NULL_COMPARISON_WARNING) == 0) {
                scope.problemReporter().localVariableRedundantCheckOnNull(local, location);
              }
            } else {
              scope.problemReporter().localVariableNullComparedToNonNull(local, location);
            }
            continue;
          }
          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);
          }
          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:
View Full Code Here

    traversedContext.recordReturnFrom(flowInfo.unconditionalInits());

    if (!isExceptionOnAutoClose) {
      if (traversedContext instanceof InsideSubRoutineFlowContext) {
        ASTNode node = traversedContext.associatedNode;
        if (node instanceof TryStatement) {
          TryStatement tryStatement = (TryStatement) node;
          flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
        }
      }
View Full Code Here

      return;

    traversedContext.recordReturnFrom(flowInfo.unconditionalInits());

    if (traversedContext instanceof InsideSubRoutineFlowContext) {
      ASTNode node = traversedContext.associatedNode;
      if (node instanceof TryStatement) {
        TryStatement tryStatement = (TryStatement) node;
        flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
      }
    }
View Full Code Here

    }
  }
  else { // no enclosing loop, be as precise as possible right now
    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:
View Full Code Here

    traversedContext.recordReturnFrom(flowInfo.unconditionalInits());

    if (!isExceptionOnAutoClose) {
      if (traversedContext instanceof InsideSubRoutineFlowContext) {
        ASTNode node = traversedContext.associatedNode;
        if (node instanceof TryStatement) {
          TryStatement tryStatement = (TryStatement) node;
          flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
        }
      }
View Full Code Here

      return;

    traversedContext.recordReturnFrom(flowInfo.unconditionalInits());

    if (traversedContext instanceof InsideSubRoutineFlowContext) {
      ASTNode node = traversedContext.associatedNode;
      if (node instanceof TryStatement) {
        TryStatement tryStatement = (TryStatement) node;
        flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
      }
    }
View Full Code Here

private ASTNode getExceptionType(int index) { 
  if (this.exceptionToCatchBlockMap == null) {
    return this.catchArguments[index].type;
  }
  int catchBlock = this.exceptionToCatchBlockMap[index];
  ASTNode node = this.catchArguments[catchBlock].type;
  if (node instanceof UnionTypeReference) {
    TypeReference[] typeRefs = ((UnionTypeReference)node).typeReferences;
    for (int i = 0, len = typeRefs.length; i < len; i++) {
      TypeReference typeRef = typeRefs[i];
      if (typeRef.resolvedType == this.handledExceptions[index]) return typeRef;
View Full Code Here

TOP

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

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.