mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javac ast indices: do not search java direct inheritors for unknown language classes (AssertionError fixed)
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.compiler.backwardRefs;
|
||||
|
||||
import com.intellij.compiler.server.BuildManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
@@ -45,6 +46,8 @@ import java.util.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
class CompilerReferenceReader {
|
||||
private final static Logger LOG = Logger.getInstance(CompilerReferenceReader.class);
|
||||
|
||||
private final CompilerBackwardReferenceIndex myIndex;
|
||||
|
||||
private CompilerReferenceReader(File buildDir) throws IOException {
|
||||
@@ -85,6 +88,7 @@ class CompilerReferenceReader {
|
||||
|
||||
GlobalSearchScope effectiveSearchScope = GlobalSearchScope.notScope(dirtyScope).intersectWith(searchScope);
|
||||
LanguageLightRefAdapter adapter = CompilerReferenceServiceImpl.findAdapterForFileType(fileType);
|
||||
LOG.assertTrue(adapter != null, "adapter is null for file type: " + fileType);
|
||||
Class<? extends LightRef> requiredLightRefClass = searchType.getRequiredClass(adapter);
|
||||
Map<VirtualFile, List<LightRef>> candidatesPerFile = candidates
|
||||
.stream()
|
||||
|
||||
+4
-2
@@ -194,7 +194,7 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
@NotNull GlobalSearchScope searchScope,
|
||||
@NotNull FileType searchFileType,
|
||||
@NotNull CompilerHierarchySearchType searchType) {
|
||||
if (!isServiceEnabledFor(aClass) || searchScope == LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope()) return null;
|
||||
if (!isServiceEnabledFor(aClass) || searchScope == LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope()) return null;
|
||||
|
||||
Couple<Map<VirtualFile, T[]>> directInheritorsAndCandidates =
|
||||
CachedValuesManager.getCachedValue(aClass, () -> CachedValueProvider.Result.create(
|
||||
@@ -284,6 +284,7 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
return null;
|
||||
}
|
||||
final LanguageLightRefAdapter<?, ?> adapter = findAdapterForFileType(file.getFileType());
|
||||
if (adapter == null) return null;
|
||||
final LightRef ref = ReadAction.compute(() -> adapter.asLightUsage(psiElement, myReader.getNameEnumerator()));
|
||||
if (ref == null) return null;
|
||||
if (place == ElementPlace.LIB && buildHierarchyForLibraryElements) {
|
||||
@@ -360,13 +361,14 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static LanguageLightRefAdapter findAdapterForFileType(@NotNull FileType fileType) {
|
||||
for (LanguageLightRefAdapter adapter : LanguageLightRefAdapter.INSTANCES) {
|
||||
if (adapter.getFileTypes().contains(fileType)) {
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("adapter is not found for: " + fileType);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void executeOnBuildThread(Runnable compilationFinished) {
|
||||
|
||||
+1
-1
@@ -281,7 +281,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
SearchScope scope = parameters.getScope();
|
||||
if (!(scope instanceof GlobalSearchScope)) return null;
|
||||
|
||||
PsiClass searchClass = (PsiClass)PsiUtil.preferCompiledElement(parameters.getClassToProcess());
|
||||
PsiClass searchClass = ReadAction.compute(() -> (PsiClass)PsiUtil.preferCompiledElement(parameters.getClassToProcess()));
|
||||
final CompilerReferenceService compilerReferenceService = CompilerReferenceService.getInstance(project);
|
||||
return compilerReferenceService.getDirectInheritors(searchClass,
|
||||
(GlobalSearchScope)useScope,
|
||||
|
||||
Reference in New Issue
Block a user