search java direct inheritors using javac indices: add javadoc (IDEA-CR-14364)
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 11 Oct 2016 20:20:57 +0000 (23:20 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 11 Oct 2016 20:43:48 +0000 (23:43 +0300)
java/compiler/impl/src/com/intellij/compiler/CompilerReferenceReader.java
java/java-indexing-impl/src/com/intellij/compiler/CompilerReferenceService.java

index b5be62418ee6b255ee1935a22ae095ce48369451..255c42dc56e8e7695ba06f6ac3cf3ad421b63c03 100644 (file)
@@ -75,18 +75,24 @@ class CompilerReferenceReader {
     return set;
   }
 
+  /**
+   * @return two maps of classes grouped per file
+   *
+   * 1st map: inheritors. Can be used without explicit inheritance verification
+   * 2nd map: candidates. One need to check that these classes are really direct inheritors
+   */
   @Nullable
-  <T extends PsiNamedElement> Couple<Map<VirtualFile, T[]>> getDirectInheritors(@NotNull PsiNamedElement psiElement,
-                                                                                @Nullable CompilerReferenceServiceImpl.CompilerElementInfo searchElementInfo,
+  <T extends PsiNamedElement> Couple<Map<VirtualFile, T[]>> getDirectInheritors(@NotNull PsiNamedElement baseClass,
+                                                                                @Nullable CompilerReferenceServiceImpl.CompilerElementInfo classSearchElementInfo,
                                                                                 @NotNull ClassResolvingCompilerSearchAdapter<T> inheritorSearchAdapter,
                                                                                 @NotNull GlobalSearchScope searchScope,
                                                                                 @NotNull GlobalSearchScope dirtyScope,
                                                                                 @NotNull Project project,
                                                                                 FileType fileType) {
-    if (searchElementInfo == null) return null;
+    if (classSearchElementInfo == null) return null;
 
     CompilerBackwardReferenceIndex.LightDefinition[] candidates =
-      Stream.of(searchElementInfo.searchElements)
+      Stream.of(classSearchElementInfo.searchElements)
       .map(this::asLightUsage)
       .map(myIndex.getBackwardHierarchyMap()::get)
       .filter(Objects::nonNull)
@@ -120,7 +126,7 @@ class CompilerReferenceReader {
     Map<VirtualFile, T[]> inheritorCandidates = new THashMap<>();
 
     candidatesPerFile.forEach((file, directInheritors) -> {
-      final T[] currInheritors = inheritorSearchAdapter.getCandidatesFromFile(directInheritors, psiElement, file, project);
+      final T[] currInheritors = inheritorSearchAdapter.getCandidatesFromFile(directInheritors, baseClass, file, project);
       if (currInheritors.length == directInheritors.size()) {
         inheritors.put(file, currInheritors);
       } else {
index 8d5869ad5c716d85b8f1175ca2de098f4164136e..233ee14fb38326dc23e778df596991bb55190f2b 100644 (file)
@@ -55,12 +55,21 @@ public abstract class CompilerReferenceService extends AbstractProjectComponent
   }
 
   public interface CompilerDirectInheritorInfo<T extends PsiNamedElement> {
+    /**
+     * Can be used as direct inheritors without explicit inheritance verification
+     */
     @NotNull
     Stream<T> getDirectInheritors();
 
+    /**
+     * Must be explicitly checked do they are really direct inheritors
+     */
     @NotNull
     Stream<T> getDirectInheritorCandidates();
 
+    /**
+     * A scope where compiler based index search was not performed
+     */
     @NotNull
     GlobalSearchScope getDirtyScope();
   }