本文整理汇总了Java中com.intellij.codeInsight.NullableNotNullManager.getNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java NullableNotNullManager.getNotNull方法的具体用法?Java NullableNotNullManager.getNotNull怎么用?Java NullableNotNullManager.getNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.NullableNotNullManager
的用法示例。
在下文中一共展示了NullableNotNullManager.getNotNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: 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), "???"));
}
示例3: 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), "???"));
}
示例4: annotateWithNullableStuff
import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private static void annotateWithNullableStuff(final PsiModifierListOwner field, final PsiElementFactory factory, final PsiModifierListOwner listOwner)
throws IncorrectOperationException {
final NullableNotNullManager manager = NullableNotNullManager.getInstance(field.getProject());
final String notNull = manager.getNotNull(field);
if (notNull != null) {
annotate(factory, listOwner, notNull);
}
else {
final String nullable = manager.getNullable(field);
if (nullable != null) {
annotate(factory, listOwner, nullable);
}
}
}
示例5: delegateMethod
import com.intellij.codeInsight.NullableNotNullManager; //导入方法依赖的package包/类
private PsiMethod delegateMethod(@NonNls String delegationTarget,
PsiMethod method,
PsiSubstitutor substitutor) throws IncorrectOperationException {
substitutor = OverrideImplementUtil.correctSubstitutor(method, substitutor);
PsiMethod methodToAdd = GenerateMembersUtil.substituteGenericMethod(method, substitutor);
final PsiModifierList modifierList = methodToAdd.getModifierList();
final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
modifierList.setModifierProperty(PsiModifier.ABSTRACT, false);
final String nullable = manager.getNullable(method);
if (nullable != null) {
modifierList.addAfter(myFactory.createAnnotationFromText("@" + nullable, methodToAdd), null);
}
else {
final String notNull = manager.getNotNull(method);
if (notNull != null) {
modifierList.addAfter(myFactory.createAnnotationFromText("@" + notNull, methodToAdd), null);
}
}
final String delegationBody = getDelegationBody(methodToAdd, delegationTarget);
PsiCodeBlock newBody = myFactory.createCodeBlockFromText(delegationBody, method);
PsiCodeBlock oldBody = methodToAdd.getBody();
if (oldBody != null) {
oldBody.replace(newBody);
}
else {
methodToAdd.addBefore(newBody, null);
}
if (methodToAdd.getDocComment() != null) methodToAdd.getDocComment().delete();
methodToAdd = (PsiMethod)CodeStyleManager.getInstance(myProject).reformat(methodToAdd);
methodToAdd = (PsiMethod)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(methodToAdd);
return methodToAdd;
}