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


Java NullableNotNullManager.getInstance方法代码示例

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


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

示例1: checkNullableStuffForMethod

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private void checkNullableStuffForMethod(PsiMethod method, final ProblemsHolder holder) {
  Annotated annotated = check(method, holder, method.getReturnType());

  List<PsiMethod> superMethods = ContainerUtil.map(
    method.findSuperMethodSignaturesIncludingStatic(true), new Function<MethodSignatureBackedByPsiMethod, PsiMethod>() {
      @Override
      public PsiMethod fun(MethodSignatureBackedByPsiMethod signature) {
        return signature.getMethod();
      }
    });

  final NullableNotNullManager nullableManager = NullableNotNullManager.getInstance(holder.getProject());

  checkSupers(method, holder, annotated, superMethods, nullableManager);
  checkParameters(method, holder, superMethods, nullableManager);
  checkOverriders(method, holder, annotated, nullableManager);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:NullableStuffInspectionBase.java

示例2: annotateWithNullableStuff

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static void annotateWithNullableStuff(final PsiModifierListOwner field, final PsiModifierListOwner listOwner)
  throws IncorrectOperationException {
  final NullableNotNullManager manager = NullableNotNullManager.getInstance(field.getProject());
  final PsiAnnotation notNull = manager.copyNotNullAnnotation(field);
  if (notNull != null) {
    annotate(listOwner, notNull);
  }
  else {
    final PsiAnnotation nullable = manager.copyNullableAnnotation(field);
    if (nullable != null) {
      annotate(listOwner, nullable);
    }
  }

  final PsiModifierList modifierList = listOwner.getModifierList();
  if (modifierList.hasExplicitModifier(GrModifier.DEF)) {
    LOG.assertTrue(modifierList instanceof GrModifierList);
    if (modifierList.getAnnotations().length > 0 || ((GrModifierList)modifierList).getModifiers().length > 1) {
      ((GrModifierList)modifierList).setModifierProperty(GrModifier.DEF, false);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyPropertyUtils.java

示例3: testOverrideCustomDefault

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
public void testOverrideCustomDefault() {
  DataFlowInspectionTest.addJavaxNullabilityAnnotations(myFixture);
  myFixture.addClass("package custom;" +
                     "public @interface CheckForNull {}");

  final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject());
  nnnManager.setNullables("custom.CheckForNull");
  Disposer.register(myTestRootDisposable, new Disposable() {
    @Override
    public void dispose() {
      nnnManager.setNullables();
    }
  });

  myFixture.addClass("package foo;" +
                     "import static java.lang.annotation.ElementType.*;" +
                     "@javax.annotation.meta.TypeQualifierDefault(METHOD) " +
                     "@javax.annotation.Nonnull " +
                     "public @interface ReturnValuesAreNonnullByDefault {}");

  myFixture.addFileToProject("foo/package-info.java", "@ReturnValuesAreNonnullByDefault package foo;");

  myFixture.configureFromExistingVirtualFile(myFixture.copyFileToProject(getTestName(false) + ".java", "foo/Classes.java"));
  myFixture.enableInspections(myInspection);
  myFixture.checkHighlighting(true, false, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:NullableStuffInspectionTest.java

示例4: buildFix

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos) {
  final PsiElement elt = (PsiElement)infos[0];
  if (!AnnotationUtil.isAnnotatingApplicable(elt)) {
    return null;
  }

  if (PsiTreeUtil.getParentOfType(elt, PsiMethod.class, PsiLambdaExpression.class) instanceof PsiLambdaExpression) {
    return null;
  }

  final NullableNotNullManager manager = NullableNotNullManager.getInstance(elt.getProject());
  return new DelegatingFix(new AnnotateMethodFix(
    manager.getDefaultNullable(),
    ArrayUtil.toStringArray(manager.getNotNulls())){
    @Override
    public int shouldAnnotateBaseMethod(PsiMethod method, PsiMethod superMethod, Project project) {
      return ReturnNullInspectionBase.this.shouldAnnotateBaseMethod(method, superMethod);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReturnNullInspectionBase.java

示例5: buildFix

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos) {
  final PsiElement elt = (PsiElement)infos[0];
  if (!AnnotationUtil.isAnnotatingApplicable(elt)) {
    return null;
  }
  final NullableNotNullManager manager =
    NullableNotNullManager.getInstance(elt.getProject());
  return new DelegatingFix(new AnnotateMethodFix(
    manager.getDefaultNullable(),
    ArrayUtil.toStringArray(manager.getNotNulls())){
    @Override
    public int shouldAnnotateBaseMethod(PsiMethod method, PsiMethod superMethod, Project project) {
      return ReturnNullInspectionBase.this.shouldAnnotateBaseMethod(method, superMethod);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ReturnNullInspectionBase.java

示例6: annotateWithNullableStuff

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static void annotateWithNullableStuff(final PsiModifierListOwner field, final PsiModifierListOwner listOwner)
  throws IncorrectOperationException {
  final NullableNotNullManager manager = NullableNotNullManager.getInstance(field.getProject());
  final String notNull = manager.getNotNull(field);
  if (notNull != null) {
    annotate(listOwner, notNull);
  }
  else {
    final String nullable = manager.getNullable(field);
    if (nullable != null) {
      annotate(listOwner, nullable);
    }
  }

  final PsiModifierList modifierList = listOwner.getModifierList();
  if (modifierList.hasExplicitModifier(GrModifier.DEF)) {
    LOG.assertTrue(modifierList instanceof GrModifierList);
    if (modifierList.getAnnotations().length > 0 || ((GrModifierList)modifierList).getModifiers().length > 1) {
      ((GrModifierList)modifierList).setModifierProperty(GrModifier.DEF, false);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:GroovyPropertyUtils.java

示例7: getTypeOwnNullability

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
private static Nullness getTypeOwnNullability(Ref<Nullness> result, PsiType eachType)
{
	for(PsiAnnotation annotation : eachType.getAnnotations())
	{
		String qualifiedName = annotation.getQualifiedName();
		NullableNotNullManager nnn = NullableNotNullManager.getInstance(annotation.getProject());
		if(nnn.getNullables().contains(qualifiedName))
		{
			return Nullness.NULLABLE;
		}
		if(nnn.getNotNulls().contains(qualifiedName))
		{
			return Nullness.NOT_NULL;
		}
	}
	return Nullness.UNKNOWN;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:DfaPsiUtil.java

示例8: isNotNullLocally

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static boolean isNotNullLocally(@NotNull PsiModifierListOwner owner, boolean ignoreParameterNullabilityInference)
{
	NullableNotNullManager nnnm = NullableNotNullManager.getInstance(owner.getProject());
	PsiAnnotation notNullAnno = nnnm.getNotNullAnnotation(owner, true);
	if(notNullAnno == null || ignoreParameterNullabilityInference && owner instanceof PsiParameter && AnnotationUtil.isInferredAnnotation(notNullAnno))
	{
		return false;
	}

	if(!(owner instanceof PsiParameter))
	{
		return true; // notnull on a super method requires all inheritors to return notnull as well
	}

	// @NotNull on a super parameter doesn't prohibit calling the inheritors with null args, if they're ready for that.
	// so treat parameters as @NotNull only if they're annotated explicitly, or if they're in a scope of some nullity default annotation.
	return isOwnAnnotation(owner, notNullAnno) || nnnm.isContainerAnnotation(notNullAnno);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:DfaPsiUtil.java

示例9: getPresentableAnnoName

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
private static String getPresentableAnnoName(@NotNull PsiModifierListOwner owner)
{
	NullableNotNullManager manager = NullableNotNullManager.getInstance(owner.getProject());
	Set<String> names = ContainerUtil.newHashSet(manager.getNullables());
	names.addAll(manager.getNotNulls());

	PsiAnnotation annotation = AnnotationUtil.findAnnotationInHierarchy(owner, names);
	if(annotation != null)
	{
		return getPresentableAnnoName(annotation);
	}

	String anno = manager.getNotNull(owner);
	return StringUtil.getShortName(anno != null ? anno : StringUtil.notNullize(manager.getNullable(owner), "???"));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:NullableStuffInspectionBase.java

示例10: 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

示例11: isNullableNotInferred

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

	PsiAnnotation anno = manager.getNullableAnnotation(owner, checkBases);
	return !(anno != null && AnnotationUtil.isInferredAnnotation(anno));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:NullableStuffInspectionBase.java

示例12: initNullness

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private Nullness initNullness()
{
	if(!PsiUtil.isLanguageLevel5OrHigher(myElements[0]) || PsiUtil.resolveClassInType(myReturnType) == null)
	{
		return null;
	}
	final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
	final PsiClass nullableAnnotationClass = JavaPsiFacade.getInstance(myProject).findClass(manager.getDefaultNullable(), myElements[0].getResolveScope());
	if(nullableAnnotationClass != null)
	{
		final PsiElement elementInCopy = myTargetClass.getContainingFile().copy().findElementAt(myTargetClass.getTextOffset());
		final PsiClass classCopy = PsiTreeUtil.getParentOfType(elementInCopy, PsiClass.class);
		if(classCopy == null)
		{
			return null;
		}
		final PsiMethod emptyMethod = (PsiMethod) classCopy.addAfter(generateEmptyMethod("name"), classCopy.getLBrace());
		prepareMethodBody(emptyMethod, false);
		if(myNotNullConditionalCheck || myNullConditionalCheck)
		{
			return Nullness.NULLABLE;
		}
		return DfaUtil.inferMethodNullity(emptyMethod);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:ExtractMethodProcessor.java

示例13: annotateWithNullableStuff

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
public static void annotateWithNullableStuff(@NotNull PsiModifierListOwner field,
                                             @NotNull PsiModifierListOwner listOwner)
  throws IncorrectOperationException {
  final NullableNotNullManager manager = NullableNotNullManager.getInstance(field.getProject());
  final PsiAnnotation notNull = manager.copyNotNullAnnotation(field);
  if (notNull != null) {
    annotate(listOwner, notNull);
  }
  else {
    final PsiAnnotation nullable = manager.copyNullableAnnotation(field);
    if (nullable != null) {
      annotate(listOwner, nullable);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PropertyUtil.java

示例14: 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

示例15: getPresentableAnnoName

import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
@NotNull
private static String getPresentableAnnoName(@NotNull PsiModifierListOwner owner) {
  NullableNotNullManager manager = NullableNotNullManager.getInstance(owner.getProject());
  Set<String> names = ContainerUtil.newHashSet(manager.getNullables());
  names.addAll(manager.getNotNulls());

  PsiAnnotation annotation = AnnotationUtil.findAnnotationInHierarchy(owner, names);
  if (annotation != null) return getPresentableAnnoName(annotation);
  
  String anno = manager.getNotNull(owner);
  return StringUtil.getShortName(anno != null ? anno : StringUtil.notNullize(manager.getNullable(owner), "???"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:NullableStuffInspectionBase.java


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