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


Java NullableNotNullManager.isNotNull方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.NullableNotNullManager.isNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java NullableNotNullManager.isNotNull方法的具体用法?Java NullableNotNullManager.isNotNull怎么用?Java NullableNotNullManager.isNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.NullableNotNullManager的用法示例。


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

示例1: withConstraint

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@Nullable
private ValueConstraint[] withConstraint(ValueConstraint[] constraints, int index, ValueConstraint constraint) {
  if (constraints[index] == constraint) return constraints;

  ValueConstraint negated = negateConstraint(constraint);
  if (negated != constraint && constraints[index] == negated) {
    return null;
  }

  if (constraint == NULL_VALUE && NullableNotNullManager.isNotNull(getParameter(index))) {
    return null;
  }

  ValueConstraint[] copy = constraints.clone();
  copy[index] = constraint;
  return copy;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ContractInference.java

示例2: createInitialStates

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@Override
protected Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
  final Collection<DfaMemoryState> initialStates = super.createInitialStates(psiBlock, visitor);

  myIsInMethod = psiBlock.getParent() instanceof PsiMethod;
  if (myIsInMethod) {
    PsiMethod method = (PsiMethod)psiBlock.getParent();
    PsiType returnType = method.getReturnType();
    myInNullableMethod = NullableNotNullManager.isNullable(method) ||
                         returnType != null && returnType.equalsToText(CommonClassNames.JAVA_LANG_VOID);
    myInNotNullMethod = NullableNotNullManager.isNotNull(method);
  }

  myNPEInstructions.clear();
  myCCEInstructions.clear();
  myNullableArguments.clear();
  myNullableArgumentsPassedToNonAnnotatedParam.clear();
  myNullableAssignments.clear();
  myNullableReturns.clear();
  myUnboxedNullables.clear();

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

示例3: createInitialStates

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@Override
protected Collection<DfaMemoryState> createInitialStates(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
  final Collection<DfaMemoryState> initialStates = super.createInitialStates(psiBlock, visitor);
  if (initialStates == null) {
    return null;
  }

  final PsiElement parent = psiBlock.getParent();
  if (parent instanceof PsiMethod) {
    PsiMethod method = (PsiMethod)parent;

    //todo move out from generic runner
    for (PsiParameter parameter : method.getParameterList().getParameters()) {
      if (NullableNotNullManager.isNotNull(parameter)) {
        final DfaVariableValue value = getFactory().getVarFactory().createVariableValue(parameter, false);
        for (final DfaMemoryState initialState : initialStates) {
          initialState.applyNotNull(value);
        }
      }
    }
  }
  return initialStates;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:AnnotationsAwareDataFlowRunner.java

示例4: toContracts

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
@Override
public List<StandardMethodContract> toContracts(PsiMethod method, Supplier<PsiCodeBlock> body)
{
	PsiExpression expression = call.restoreExpression(body.get());
	if(!(expression instanceof PsiMethodCallExpression))
	{
		return Collections.emptyList();
	}
	PsiMethod target = ((PsiMethodCallExpression) expression).resolveMethod();
	if(target != null && NullableNotNullManager.isNotNull(target))
	{
		return ContractInferenceInterpreter.toContracts(ContainerUtil.map(states, it -> it.toArray(new MethodContract.ValueConstraint[it.size()])), MethodContract.ValueConstraint.NOT_NULL_VALUE);
	}
	return Collections.emptyList();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:MethodCallContract.java

示例5: isNotNullNotInferred

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean isNotNullNotInferred(@NotNull PsiModifierListOwner owner, boolean checkBases, boolean skipExternal)
{
	Project project = owner.getProject();
	NullableNotNullManager manager = NullableNotNullManager.getInstance(project);
	if(!manager.isNotNull(owner, checkBases))
	{
		return false;
	}
	if(DfaPsiUtil.getTypeNullability(getMemberType(owner)) == Nullness.NOT_NULL)
	{
		return true;
	}

	PsiAnnotation anno = manager.getNotNullAnnotation(owner, checkBases);
	if(anno == null || AnnotationUtil.isInferredAnnotation(anno))
	{
		return false;
	}
	if(skipExternal && AnnotationUtil.isExternalAnnotation(anno))
	{
		return false;
	}
	return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:NullableStuffInspectionBase.java

示例6: isAnnotated

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean isAnnotated(PsiExpression expression, boolean nullable)
{
	expression = ParenthesesUtils.stripParentheses(expression);
	if(!(expression instanceof PsiReferenceExpression))
	{
		return false;
	}
	final PsiReferenceExpression referenceExpression = (PsiReferenceExpression) expression;
	final PsiElement target = referenceExpression.resolve();
	if(!(target instanceof PsiModifierListOwner))
	{
		return false;
	}
	final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner) target;
	return nullable ? NullableNotNullManager.isNullable(modifierListOwner) : NullableNotNullManager.isNotNull(modifierListOwner);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ExpressionUtils.java

示例7: getElementNullability

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
public static Nullness getElementNullability(@Nullable PsiType resultType, @Nullable PsiModifierListOwner owner) {
  if (owner == null) {
    return Nullness.UNKNOWN;
  }

  if (owner instanceof PsiEnumConstant) {
    return Nullness.NOT_NULL;
  }

  if (resultType != null) {
    NullableNotNullManager nnn = NullableNotNullManager.getInstance(owner.getProject());
    for (PsiAnnotation annotation : resultType.getAnnotations()) {
      if (!annotation.isValid()) {
        PsiUtilCore.ensureValid(owner);
        PsiUtil.ensureValidType(resultType, owner + " of " + owner.getClass());
        PsiUtilCore.ensureValid(annotation); //should fail
      }
      String qualifiedName = annotation.getQualifiedName();
      if (nnn.getNullables().contains(qualifiedName)) {
        return Nullness.NULLABLE;
      }
      if (nnn.getNotNulls().contains(qualifiedName)) {
        return Nullness.NOT_NULL;
      }
    }
  }

  if (NullableNotNullManager.isNullable(owner)) {
    return Nullness.NULLABLE;
  }
  if (NullableNotNullManager.isNotNull(owner)) {
    return Nullness.NOT_NULL;
  }

  return Nullness.UNKNOWN;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:DfaPsiUtil.java

示例8: isNotNullNotInferred

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean isNotNullNotInferred(@NotNull PsiModifierListOwner owner, boolean checkBases, boolean skipExternal) {
  Project project = owner.getProject();
  NullableNotNullManager manager = NullableNotNullManager.getInstance(project);
  if (!manager.isNotNull(owner, checkBases)) return false;

  PsiAnnotation anno = manager.getNotNullAnnotation(owner, checkBases);
  if (anno == null || AnnotationUtil.isInferredAnnotation(anno)) return false;
  if (skipExternal && AnnotationUtil.isExternalAnnotation(anno)) return false;
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:NullableStuffInspectionBase.java

示例9: isNotNull

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private boolean isNotNull(PsiModifierListOwner owner) {
  if (NullableNotNullManager.isNotNull(owner)) {
    return true;
  }
  final SmartPsiElementPointer<PsiModifierListOwner> pointer = myPointerManager.createSmartPsiElementPointer(owner);
  return myNotNullSet.contains(pointer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:NullityInferrer.java

示例10: isAnnotated

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean isAnnotated(PsiExpression expression, boolean nullable) {
  expression = ParenthesesUtils.stripParentheses(expression);
  if (!(expression instanceof PsiReferenceExpression)) {
    return false;
  }
  final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)expression;
  final PsiElement target = referenceExpression.resolve();
  if (!(target instanceof PsiModifierListOwner)) {
    return false;
  }
  final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)target;
  return nullable ?
         NullableNotNullManager.isNullable(modifierListOwner):
         NullableNotNullManager.isNotNull(modifierListOwner);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ExpressionUtils.java

示例11: getElementNullability

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
public static Nullness getElementNullability(@Nullable PsiType resultType, @Nullable PsiModifierListOwner owner) {
  if (owner == null) {
    return Nullness.UNKNOWN;
  }

  if (NullableNotNullManager.isNullable(owner)) {
    return Nullness.NULLABLE;
  }
  if (NullableNotNullManager.isNotNull(owner)) {
    return Nullness.NOT_NULL;
  }

  if (resultType != null) {
    NullableNotNullManager nnn = NullableNotNullManager.getInstance(owner.getProject());
    for (PsiAnnotation annotation : resultType.getAnnotations()) {
      String qualifiedName = annotation.getQualifiedName();
      if (nnn.getNullables().contains(qualifiedName)) {
        return Nullness.NULLABLE;
      }
      if (nnn.getNotNulls().contains(qualifiedName)) {
        return Nullness.NOT_NULL;
      }
    }
  }

  return Nullness.UNKNOWN;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:DfaPsiUtil.java

示例12: isNullableInitialized

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
public static boolean isNullableInitialized(PsiVariable var, boolean nullable) {
  if (!isFinalField(var)) {
    return false;
  }

  List<PsiExpression> initializers = findAllConstructorInitializers((PsiField)var);
  if (initializers.isEmpty()) {
    return false;
  }

  for (PsiExpression expression : initializers) {
    if (!(expression instanceof PsiReferenceExpression)) {
      return false;
    }
    PsiElement target = ((PsiReferenceExpression)expression).resolve();
    if (!(target instanceof PsiParameter)) {
      return false;
    }
    if (nullable && NullableNotNullManager.isNullable((PsiParameter)target)) {
      return true;
    }
    if (!nullable && !NullableNotNullManager.isNotNull((PsiParameter)target)) {
      return false;
    }
  }
  return !nullable;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:DfaPsiUtil.java

示例13: hasContradictoryExplicitParameterNullity

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean hasContradictoryExplicitParameterNullity(@NotNull PsiMethod method, StandardMethodContract contract)
{
	for(int i = 0; i < contract.arguments.length; i++)
	{
		if(contract.arguments[i] == NULL_VALUE && NullableNotNullManager.isNotNull(method.getParameterList().getParameters()[i]))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:ContractInference.java

示例14: checkMethodParameters

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
static PsiParameter[] checkMethodParameters(PsiMethod method)
{
	if(method.getBody() == null)
	{
		return PsiParameter.EMPTY_ARRAY;
	}

	final Collection<PsiParameter> nullableParameters = new SmartList<>();
	final PsiParameter[] parameters = method.getParameterList().getParameters();
	for(int index = 0; index < parameters.length; index++)
	{
		PsiParameter parameter = parameters[index];
		if(!(parameter.getType() instanceof PsiPrimitiveType) && !NullableNotNullManager.isNotNull(parameter) && !NullableNotNullManager.isNullable(parameter) && JavaNullMethodArgumentUtil
				.hasNullArgument(method, index))
		{
			nullableParameters.add(parameter);
		}
	}
	if(nullableParameters.isEmpty())
	{
		return PsiParameter.EMPTY_ARRAY;
	}

	final NullParameterConstraintChecker checker = new NullParameterConstraintChecker(nullableParameters);
	checker.analyzeMethod(method.getBody(), new StandardInstructionVisitor());

	return checker.myPossiblyViolatedParameters.stream().filter(checker.myUsedParameters::contains).toArray(PsiParameter[]::new);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:NullParameterConstraintChecker.java

示例15: isNotNullCall

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private boolean isNotNullCall(ExpressionRange delegate, PsiCodeBlock body)
{
	PsiMethodCallExpression call = (PsiMethodCallExpression) delegate.restoreExpression(body);
	if(call.getType() instanceof PsiPrimitiveType)
	{
		return true;
	}
	PsiMethod target = call.resolveMethod();
	return target != null && NullableNotNullManager.isNotNull(target);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:11,代码来源:NullityInferenceResult.java


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