本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}