示例#1
0
 private DfaValue handleFlush(DfaVariableValue flushed, DfaValue value) {
   if (value instanceof DfaVariableValue
       && (value == flushed
           || myFactory.getVarFactory().getAllQualifiedBy(flushed).contains(value))) {
     Nullness nullability =
         isNotNull(value)
             ? Nullness.NOT_NULL
             : ((DfaVariableValue) value).getInherentNullability();
     return myFactory.createTypeValue(((DfaVariableValue) value).getVariableType(), nullability);
   }
   return value;
 }
示例#2
0
  @Override
  public void flushVariable(@NotNull final DfaVariableValue variable) {
    List<DfaValue> updatedStack = ContainerUtil.map(myStack, value -> handleFlush(variable, value));
    myStack.clear();
    for (DfaValue value : updatedStack) {
      myStack.push(value);
    }

    doFlush(variable, false);
    flushDependencies(variable);
    myUnknownVariables.remove(variable);
    myUnknownVariables.removeAll(myFactory.getVarFactory().getAllQualifiedBy(variable));
    myCachedHash = null;
  }
  @Override
  public DfaInstructionState[] visitAssign(
      AssignInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
    DfaValue dfaSource = memState.pop();
    DfaValue dfaDest = memState.pop();

    if (dfaDest instanceof DfaVariableValue) {
      DfaVariableValue var = (DfaVariableValue) dfaDest;

      DfaValueFactory factory = runner.getFactory();
      if (dfaSource instanceof DfaVariableValue
          && factory.getVarFactory().getAllQualifiedBy(var).contains(dfaSource)) {
        Nullness nullability =
            memState.isNotNull(dfaSource)
                ? Nullness.NOT_NULL
                : ((DfaVariableValue) dfaSource).getInherentNullability();
        dfaSource =
            factory.createTypeValue(((DfaVariableValue) dfaSource).getVariableType(), nullability);
      }

      if (var.getInherentNullability() == Nullness.NOT_NULL) {
        checkNotNullable(
            memState,
            dfaSource,
            NullabilityProblem.assigningToNotNull,
            instruction.getRExpression());
      }
      final PsiModifierListOwner psi = var.getPsiVariable();
      if (!(psi instanceof PsiField) || !psi.hasModifierProperty(PsiModifier.VOLATILE)) {
        memState.setVarValue(var, dfaSource);
      }
    } else if (dfaDest instanceof DfaTypeValue && ((DfaTypeValue) dfaDest).isNotNull()) {
      checkNotNullable(
          memState, dfaSource, NullabilityProblem.assigningToNotNull, instruction.getRExpression());
    }

    memState.push(dfaDest);

    return nextInstruction(instruction, runner, memState);
  }
示例#4
0
 void flushDependencies(@NotNull DfaVariableValue variable) {
   for (DfaVariableValue dependent : myFactory.getVarFactory().getAllQualifiedBy(variable)) {
     doFlush(dependent, false);
   }
 }