Search in sources :

Example 1 with InspectionGadgetsFix

use of com.siyeh.ig.InspectionGadgetsFix 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)) };
}
Also used : DelegatingFix(com.siyeh.ig.DelegatingFix) AddTypeCastFix(com.intellij.codeInsight.daemon.impl.quickfix.AddTypeCastFix) InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with InspectionGadgetsFix

use of com.siyeh.ig.InspectionGadgetsFix 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()]);
}
Also used : AddAnnotationPsiFix(com.intellij.codeInsight.intention.AddAnnotationPsiFix) DelegatingFix(com.siyeh.ig.DelegatingFix) ArrayList(java.util.ArrayList) InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with InspectionGadgetsFix

use of com.siyeh.ig.InspectionGadgetsFix in project intellij-community by JetBrains.

the class UnusedCatchParameterInspection method buildFixes.

@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
    final boolean namedIgnoreButUsed = ((Boolean) infos[0]).booleanValue();
    final PsiElement context = (PsiElement) infos[1];
    final InspectionGadgetsFix fix = SuppressForTestsScopeFix.build(this, context);
    if (namedIgnoreButUsed) {
        if (fix == null) {
            return InspectionGadgetsFix.EMPTY_ARRAY;
        }
        return new InspectionGadgetsFix[] { fix };
    }
    final RenameFix renameFix = new RenameFix("ignored", false, false);
    if (fix == null) {
        return new InspectionGadgetsFix[] { renameFix };
    }
    return new InspectionGadgetsFix[] { renameFix, fix };
}
Also used : RenameFix(com.siyeh.ig.fixes.RenameFix) InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with InspectionGadgetsFix

use of com.siyeh.ig.InspectionGadgetsFix in project intellij-community by JetBrains.

the class MagicNumberInspection method buildFixes.

@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
    final PsiElement context = (PsiElement) infos[0];
    final InspectionGadgetsFix fix = SuppressForTestsScopeFix.build(this, context);
    if (fix == null) {
        return new InspectionGadgetsFix[] { new IntroduceConstantFix() };
    }
    return new InspectionGadgetsFix[] { new IntroduceConstantFix(), fix };
}
Also used : InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) PsiElement(com.intellij.psi.PsiElement) IntroduceConstantFix(com.siyeh.ig.fixes.IntroduceConstantFix) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with InspectionGadgetsFix

use of com.siyeh.ig.InspectionGadgetsFix in project intellij-community by JetBrains.

the class EmptyCatchBlockInspection method buildFixes.

@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
    final PsiElement context = (PsiElement) infos[0];
    final SuppressForTestsScopeFix fix = SuppressForTestsScopeFix.build(this, context);
    if (fix == null) {
        return new InspectionGadgetsFix[] { buildFix(infos) };
    }
    return new InspectionGadgetsFix[] { buildFix(infos), fix };
}
Also used : InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) SuppressForTestsScopeFix(com.siyeh.ig.fixes.SuppressForTestsScopeFix) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

InspectionGadgetsFix (com.siyeh.ig.InspectionGadgetsFix)14 NotNull (org.jetbrains.annotations.NotNull)13 PsiElement (com.intellij.psi.PsiElement)6 ArrayList (java.util.ArrayList)5 SuppressForTestsScopeFix (com.siyeh.ig.fixes.SuppressForTestsScopeFix)4 DelegatingFix (com.siyeh.ig.DelegatingFix)2 RenameFix (com.siyeh.ig.fixes.RenameFix)2 AddTypeCastFix (com.intellij.codeInsight.daemon.impl.quickfix.AddTypeCastFix)1 CreateMethodQuickFix (com.intellij.codeInsight.daemon.impl.quickfix.CreateMethodQuickFix)1 AddAnnotationPsiFix (com.intellij.codeInsight.intention.AddAnnotationPsiFix)1 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 Project (com.intellij.openapi.project.Project)1 PsiField (com.intellij.psi.PsiField)1 PsiPolyadicExpression (com.intellij.psi.PsiPolyadicExpression)1 ChangeSignatureProcessor (com.intellij.refactoring.changeSignature.ChangeSignatureProcessor)1 EncapsulateVariableFix (com.siyeh.ig.fixes.EncapsulateVariableFix)1 IntroduceConstantFix (com.siyeh.ig.fixes.IntroduceConstantFix)1 RemoveModifierFix (com.siyeh.ig.fixes.RemoveModifierFix)1 List (java.util.List)1