use of com.siyeh.ig.DelegatingFix in project intellij-community by JetBrains.
the class NullArgumentToVariableArgMethodInspection method buildFixes.
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
final PsiExpression argument = (PsiExpression) infos[0];
final PsiType type1 = (PsiType) infos[1];
final PsiType type2 = (PsiType) infos[2];
return new InspectionGadgetsFix[] { new DelegatingFix(new AddTypeCastFix(type1, argument)), new DelegatingFix(new AddTypeCastFix(type2, argument)) };
}
use of com.siyeh.ig.DelegatingFix in project intellij-community by JetBrains.
the class CallToSuspiciousStringMethodInspection method buildFixes.
@Override
@NotNull
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression) infos[0];
final List<InspectionGadgetsFix> result = new ArrayList<>();
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
final PsiModifierListOwner annotatableQualifier = NonNlsUtils.getAnnotatableQualifier(methodExpression);
if (annotatableQualifier != null) {
final InspectionGadgetsFix fix = new DelegatingFix(new AddAnnotationPsiFix(AnnotationUtil.NON_NLS, annotatableQualifier, PsiNameValuePair.EMPTY_ARRAY));
result.add(fix);
}
final PsiModifierListOwner annotatableArgument = NonNlsUtils.getAnnotatableArgument(methodCallExpression);
if (annotatableArgument != null) {
final InspectionGadgetsFix fix = new DelegatingFix(new AddAnnotationPsiFix(AnnotationUtil.NON_NLS, annotatableArgument, PsiNameValuePair.EMPTY_ARRAY));
result.add(fix);
}
return result.toArray(new InspectionGadgetsFix[result.size()]);
}
use of com.siyeh.ig.DelegatingFix in project intellij-community by JetBrains.
the class StringToUpperWithoutLocaleInspection method buildFix.
@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiReferenceExpression methodExpression = (PsiReferenceExpression) infos[0];
final PsiModifierListOwner annotatableQualifier = NonNlsUtils.getAnnotatableQualifier(methodExpression);
if (annotatableQualifier == null) {
return null;
}
return new DelegatingFix(new AddAnnotationPsiFix(AnnotationUtil.NON_NLS, annotatableQualifier, PsiNameValuePair.EMPTY_ARRAY));
}
use of com.siyeh.ig.DelegatingFix in project intellij-community by JetBrains.
the class PrimitiveArrayArgumentToVariableArgMethodInspection method buildFix.
@Nullable
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiExpression argument = (PsiExpression) infos[0];
final PsiType type = (PsiType) infos[1];
return new DelegatingFix(new AddTypeCastFix(type, argument));
}
use of com.siyeh.ig.DelegatingFix 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));
}
Aggregations