Don't fail on index update when counting paths for bad abi roots
EA-63535
This commit is contained in:
@@ -22,11 +22,13 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
@@ -61,7 +63,7 @@ public class KotlinRuntimeLibraryUtil {
|
||||
|
||||
@NotNull
|
||||
public static Collection<VirtualFile> getLibraryRootsWithAbiIncompatibleKotlinClasses(@NotNull Project project) {
|
||||
ID<Integer,Void> id = KotlinAbiVersionIndex.INSTANCE.getName();
|
||||
ID<Integer, Void> id = KotlinAbiVersionIndex.INSTANCE.getName();
|
||||
Collection<Integer> abiVersions = FileBasedIndex.getInstance().getAllKeys(id, project);
|
||||
Set<Integer> badAbiVersions = Sets.newHashSet(Collections2.filter(abiVersions, new Predicate<Integer>() {
|
||||
@Override
|
||||
|
||||
+14
-6
@@ -37,6 +37,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -157,13 +158,20 @@ public class UnsupportedAbiVersionNotificationPanelProvider extends EditorNotifi
|
||||
Runnable action = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Collection<VirtualFile> badRoots =
|
||||
KotlinRuntimeLibraryUtil.getLibraryRootsWithAbiIncompatibleKotlinClasses(project);
|
||||
assert !badRoots.isEmpty() : "This action should only be called when bad roots are present";
|
||||
DumbService.getInstance(project).tryRunReadActionInSmartMode(new Computable<Object>() {
|
||||
@Override
|
||||
public Object compute() {
|
||||
Collection<VirtualFile> badRoots =
|
||||
KotlinRuntimeLibraryUtil.getLibraryRootsWithAbiIncompatibleKotlinClasses(project);
|
||||
assert !badRoots.isEmpty() : "This action should only be called when bad roots are present";
|
||||
|
||||
LibraryRootsPopupModel listPopupModel = new LibraryRootsPopupModel("Unsupported format", project, badRoots);
|
||||
ListPopup popup = JBPopupFactory.getInstance().createListPopup(listPopupModel);
|
||||
popup.showUnderneathOf(label.get());
|
||||
LibraryRootsPopupModel listPopupModel = new LibraryRootsPopupModel("Unsupported format", project, badRoots);
|
||||
ListPopup popup = JBPopupFactory.getInstance().createListPopup(listPopupModel);
|
||||
popup.showUnderneathOf(label.get());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, "Can't show all paths during index update");
|
||||
}
|
||||
};
|
||||
label.set(answer.createActionLabel(labelText, action));
|
||||
|
||||
Reference in New Issue
Block a user