use of com.intellij.codeInsight.intention.AddAnnotationPsiFix in project intellij-community by JetBrains.
the class AssignmentToNullInspection method buildFix.
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final Object info = infos[0];
if (!(info instanceof PsiReferenceExpression)) {
return null;
}
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression) info;
if (TypeUtils.isOptional(referenceExpression.getType())) {
return null;
}
final PsiElement target = referenceExpression.resolve();
if (!(target instanceof PsiVariable)) {
return null;
}
final PsiVariable variable = (PsiVariable) target;
if (NullableNotNullManager.isNotNull(variable)) {
return null;
}
final NullableNotNullManager manager = NullableNotNullManager.getInstance(target.getProject());
return new DelegatingFix(new AddAnnotationPsiFix(manager.getDefaultNullable(), variable, PsiNameValuePair.EMPTY_ARRAY));
}
use of com.intellij.codeInsight.intention.AddAnnotationPsiFix in project intellij-community by JetBrains.
the class AnnotateMethodFix method annotateMethod.
private void annotateMethod(@NotNull PsiMethod method) {
AddAnnotationPsiFix fix = new AddAnnotationPsiFix(myAnnotation, method, PsiNameValuePair.EMPTY_ARRAY, myAnnotationsToRemove);
fix.invoke(method.getProject(), method.getContainingFile(), method, method);
}
Aggregations