本文整理汇总了Java中com.intellij.codeInsight.AnnotationUtil.isInferredAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtil.isInferredAnnotation方法的具体用法?Java AnnotationUtil.isInferredAnnotation怎么用?Java AnnotationUtil.isInferredAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.AnnotationUtil
的用法示例。
在下文中一共展示了AnnotationUtil.isInferredAnnotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotateOnOverrideImplement
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的package包/类
public static void annotateOnOverrideImplement(PsiMethod method, PsiClass targetClass, PsiMethod overridden, boolean insertOverride) {
if (insertOverride && canInsertOverride(overridden, targetClass)) {
final String overrideAnnotationName = Override.class.getName();
if (!AnnotationUtil.isAnnotated(method, overrideAnnotationName, false, true)) {
AddAnnotationPsiFix.addPhysicalAnnotation(overrideAnnotationName, PsiNameValuePair.EMPTY_ARRAY, method.getModifierList());
}
}
final Module module = ModuleUtilCore.findModuleForPsiElement(targetClass);
final GlobalSearchScope moduleScope = module != null ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) : null;
final Project project = targetClass.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
for (OverrideImplementsAnnotationsHandler each : Extensions.getExtensions(OverrideImplementsAnnotationsHandler.EP_NAME)) {
for (String annotation : each.getAnnotations(project)) {
if (moduleScope != null && facade.findClass(annotation, moduleScope) == null) continue;
if (AnnotationUtil.isAnnotated(overridden, annotation, false, false) && !AnnotationUtil.isAnnotated(method, annotation, false, false)) {
PsiAnnotation psiAnnotation = AnnotationUtil.findAnnotation(overridden, annotation);
if (psiAnnotation != null && AnnotationUtil.isInferredAnnotation(psiAnnotation)) {
continue;
}
AddAnnotationPsiFix.removePhysicalAnnotations(method, each.annotationsToRemove(project, annotation));
AddAnnotationPsiFix.addPhysicalAnnotation(annotation, PsiNameValuePair.EMPTY_ARRAY, method.getModifierList());
}
}
}
}
示例2: isNotNullNotInferred
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的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;
}
示例3: isNullableNotInferred
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的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;
PsiAnnotation anno = manager.getNullableAnnotation(owner, checkBases);
return !(anno != null && AnnotationUtil.isInferredAnnotation(anno));
}
示例4: removePhysicalAnnotations
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的package包/类
public static void removePhysicalAnnotations(PsiModifierListOwner owner, String... fqns) {
for (String fqn : fqns) {
PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, fqn);
if (annotation != null && !AnnotationUtil.isInferredAnnotation(annotation)) {
annotation.delete();
}
}
}
示例5: isAnnotatedSkipInferred
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的package包/类
private static boolean isAnnotatedSkipInferred(PsiModifierListOwner owner, String... annoFqns) {
PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, false, annoFqns);
return annotation != null && !AnnotationUtil.isInferredAnnotation(annotation);
}
示例6: checkContract
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的package包/类
private static void checkContract(MultiMap<PsiElement, String> conflictDescriptions, PsiMethod method) {
PsiAnnotation contract = ControlFlowAnalyzer.findContractAnnotation(method);
if (contract != null && !AnnotationUtil.isInferredAnnotation(contract)) {
conflictDescriptions.putValue(method, "@Contract annotation will have to be changed manually");
}
}
示例7: visitExpressionStatement
import com.intellij.codeInsight.AnnotationUtil; //导入方法依赖的package包/类
@Override
public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
super.visitExpressionStatement(statement);
final PsiExpression expression = statement.getExpression();
if (!(expression instanceof PsiMethodCallExpression)) {
return;
}
final PsiMethodCallExpression call = (PsiMethodCallExpression)expression;
final PsiMethod method = call.resolveMethod();
if (method == null || method.isConstructor()) {
return;
}
final PsiType returnType = method.getReturnType();
if (PsiType.VOID.equals(returnType)) {
return;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
if (PsiUtilCore.hasErrorElementChild(statement)) {
return;
}
if (m_reportAllNonLibraryCalls && !LibraryUtil.classIsInLibrary(aClass)) {
registerMethodCallError(call, aClass);
return;
}
PsiAnnotation anno = ControlFlowAnalyzer.findContractAnnotation(method);
boolean honorInferred = Registry.is("ide.ignore.call.result.inspection.honor.inferred.pure");
if (anno != null &&
(honorInferred || !AnnotationUtil.isInferredAnnotation(anno)) &&
Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(anno, "pure"))) {
registerMethodCallError(call, aClass);
return;
}
final PsiReferenceExpression methodExpression = call.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (methodName == null) {
return;
}
for (int i = 0; i < methodNamePatterns.size(); i++) {
final String methodNamePattern = methodNamePatterns.get(i);
if (!methodNamesMatch(methodName, methodNamePattern)) {
continue;
}
final String className = classNames.get(i);
if (!InheritanceUtil.isInheritor(aClass, className)) {
continue;
}
registerMethodCallError(call, aClass);
return;
}
}