use of com.intellij.util.containers.ConcurrentFactoryMap in project intellij-community by JetBrains.
the class CompilerReferenceServiceImpl method getHierarchyInfo.
@Nullable
private CompilerHierarchyInfoImpl getHierarchyInfo(@NotNull PsiNamedElement aClass, @NotNull GlobalSearchScope useScope, @NotNull GlobalSearchScope searchScope, @NotNull FileType searchFileType, @NotNull CompilerHierarchySearchType searchType) {
if (!isServiceEnabledFor(aClass) || searchScope == LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope())
return null;
try {
Map<VirtualFile, Object[]> candidatesPerFile = ReadAction.compute(() -> {
if (myProject.isDisposed())
throw new ProcessCanceledException();
return CachedValuesManager.getCachedValue(aClass, () -> CachedValueProvider.Result.create(new ConcurrentFactoryMap<HierarchySearchKey, Map<VirtualFile, Object[]>>() {
@Nullable
@Override
protected Map<VirtualFile, Object[]> create(HierarchySearchKey key) {
return calculateDirectInheritors(aClass, useScope, key.mySearchFileType, key.mySearchType);
}
}, PsiModificationTracker.MODIFICATION_COUNT, this)).get(new HierarchySearchKey(searchType, searchFileType));
});
if (candidatesPerFile == null)
return null;
GlobalSearchScope dirtyScope = myDirtyScopeHolder.getDirtyScope();
if (ElementPlace.LIB == ReadAction.compute(() -> ElementPlace.get(aClass.getContainingFile().getVirtualFile(), myProjectFileIndex))) {
dirtyScope = dirtyScope.union(LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope());
}
return new CompilerHierarchyInfoImpl(candidatesPerFile, aClass, dirtyScope, searchScope, myProject, searchFileType, searchType);
} catch (ProcessCanceledException e) {
throw e;
} catch (RuntimeException e) {
return onException(e, "hierarchy");
}
}
use of com.intellij.util.containers.ConcurrentFactoryMap in project intellij-community by JetBrains.
the class AnnotationUtil method findNonCodeAnnotation.
private static PsiAnnotation findNonCodeAnnotation(final PsiModifierListOwner listOwner, Collection<String> annotationNames) {
ConcurrentFactoryMap<Collection<String>, PsiAnnotation> map = CachedValuesManager.getCachedValue(listOwner, () -> {
ConcurrentFactoryMap<Collection<String>, PsiAnnotation> value = new ConcurrentFactoryMap<Collection<String>, PsiAnnotation>() {
@Nullable
@Override
protected PsiAnnotation create(Collection<String> annotationNames1) {
final Project project = listOwner.getProject();
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
for (String annotationName : annotationNames1) {
final PsiAnnotation annotation = annotationsManager.findExternalAnnotation(listOwner, annotationName);
if (annotation != null) {
return annotation;
}
}
final InferredAnnotationsManager inferredAnnotationsManager = InferredAnnotationsManager.getInstance(project);
for (String annotationName : annotationNames1) {
final PsiAnnotation annotation = inferredAnnotationsManager.findInferredAnnotation(listOwner, annotationName);
if (annotation != null) {
return annotation;
}
}
return null;
}
};
return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
});
return map.get(annotationNames);
}
Aggregations