create less garbage from UnusedSymbolUtil
authorBas Leijdekkers <basleijdekkers@gmail.com>
Tue, 5 Apr 2016 10:33:31 +0000 (12:33 +0200)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Tue, 5 Apr 2016 10:35:11 +0000 (12:35 +0200)
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/UnusedSymbolUtil.java
java/java-analysis-impl/src/com/intellij/find/findUsages/JavaClassFindUsagesOptions.java
java/java-analysis-impl/src/com/intellij/find/findUsages/JavaFindUsagesOptions.java
java/java-analysis-impl/src/com/intellij/find/findUsages/JavaMethodFindUsagesOptions.java
java/java-analysis-impl/src/com/intellij/find/findUsages/JavaPackageFindUsagesOptions.java
java/java-analysis-impl/src/com/intellij/find/findUsages/JavaVariableFindUsagesOptions.java

index b1c858b0d9bbd6021b139fcf5beb33a1d78a79a0..a68f794c578ec33fb7fcf61be4095d98556a18f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -240,28 +240,27 @@ public class UnusedSymbolUtil {
     }
     FindUsagesOptions options;
     if (member instanceof PsiPackage) {
-      options = new JavaPackageFindUsagesOptions(project);
+      options = new JavaPackageFindUsagesOptions(useScope);
       options.isSearchForTextOccurrences = true;
     }
     else if (member instanceof PsiClass) {
-      options = new JavaClassFindUsagesOptions(project);
+      options = new JavaClassFindUsagesOptions(useScope);
       options.isSearchForTextOccurrences = true;
     }
     else if (member instanceof PsiMethod) {
       PsiMethod method = (PsiMethod)member;
-      options = new JavaMethodFindUsagesOptions(project);
+      options = new JavaMethodFindUsagesOptions(useScope);
       options.isSearchForTextOccurrences = method.isConstructor();
     }
     else if (member instanceof PsiVariable) {
-      options = new JavaVariableFindUsagesOptions(project);
+      options = new JavaVariableFindUsagesOptions(useScope);
       options.isSearchForTextOccurrences = false;
     }
     else {
-      options = new FindUsagesOptions(project);
+      options = new FindUsagesOptions(useScope);
       options.isSearchForTextOccurrences = true;
     }
     options.isUsages = true;
-    options.searchScope = useScope;
     return JavaFindUsagesHelper.processElementUsages(member, options, usageInfoProcessor);
   }
 
index 8a509ab05b4b586d3ec5ca73ad97283444e10743..4339d36ffb38fcafe09b8529f16382d133893bde 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.find.findUsages;
 
 import com.intellij.find.FindBundle;
 import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.SearchScope;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.LinkedHashSet;
@@ -37,6 +38,10 @@ public class JavaClassFindUsagesOptions extends JavaFindUsagesOptions {
     super(project);
   }
 
+  public JavaClassFindUsagesOptions(@NotNull SearchScope searchScope) {
+    super(searchScope);
+  }
+
   @Override
   protected void addUsageTypes(@NotNull LinkedHashSet<String> strings) {
     if (isUsages || isMethodsUsages || isFieldsUsages) {
index 7accfccd14b937a437872fa7acc525aeb2c19693..60b650ce293ac89ddc3d025bb0467762f5eeae25 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.find.findUsages;
 import com.intellij.find.FindBundle;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.search.SearchScope;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.LinkedHashSet;
@@ -34,6 +35,12 @@ public abstract class JavaFindUsagesOptions extends FindUsagesOptions {
     isUsages = true;
   }
 
+  public JavaFindUsagesOptions(@NotNull SearchScope searchScope) {
+    super(searchScope);
+
+    isUsages = true;
+  }
+
   @Override
   public boolean equals(final Object o) {
     if (this == o) return true;
index 575ea88d5f522f0291f1375307b3479d08bbc541..ab39b82d109f7d7cee2c2a6b182c43c2e2f61726 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.find.findUsages;
 
 import com.intellij.find.FindBundle;
 import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.SearchScope;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.LinkedHashSet;
@@ -36,6 +37,11 @@ public class JavaMethodFindUsagesOptions extends JavaFindUsagesOptions {
     isSearchForTextOccurrences = false;
   }
 
+  public JavaMethodFindUsagesOptions(@NotNull SearchScope searchScope) {
+    super(searchScope);
+    isSearchForTextOccurrences = false;
+  }
+
   public boolean equals(final Object o) {
     if (this == o) return true;
     if (!super.equals(this)) return false;
index 415e06b2c502e8da3b78dbd62e3665e40d38129d..93cc0db69e9e7415d6195b7ed1a7b03ac5966005 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.find.findUsages;
 
 import com.intellij.find.FindBundle;
 import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.SearchScope;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.LinkedHashSet;
@@ -33,6 +34,10 @@ public class JavaPackageFindUsagesOptions extends JavaFindUsagesOptions {
     super(project);
   }
 
+  public JavaPackageFindUsagesOptions(@NotNull SearchScope searchScope) {
+    super(searchScope);
+  }
+
   @Override
   protected void addUsageTypes(@NotNull LinkedHashSet<String> to) {
     if (this.isUsages || this.isClassesUsages) {
index 14d865280d3a75908863a7bc2521b67e75429e80..218525612d6aedfaf33d007f201cd22bf7274296 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.find.findUsages;
 
 import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.SearchScope;
 import org.jetbrains.annotations.NotNull;
 
 /**
@@ -30,6 +31,11 @@ public class JavaVariableFindUsagesOptions extends JavaFindUsagesOptions {
     isSearchForTextOccurrences = false;
   }
 
+  public JavaVariableFindUsagesOptions(@NotNull SearchScope searchScope) {
+    super(searchScope);
+    isSearchForTextOccurrences = false;
+  }
+
   public boolean equals(final Object o) {
     if (this == o) return true;
     if (!super.equals(this)) return false;