当前位置: 首页>>代码示例>>Java>>正文


Java DfaTypeValue类代码示例

本文整理汇总了Java中com.intellij.codeInspection.dataFlow.value.DfaTypeValue的典型用法代码示例。如果您正苦于以下问题:Java DfaTypeValue类的具体用法?Java DfaTypeValue怎么用?Java DfaTypeValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DfaTypeValue类属于com.intellij.codeInspection.dataFlow.value包,在下文中一共展示了DfaTypeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: withInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Nullable
public DfaVariableState withInstanceofValue(DfaTypeValue dfaType) {
  if (dfaType.getDfaType().getPsiType() instanceof PsiPrimitiveType) return this;

  if (checkInstanceofValue(dfaType.getDfaType())) {
    DfaVariableState result = dfaType.isNullable() ? withNullability(Nullness.NULLABLE) : this;
    List<DfaPsiType> moreGeneric = ContainerUtil.newArrayList();
    for (DfaPsiType alreadyInstanceof : myInstanceofValues) {
      if (dfaType.getDfaType().isAssignableFrom(alreadyInstanceof)) {
        return result;
      }
      if (alreadyInstanceof.isAssignableFrom(dfaType.getDfaType())) {
        moreGeneric.add(alreadyInstanceof);
      }
    }

    HashSet<DfaPsiType> newInstanceof = ContainerUtil.newHashSet(myInstanceofValues);
    newInstanceof.removeAll(moreGeneric);
    newInstanceof.add(dfaType.getDfaType());
    result = createCopy(newInstanceof, myNotInstanceofValues, result.myNullability);
    return result;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DfaVariableState.java

示例2: withNotInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Nullable
public DfaVariableState withNotInstanceofValue(DfaTypeValue dfaType) {
  if (myNotInstanceofValues.contains(dfaType.getDfaType())) return this;

  for (DfaPsiType dfaTypeValue : myInstanceofValues) {
    if (dfaType.getDfaType().isAssignableFrom(dfaTypeValue)) return null;
  }

  List<DfaPsiType> moreSpecific = ContainerUtil.newArrayList();
  for (DfaPsiType alreadyNotInstanceof : myNotInstanceofValues) {
    if (alreadyNotInstanceof.isAssignableFrom(dfaType.getDfaType())) {
      return this;
    }
    if (dfaType.getDfaType().isAssignableFrom(alreadyNotInstanceof)) {
      moreSpecific.add(alreadyNotInstanceof);
    }
  }

  HashSet<DfaPsiType> newNotInstanceof = ContainerUtil.newHashSet(myNotInstanceofValues);
  newNotInstanceof.removeAll(moreSpecific);
  newNotInstanceof.add(dfaType.getDfaType());
  return createCopy(myInstanceofValues, newNotInstanceof, myNullability);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DfaVariableState.java

示例3: allCaughtTypes

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@NotNull
private List<DfaTypeValue> allCaughtTypes(PsiParameter param)
{
	List<PsiType> psiTypes;
	PsiType type = param.getType();
	if(type instanceof PsiDisjunctionType)
	{
		psiTypes = ((PsiDisjunctionType) type).getDisjunctions();
	}
	else
	{
		psiTypes = Collections.singletonList(type);
	}
	List<DfaValue> result = psiTypes.stream().map(it -> myRunner.getFactory().createTypeValue(it, Nullness.NOT_NULL)).collect(Collectors.toList());
	return ContainerUtil.<DfaValue, DfaTypeValue>mapNotNull(result, dfaValue -> dfaValue instanceof DfaTypeValue ? (DfaTypeValue) dfaValue : null);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ControlTransferHandler.java

示例4: getDfaReturnValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
/**
 * Returns DfaValue describing the return value of this contract
 *
 * @param factory       factory to create values
 * @param defaultResult default result value for the called method
 * @return a DfaValue describing the return value of this contract
 */
@NotNull
DfaValue getDfaReturnValue(DfaValueFactory factory, DfaValue defaultResult)
{
	switch(getReturnValue())
	{
		case NULL_VALUE:
			return factory.getConstFactory().getNull();
		case NOT_NULL_VALUE:
			return defaultResult instanceof DfaTypeValue ? ((DfaTypeValue) defaultResult).withNullness(Nullness.NOT_NULL) : DfaUnknownValue.getInstance();
		case TRUE_VALUE:
			return factory.getConstFactory().getTrue();
		case FALSE_VALUE:
			return factory.getConstFactory().getFalse();
		case THROW_EXCEPTION:
			return factory.getConstFactory().getContractFail();
		default:
			return defaultResult;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:MethodContract.java

示例5: visitTypeCast

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Override
public DfaInstructionState[] visitTypeCast(TypeCastInstruction instruction, DataFlowRunner runner, DfaMemoryState memState)
{
	final DfaValueFactory factory = runner.getFactory();
	DfaValue dfaExpr = factory.createValue(instruction.getCasted());
	if(dfaExpr != null)
	{
		DfaTypeValue dfaType = (DfaTypeValue) factory.createTypeValue(instruction.getCastTo(), Nullness.UNKNOWN);
		DfaRelationValue dfaInstanceof = factory.getRelationFactory().createRelation(dfaExpr, RelationType.IS, dfaType);
		if(dfaInstanceof != null && !memState.applyInstanceofOrNull(dfaInstanceof))
		{
			onInstructionProducesCCE(instruction);
		}
	}

	if(instruction.getCastTo() instanceof PsiPrimitiveType)
	{
		memState.push(runner.getFactory().getBoxedFactory().createUnboxed(memState.pop()));
	}

	return nextInstruction(instruction, runner, memState);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:StandardInstructionVisitor.java

示例6: visitCheckNotNull

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Override
public DfaInstructionState[] visitCheckNotNull(CheckNotNullInstruction instruction, DataFlowRunner runner, DfaMemoryState memState)
{
	if(!checkNotNullable(memState, memState.peek(), instruction.getProblem(), instruction.getExpression()))
	{
		DfaValue arg = memState.peek();
		if(arg instanceof DfaVariableValue)
		{
			DfaVariableValue var = (DfaVariableValue) arg;
			memState.setVarValue(var, runner.getFactory().createTypeValue(var.getVariableType(), Nullness.NOT_NULL));
		}
		else if(arg instanceof DfaTypeValue)
		{
			memState.pop();
			memState.push(((DfaTypeValue) arg).withNullness(Nullness.NOT_NULL));
		}
		else if(memState.isNull(arg) && instruction.getProblem() == NullabilityProblem.nullableFunctionReturn)
		{
			memState.pop();
			memState.push(runner.getFactory().createTypeValue(PsiType.VOID, Nullness.NOT_NULL));
		}
	}
	return super.visitCheckNotNull(instruction, runner, memState);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:StandardInstructionVisitor.java

示例7: handleInstanceof

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
private void handleInstanceof(InstanceofInstruction instruction, DfaValue dfaRight, DfaValue dfaLeft)
{
	if(dfaLeft instanceof DfaTypeValue && dfaRight instanceof DfaTypeValue)
	{
		if(!((DfaTypeValue) dfaLeft).isNotNull())
		{
			myCanBeNullInInstanceof.add(instruction);
		}

		if(((DfaTypeValue) dfaRight).getDfaType().isAssignableFrom(((DfaTypeValue) dfaLeft).getDfaType()))
		{
			return;
		}
	}
	myUsefulInstanceofs.add(instruction);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:StandardInstructionVisitor.java

示例8: fromDfaValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Nullable
@Override
Boolean fromDfaValue(DfaValue value)
{
	if(value instanceof DfaConstValue)
	{
		return ((DfaConstValue) value).getValue() == null;
	}
	if(value instanceof DfaBoxedValue || value instanceof DfaUnboxedValue || value instanceof DfaRangeValue)
	{
		return false;
	}
	if(value instanceof DfaTypeValue)
	{
		return NullnessUtil.toBoolean(((DfaTypeValue) value).getNullness());
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:DfaFactType.java

示例9: setInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
public boolean setInstanceofValue(DfaTypeValue dfaType) {
  if (dfaType.isNullable()) {
    myNullability = Nullness.NULLABLE;
  }

  if (dfaType.getType() instanceof PsiPrimitiveType) return true;

  if (checkInstanceofValue(dfaType)) {
    myInstanceofValues.add(dfaType);
    return true;
  }

  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:DfaVariableState.java

示例10: addNotInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
public boolean addNotInstanceofValue(DfaTypeValue dfaType) {
  if (myNotInstanceofValues.contains(dfaType)) return true;

  for (DfaTypeValue dfaTypeValue : myInstanceofValues) {
    if (dfaType.isAssignableFrom(dfaTypeValue)) return false;
  }

  myNotInstanceofValues.add(dfaType);
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:DfaVariableState.java

示例11: processCatches

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@NotNull
private List<DfaInstructionState> processCatches(Trap.TryCatch tryCatch, DfaValue thrownValue, FList<Trap> traps)
{
	List<DfaInstructionState> result = new ArrayList<>();
	for(Map.Entry<PsiCatchSection, ControlFlow.ControlFlowOffset> entry : tryCatch.getClauses().entrySet())
	{
		PsiCatchSection catchSection = entry.getKey();
		ControlFlow.ControlFlowOffset jumpOffset = entry.getValue();

		PsiParameter param = catchSection.getParameter();
		if(param == null)
		{
			continue;
		}

		if(throwableState == null)
		{
			throwableState = initVariableState(param, thrownValue);
		}

		for(DfaTypeValue caughtType : allCaughtTypes(param))
		{
			DfaVariableState varState = throwableState.withInstanceofValue(caughtType);
			if(varState != null)
			{
				result.add(new DfaInstructionState(myRunner.getInstruction(jumpOffset.getInstructionOffset()), stateForCatchClause(param, varState)));
			}

			throwableState = throwableState.withNotInstanceofValue(caughtType);

			if(throwableState == null)
			{
				return result;
			}
		}
	}
	return ContainerUtil.concat(result, iteration(traps));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:39,代码来源:ControlTransferHandler.java

示例12: initVariableState

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@NotNull
private DfaVariableState initVariableState(PsiParameter param, DfaValue throwable)
{
	DfaVariableValue sampleVar = ((DfaMemoryStateImpl) myState).getFactory().getVarFactory().createVariableValue(param, false);
	DfaVariableState varState = ((DfaMemoryStateImpl) myState).createVariableState(sampleVar).withFact(DfaFactType.CAN_BE_NULL, false);
	if(throwable instanceof DfaTypeValue)
	{
		return Objects.requireNonNull(varState.withInstanceofValue((DfaTypeValue) throwable));
	}
	else
	{
		return varState;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:ControlTransferHandler.java

示例13: withInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Nullable
DfaVariableState withInstanceofValue(@NotNull DfaTypeValue dfaType)
{
	if(dfaType.getDfaType().getPsiType() instanceof PsiPrimitiveType)
	{
		return this;
	}

	if(checkInstanceofValue(dfaType.getDfaType()))
	{
		DfaVariableState result = dfaType.isNullable() ? withFact(DfaFactType.CAN_BE_NULL, true) : this;
		List<DfaPsiType> moreGeneric = ContainerUtil.newArrayList();
		for(DfaPsiType alreadyInstanceof : myInstanceofValues)
		{
			if(dfaType.getDfaType().isAssignableFrom(alreadyInstanceof))
			{
				return result;
			}
			if(alreadyInstanceof.isAssignableFrom(dfaType.getDfaType()))
			{
				moreGeneric.add(alreadyInstanceof);
			}
		}

		HashSet<DfaPsiType> newInstanceof = ContainerUtil.newHashSet(myInstanceofValues);
		newInstanceof.removeAll(moreGeneric);
		newInstanceof.add(dfaType.getDfaType());
		result = createCopy(newInstanceof, myNotInstanceofValues, result.myFactMap);
		return result;
	}

	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:DfaVariableState.java

示例14: withNotInstanceofValue

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
@Nullable
DfaVariableState withNotInstanceofValue(@NotNull DfaTypeValue dfaType)
{
	if(myNotInstanceofValues.contains(dfaType.getDfaType()))
	{
		return this;
	}

	for(DfaPsiType dfaTypeValue : myInstanceofValues)
	{
		if(dfaType.getDfaType().isAssignableFrom(dfaTypeValue))
		{
			return null;
		}
	}

	List<DfaPsiType> moreSpecific = ContainerUtil.newArrayList();
	for(DfaPsiType alreadyNotInstanceof : myNotInstanceofValues)
	{
		if(alreadyNotInstanceof.isAssignableFrom(dfaType.getDfaType()))
		{
			return this;
		}
		if(dfaType.getDfaType().isAssignableFrom(alreadyNotInstanceof))
		{
			moreSpecific.add(alreadyNotInstanceof);
		}
	}

	HashSet<DfaPsiType> newNotInstanceof = ContainerUtil.newHashSet(myNotInstanceofValues);
	newNotInstanceof.removeAll(moreSpecific);
	newNotInstanceof.add(dfaType.getDfaType());
	return createCopy(myInstanceofValues, newNotInstanceof, myFactMap);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:35,代码来源:DfaVariableState.java

示例15: DfaVariableState

import com.intellij.codeInspection.dataFlow.value.DfaTypeValue; //导入依赖的package包/类
public DfaVariableState(@NotNull DfaVariableValue dfaVar) {
  myInstanceofValues = new HashSet<DfaTypeValue>();
  myNotInstanceofValues = new HashSet<DfaTypeValue>();

  myNullability = dfaVar.getInherentNullability();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:DfaVariableState.java


注:本文中的com.intellij.codeInspection.dataFlow.value.DfaTypeValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。