Search in sources :

Example 1 with EqualsWithItselfInspection

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

the class OfflineInspectionResultViewTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    HighlightDisplayKey key = HighlightDisplayKey.find(UnusedDeclarationInspectionBase.SHORT_NAME);
    if (key == null) {
        HighlightDisplayKey.register(UnusedDeclarationInspectionBase.SHORT_NAME);
    }
    final InspectionProfileImpl profile = new InspectionProfileImpl("test") {

        @Override
        public boolean isToolEnabled(@Nullable final HighlightDisplayKey key, PsiElement element) {
            return key != null && Comparing.strEqual(key.toString(), UnusedDeclarationInspectionBase.SHORT_NAME);
        }

        @Override
        @NotNull
        public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
            return new InspectionToolWrapper[] { myUnusedToolWrapper };
        }

        @Override
        @NotNull
        public InspectionProfileModifiableModel getModifiableModel() {
            return new InspectionProfileModifiableModel(this) {

                @Override
                @NotNull
                public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
                    return new InspectionToolWrapper[] { myUnusedToolWrapper };
                }

                @Override
                public boolean isToolEnabled(@Nullable HighlightDisplayKey key, PsiElement element) {
                    return key != null && Comparing.strEqual(key.toString(), UnusedDeclarationInspectionBase.SHORT_NAME);
                }
            };
        }
    };
    myView = ViewOfflineResultsAction.showOfflineView(getProject(), parse(), profile, "");
    myUnusedToolWrapper = new GlobalInspectionToolWrapper(new UnusedDeclarationInspection());
    myDataFlowToolWrapper = new LocalInspectionToolWrapper(new EqualsWithItselfInspection());
    final Map<String, Tools> tools = myView.getGlobalInspectionContext().getTools();
    for (InspectionToolWrapper tool : ContainerUtil.ar(myUnusedToolWrapper, myDataFlowToolWrapper)) {
        profile.addTool(getProject(), tool, new THashMap<>());
        tools.put(tool.getShortName(), new ToolsImpl(tool, tool.getDefaultLevel(), true));
        tool.initialize(myView.getGlobalInspectionContext());
    }
}
Also used : HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) EqualsWithItselfInspection(com.siyeh.ig.bugs.EqualsWithItselfInspection) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection) Nullable(org.jetbrains.annotations.Nullable) PsiElement(com.intellij.psi.PsiElement)

Aggregations

HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 UnusedDeclarationInspection (com.intellij.codeInspection.deadCode.UnusedDeclarationInspection)1 PsiElement (com.intellij.psi.PsiElement)1 EqualsWithItselfInspection (com.siyeh.ig.bugs.EqualsWithItselfInspection)1 Nullable (org.jetbrains.annotations.Nullable)1