Esempio n. 1
0
 @Override
 public DfaInstructionState[] visitPush(
     PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
   if (myContext == instruction.getPlace()) {
     final Map<DfaVariableValue, DfaVariableState> map =
         ((ValuableDataFlowRunner.MyDfaMemoryState) memState).getVariableStates();
     for (Map.Entry<DfaVariableValue, DfaVariableState> entry : map.entrySet()) {
       ValuableDataFlowRunner.ValuableDfaVariableState state =
           (ValuableDataFlowRunner.ValuableDfaVariableState) entry.getValue();
       DfaVariableValue variableValue = entry.getKey();
       final PsiExpression psiExpression = state.myExpression;
       if (psiExpression != null && variableValue.getQualifier() == null) {
         myValues.put(variableValue.getPsiVariable(), psiExpression);
       }
     }
     DfaValue value = instruction.getValue();
     if (value instanceof DfaVariableValue
         && ((DfaVariableValue) value).getQualifier() == null) {
       if (memState.isNotNull((DfaVariableValue) value)) {
         myNotNulls.add(((DfaVariableValue) value).getPsiVariable());
       }
       if (memState.isNull(value)) {
         myNulls.add(((DfaVariableValue) value).getPsiVariable());
       }
     }
   }
   return super.visitPush(instruction, runner, memState);
 }
 public DfaInstructionState[] visitPush(
     PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
   if (instruction.isFieldReference()) {
     memState.fieldReferenced();
   }
   memState.push(instruction.getValue());
   return nextInstruction(instruction, runner, memState);
 }
 public List<Pair<PsiReferenceExpression, DfaConstValue>> getConstantReferenceValues() {
   List<Pair<PsiReferenceExpression, DfaConstValue>> result = ContainerUtil.newArrayList();
   for (PushInstruction instruction : myPossibleVariableValues.keySet()) {
     Collection<Object> values = myPossibleVariableValues.get(instruction);
     if (values.size() == 1) {
       Object singleValue = values.iterator().next();
       if (singleValue != ANY_VALUE) {
         result.add(
             Pair.create(
                 (PsiReferenceExpression) instruction.getPlace(), (DfaConstValue) singleValue));
       }
     }
   }
   return result;
 }
 @Override
 public DfaInstructionState[] visitPush(
     PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
   if (instruction.isReferenceRead()) {
     DfaValue dfaValue = instruction.getValue();
     if (dfaValue instanceof DfaVariableValue) {
       DfaConstValue constValue = memState.getConstantValue((DfaVariableValue) dfaValue);
       myPossibleVariableValues.putValue(
           instruction,
           constValue != null
                   && (constValue.getValue() == null || constValue.getValue() instanceof Boolean)
               ? constValue
               : ANY_VALUE);
     }
   }
   return super.visitPush(instruction, runner, memState);
 }
 @Override
 public DfaInstructionState[] visitPush(
     PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
   if (myForPlace == instruction.getPlace()) {
     addToResult(((ExpressionTypeMemoryState) memState).getStates());
   }
   return super.visitPush(instruction, runner, memState);
 }