Search in sources :

Example 1 with RenameFix

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

the class NonSerializableObjectPassedToObjectStream method foo.

public void foo() throws IOException {
    final ObjectOutputStream stream = new ObjectOutputStream(null);
    stream.writeObject(new Integer(3));
    stream.writeObject(new RenameFix());
}
Also used : RenameFix(com.siyeh.ig.fixes.RenameFix) ObjectOutputStream(java.io.ObjectOutputStream)

Example 2 with RenameFix

use of com.siyeh.ig.fixes.RenameFix 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 3 with RenameFix

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

the class ClassNameDiffersFromFileNameInspection method buildFix.

@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos) {
    final PsiJavaFile file = (PsiJavaFile) infos[0];
    final String fileName = file.getName();
    final int prefixIndex = fileName.indexOf((int) '.');
    final String filenameWithoutPrefix = fileName.substring(0, prefixIndex);
    final PsiClass[] classes = file.getClasses();
    for (PsiClass psiClass : classes) {
        final String className = psiClass.getName();
        if (filenameWithoutPrefix.equals(className)) {
            return null;
        }
    }
    return new RenameFix(filenameWithoutPrefix);
}
Also used : RenameFix(com.siyeh.ig.fixes.RenameFix) PsiClass(com.intellij.psi.PsiClass) PsiJavaFile(com.intellij.psi.PsiJavaFile) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with RenameFix

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

the class NonBooleanMethodNameMayNotStartWithQuestionInspection method buildFixes.

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

Aggregations

RenameFix (com.siyeh.ig.fixes.RenameFix)4 PsiElement (com.intellij.psi.PsiElement)2 InspectionGadgetsFix (com.siyeh.ig.InspectionGadgetsFix)2 NotNull (org.jetbrains.annotations.NotNull)2 PsiClass (com.intellij.psi.PsiClass)1 PsiJavaFile (com.intellij.psi.PsiJavaFile)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Nullable (org.jetbrains.annotations.Nullable)1