Search in sources :

Example 1 with UnusedDeclarationInspection

use of com.intellij.codeInspection.deadCode.UnusedDeclarationInspection in project intellij-community by JetBrains.

the class JUnitUnusedMethodsTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myFixture.addClass("package org.junit; public @interface Test {}");
    myFixture.addClass("package org.junit.runners; public class Parameterized { public @interface Parameters {} public @interface Parameter {}}");
    myFixture.addClass("package org.junit.runner; public @interface RunWith {Class value();}");
    myFixture.enableInspections(new UnusedDeclarationInspection(true));
}
Also used : UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)

Example 2 with UnusedDeclarationInspection

use of com.intellij.codeInspection.deadCode.UnusedDeclarationInspection in project intellij-community by JetBrains.

the class UnusedMethodParameterTest method doTest.

private void doTest() throws Exception {
    UnusedDeclarationInspection declarationInspection = new UnusedDeclarationInspection();
    declarationInspection.getSharedLocalInspectionTool().LOCAL_VARIABLE = false;
    doTest("unusedMethodParameter/" + getTestName(true), declarationInspection);
}
Also used : UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)

Example 3 with UnusedDeclarationInspection

use of com.intellij.codeInspection.deadCode.UnusedDeclarationInspection in project intellij-community by JetBrains.

the class RedundantSuppressTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myInspectionToolWrappers = new InspectionToolWrapper[] { new LocalInspectionToolWrapper(new JavaDocReferenceInspection()), new LocalInspectionToolWrapper(new I18nInspection()), new LocalInspectionToolWrapper(new RawUseOfParameterizedTypeInspection()), new GlobalInspectionToolWrapper(new EmptyMethodInspection()), new GlobalInspectionToolWrapper(new UnusedDeclarationInspection()) };
    myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection() {

        @NotNull
        @Override
        protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
            return myInspectionToolWrappers;
        }
    });
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) I18nInspection(com.intellij.codeInspection.i18n.I18nInspection) RawUseOfParameterizedTypeInspection(com.siyeh.ig.migration.RawUseOfParameterizedTypeInspection) EmptyMethodInspection(com.intellij.codeInspection.emptyMethod.EmptyMethodInspection) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection) NotNull(org.jetbrains.annotations.NotNull) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) PsiElement(com.intellij.psi.PsiElement)

Example 4 with UnusedDeclarationInspection

use of com.intellij.codeInspection.deadCode.UnusedDeclarationInspection in project android by JetBrains.

the class AndroidJavaHighlightingTest method testUnusedConstructors.

public void testUnusedConstructors() throws Exception {
    // Regression test for https://code.google.com/p/android/issues/detail?id=77054
    // Checks that various constructors are not marked as unused
    final UnusedDeclarationInspection inspection = new UnusedDeclarationInspection(true);
    myFixture.enableInspections(inspection);
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".java", "src/p1/p2/UnusedConstructors.java");
    myFixture.configureFromExistingVirtualFile(f);
    myFixture.checkHighlighting(true, false, true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)

Example 5 with UnusedDeclarationInspection

use of com.intellij.codeInspection.deadCode.UnusedDeclarationInspection in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method testUnusedMethodUpdate.

public void testUnusedMethodUpdate() throws Exception {
    configureByText(JavaFileType.INSTANCE, "class X {\n" + "    static void ffff() {}\n" + "    public static void main(String[] args){\n" + "        for (int i=0; i<1000;i++) {\n" + "            System.out.println(i);\n" + "            <caret>ffff();\n" + "        }\n" + "    }\n}");
    enableInspectionTool(new UnusedDeclarationInspection(true));
    List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING);
    assertEmpty(infos);
    PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE);
    infos = doHighlighting(HighlightSeverity.WARNING);
    assertEquals(1, infos.size());
    assertEquals("Method 'ffff()' is never used", infos.get(0).getDescription());
}
Also used : UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)

Aggregations

UnusedDeclarationInspection (com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)39 RedundantCastInspection (com.intellij.codeInspection.redundantCast.RedundantCastInspection)3 UncheckedWarningLocalInspection (com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiElement (com.intellij.psi.PsiElement)3 JavacQuirksInspection (com.intellij.codeInspection.compiler.JavacQuirksInspection)2 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)2 JavaDocReferenceInspection (com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection)2 NotNull (org.jetbrains.annotations.NotNull)2 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 InspectionEP (com.intellij.codeInspection.InspectionEP)1 UnusedDeclarationPresentation (com.intellij.codeInspection.deadCode.UnusedDeclarationPresentation)1 EmptyMethodInspection (com.intellij.codeInspection.emptyMethod.EmptyMethodInspection)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)1 I18nInspection (com.intellij.codeInspection.i18n.I18nInspection)1 EntryPoint (com.intellij.codeInspection.reference.EntryPoint)1 PsiField (com.intellij.psi.PsiField)1 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)1 ApplyChangeSignatureAction (com.intellij.refactoring.changeSignature.inplace.ApplyChangeSignatureAction)1