mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unused declarations: don't search for usages under ReadLock(IDEA-175710)
when jvm-like langs are processed, refs should be already in graph, otherwise they will be caught by post processing task
This commit is contained in:
+6
-10
@@ -43,7 +43,6 @@ import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -333,16 +332,13 @@ public class UnusedDeclarationInspectionBase extends GlobalInspectionTool {
|
||||
}
|
||||
};
|
||||
|
||||
if (helper.processUsagesInNonJavaFiles(qualifiedName, processor, globalSearchScope)) {
|
||||
final PsiReference reference = ReferencesSearch.search(psiClass, globalSearchScope).findFirst();
|
||||
if (reference != null) {
|
||||
helper.processUsagesInNonJavaFiles(qualifiedName, processor, globalSearchScope);
|
||||
|
||||
//references from java-like are already in graph or
|
||||
//they would be checked during GlobalJavaInspectionContextImpl.performPostRunActivities
|
||||
for (RefElement element : refElement.getInReferences()) {
|
||||
if (!(element instanceof RefJavaElement)) {
|
||||
getEntryPointsManager(globalContext).addEntryPoint(refElement, false);
|
||||
for (PsiMethod method : psiClass.getMethods()) {
|
||||
final RefElement refMethod = refManager.getReference(method);
|
||||
if (refMethod != null) {
|
||||
getEntryPointsManager(globalContext).addEntryPoint(refMethod, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -125,6 +125,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
|
||||
if (!((RefElementImpl)refElement).hasSuspiciousCallers() || ((RefJavaElementImpl)refElement).isSuspiciousRecursive()) return 1;
|
||||
|
||||
for (RefElement element : refElement.getInReferences()) {
|
||||
if (refElement instanceof RefFile) return 1;
|
||||
if (((UnusedDeclarationInspectionBase)myTool).isEntryPoint(element)) return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class MyGroovyUsage {
|
||||
static void "to use java"() {
|
||||
new Util().foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Util {
|
||||
void foo() { }
|
||||
}
|
||||
@@ -198,4 +198,8 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
public void testReferenceFromReflection() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReferenceFromGroovy() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user