[duplicates] enable duplicates analysis in PyCharm/WebStorm/PhpStorm/RubyMine
[idea/community.git] / java / java-analysis-impl / src / com / intellij / find / findUsages / JavaMethodFindUsagesOptions.java
1 // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.find.findUsages;
3
4 import com.intellij.find.FindBundle;
5 import com.intellij.openapi.project.Project;
6 import com.intellij.psi.search.SearchScope;
7 import org.jetbrains.annotations.NotNull;
8
9 import java.util.LinkedHashSet;
10
11 /**
12  * @author peter
13  */
14 public class JavaMethodFindUsagesOptions extends JavaFindUsagesOptions {
15   public boolean isOverridingMethods;
16   public boolean isImplementingMethods;
17   public boolean isCheckDeepInheritance = true;
18   public boolean isIncludeInherited;
19   public boolean isIncludeOverloadUsages;
20   public boolean isImplicitToString = true;
21
22   public JavaMethodFindUsagesOptions(@NotNull Project project) {
23     super(project);
24     isSearchForTextOccurrences = false;
25   }
26
27   public JavaMethodFindUsagesOptions(@NotNull SearchScope searchScope) {
28     super(searchScope);
29     isSearchForTextOccurrences = false;
30   }
31
32   public boolean equals(final Object o) {
33     if (this == o) return true;
34     if (!super.equals(o)) return false;
35     if (getClass() != o.getClass()) return false;
36
37     final JavaMethodFindUsagesOptions that = (JavaMethodFindUsagesOptions)o;
38
39     if (isCheckDeepInheritance != that.isCheckDeepInheritance) return false;
40     if (isImplementingMethods != that.isImplementingMethods) return false;
41     if (isIncludeInherited != that.isIncludeInherited) return false;
42     if (isIncludeOverloadUsages != that.isIncludeOverloadUsages) return false;
43     if (isOverridingMethods != that.isOverridingMethods) return false;
44     if (isImplicitToString != that.isImplicitToString) return false;
45
46     return true;
47   }
48
49   public int hashCode() {
50     int result = super.hashCode();
51     result = 31 * result + (isOverridingMethods ? 1 : 0);
52     result = 31 * result + (isImplementingMethods ? 1 : 0);
53     result = 31 * result + (isCheckDeepInheritance ? 1 : 0);
54     result = 31 * result + (isIncludeInherited ? 1 : 0);
55     result = 31 * result + (isIncludeOverloadUsages ? 1 : 0);
56     result = 31 * result + (isImplicitToString ? 1 : 0);
57     return result;
58   }
59
60   @Override
61   protected void addUsageTypes(@NotNull LinkedHashSet<String> strings) {
62     super.addUsageTypes(strings);
63     if (isIncludeOverloadUsages) {
64       strings.add(FindBundle.message("find.usages.panel.title.overloaded.methods.usages"));
65     }
66     if (isImplementingMethods) {
67       strings.add(FindBundle.message("find.usages.panel.title.implementing.methods"));
68     }
69     if (isOverridingMethods) {
70       strings.add(FindBundle.message("find.usages.panel.title.overriding.methods"));
71     }
72   }
73 }