Package org.eclipse.jdt.internal.compiler.flow

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo


        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
      }
      // check if reading a final blank field
      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
        }
      }
      if (!fieldBinding.isStatic()) {
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318682
View Full Code Here


  public static FlowInfo markPassedToOutside(BlockScope scope, Expression expression, FlowInfo flowInfo, boolean owned) { 
   
    FakedTrackingVariable trackVar = getCloseTrackingVariable(expression);
    if (trackVar != null) {
      // insert info that the tracked resource *may* be closed (by the target method, i.e.)
      FlowInfo infoResourceIsClosed = owned ? flowInfo : flowInfo.copy();
      int flag = owned ? OWNED_BY_OUTSIDE : SHARED_WITH_OUTSIDE;
      do {
        trackVar.globalClosingState |= flag;
        if (scope.methodScope() != trackVar.methodScope)
          trackVar.globalClosingState |= CLOSED_IN_NESTED_METHOD;
        infoResourceIsClosed.markAsDefinitelyNonNull(trackVar.binding);
      } while ((trackVar = trackVar.innerTracker) != null);
      if (owned) {
        return infoResourceIsClosed; // don't let downstream signal any problems on this flow
      } else {
        return FlowInfo.conditional(flowInfo, infoResourceIsClosed); // only report potential problems on this flow
View Full Code Here

      }
      // check if final blank field
      if (lastFieldBinding.isBlankFinal()
            && this.otherBindings != null // the last field binding is only assigned
           && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
        }
      }
      if (!lastFieldBinding.isStatic()) {
        currentScope.resetDeclaringClassMethodStaticFlag(lastFieldBinding.declaringClass);
      }
      break;
    case Binding.LOCAL :
      // first binding is a local variable
      LocalVariableBinding localBinding;
      if (!flowInfo
        .isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
        currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
      }
      if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)  {
        localBinding.useFlag = LocalVariableBinding.USED;
      } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
        localBinding.useFlag = LocalVariableBinding.FAKE_USED;
      }
      if (needValue) {
        checkNPE(currentScope, flowContext, flowInfo, true);
      }
  }

  if (needValue) {
    manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
    // only for first binding
  }
  // all intermediate field accesses are read accesses
  if (this.otherBindings != null) {
    for (int i = 0; i < otherBindingsCount-1; i++) {
      lastFieldBinding = this.otherBindings[i];
      needValue = !this.otherBindings[i+1].isStatic();
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, i + 1, flowInfo);
      }
    }
    lastFieldBinding = this.otherBindings[otherBindingsCount-1];
  }

  if (isCompound) {
    if (otherBindingsCount == 0
        && lastFieldBinding.isBlankFinal()
        && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
      FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass, flowInfo);
      if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
        currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
      }
    }
    manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, otherBindingsCount, flowInfo);
  }
View Full Code Here

      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
        // check if reading a final blank field
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
          FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
          if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
            currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
          }
        }
      }
      if (!fieldBinding.isStatic()) {
View Full Code Here

    switch (this.bits & ASTNode.RestrictiveFlagMASK) {
      case Binding.FIELD : // reading a field
        FieldBinding fieldBinding = (FieldBinding) this.binding;
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
          FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
          if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
            currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
          }
        }
        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
        break;
 
View Full Code Here

        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
      }
      // check if reading a final blank field
      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
        }
      }
      break;
    case Binding.LOCAL : // reading a local variable
View Full Code Here

  public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, final FlowInfo flowInfo) {
   
    if (this.ignoreFurtherInvestigation)
      return flowInfo;
   
    FlowInfo lambdaInfo = flowInfo.copy(); // what happens in vegas, stays in vegas ...
    ExceptionHandlingFlowContext methodContext =
        new ExceptionHandlingFlowContext(
            flowContext,
            this,
            this.binding.thrownExceptions,
            null,
            this.scope,
            FlowInfo.DEAD_END);

    // nullity and mark as assigned
    MethodBinding methodWithParameterDeclaration = argumentsTypeElided() ? this.descriptor : this.binding;
    AbstractMethodDeclaration.analyseArguments18(lambdaInfo, this.arguments, methodWithParameterDeclaration);

    if (this.arguments != null) {
      for (int i = 0, count = this.arguments.length; i < count; i++) {
        this.bits |= (this.arguments[i].bits & ASTNode.HasTypeAnnotations);
      }
    }
   
    lambdaInfo = this.body.analyseCode(this.scope, methodContext, lambdaInfo);
   
    // check for missing returning path for block body's ...
    if (this.body instanceof Block) {
      TypeBinding returnTypeBinding = expectedResultType();
      if ((returnTypeBinding == TypeBinding.VOID)) {
        if ((lambdaInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0 || ((Block) this.body).statements == null) {
          this.bits |= ASTNode.NeedFreeReturn;
        }
      } else {
        if (lambdaInfo != FlowInfo.DEAD_END) {
          this.scope.problemReporter().shouldReturn(returnTypeBinding, this);
        }
      }
    } else { // Expression
      if (currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled
          && lambdaInfo.reachMode() == FlowInfo.REACHABLE)
      {
        Expression expression = (Expression)this.body;
        checkAgainstNullAnnotation(flowContext, expression, expression.nullStatus(lambdaInfo, flowContext));
      }
    }
View Full Code Here

  // compound assignment extra work
  if (isCompound) { // check the variable part is initialized if blank final
    if (this.binding.isBlankFinal()
      && this.receiver.isThis()
      && currentScope.needBlankFinalFieldInitializationCheck(this.binding)) {
      FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(this.binding.declaringClass.original(), flowInfo);
      if (!fieldInits.isDefinitelyAssigned(this.binding)) {
        currentScope.problemReporter().uninitializedBlankFinalField(this.binding, this);
        // we could improve error msg here telling "cannot use compound assignment on final blank field"
      }
    }
    manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
 
View Full Code Here

      }
      // check if final blank field
      if (lastFieldBinding.isBlankFinal()
            && this.otherBindings != null // the last field binding is only assigned
           && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
        }
      }
      break;
    case Binding.LOCAL :
      // first binding is a local variable
      LocalVariableBinding localBinding;
      if (!flowInfo
        .isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
        currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
      }
      if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)  {
        localBinding.useFlag = LocalVariableBinding.USED;
      } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
        localBinding.useFlag = LocalVariableBinding.FAKE_USED;
      }
      if (needValue) {
        checkInternalNPE(currentScope, flowContext, flowInfo, true);
      }
  }

  if (needValue) {
    manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
    // only for first binding
  }
  // all intermediate field accesses are read accesses
  if (this.otherBindings != null) {
    for (int i = 0; i < otherBindingsCount-1; i++) {
      lastFieldBinding = this.otherBindings[i];
      needValue = !this.otherBindings[i+1].isStatic();
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, i + 1, flowInfo);
      }
    }
    lastFieldBinding = this.otherBindings[otherBindingsCount-1];
  }

  if (isCompound) {
    if (otherBindingsCount == 0
        && lastFieldBinding.isBlankFinal()
        && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
      FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass, flowInfo);
      if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
        currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
      }
    }
    manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, otherBindingsCount, flowInfo);
  }
View Full Code Here

      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
        // check if reading a final blank field
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
          FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
          if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
            currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
          }
        }
      }
      break;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.flow.FlowInfo

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.