Fix absence of notification about unsupported Abi
This commit is contained in:
@@ -37,7 +37,6 @@ import com.intellij.psi.JavaPsiFacade;
|
|||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.PsiClass;
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
import com.intellij.psi.search.ProjectScope;
|
import com.intellij.psi.search.ProjectScope;
|
||||||
import com.intellij.util.Processor;
|
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import com.intellij.util.indexing.FileBasedIndex;
|
import com.intellij.util.indexing.FileBasedIndex;
|
||||||
import com.intellij.util.indexing.ID;
|
import com.intellij.util.indexing.ID;
|
||||||
@@ -54,6 +53,9 @@ import java.io.IOException;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.intellij.util.PathUtil.getLocalFile;
|
||||||
|
import static com.intellij.util.PathUtil.getLocalPath;
|
||||||
|
|
||||||
public class KotlinRuntimeLibraryUtil {
|
public class KotlinRuntimeLibraryUtil {
|
||||||
private KotlinRuntimeLibraryUtil() {}
|
private KotlinRuntimeLibraryUtil() {}
|
||||||
|
|
||||||
@@ -67,29 +69,20 @@ public class KotlinRuntimeLibraryUtil {
|
|||||||
return !AbiVersionUtil.isAbiVersionCompatible(abiVersion);
|
return !AbiVersionUtil.isAbiVersionCompatible(abiVersion);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
final Collection<VirtualFile> badRoots = Sets.newHashSet();
|
Set<VirtualFile> badRoots = Sets.newHashSet();
|
||||||
final ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
|
ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
|
||||||
FileBasedIndex.getInstance().getFilesWithKey(
|
|
||||||
id,
|
for (Integer version : badAbiVersions) {
|
||||||
badAbiVersions,
|
Collection<VirtualFile> indexedFiles = FileBasedIndex.getInstance().getContainingFiles(id, version, ProjectScope.getLibrariesScope(project));
|
||||||
new Processor<VirtualFile>() {
|
|
||||||
@Override
|
for (VirtualFile indexedFile : indexedFiles) {
|
||||||
public boolean process(VirtualFile file) {
|
VirtualFile libraryRoot = fileIndex.getClassRootForFile(indexedFile);
|
||||||
assert file != null;
|
assert libraryRoot != null : "Only library roots were requested, " +
|
||||||
if (!file.isValid()) return true;
|
"and only class files should be indexed with KotlinAbiVersionIndex key. " +
|
||||||
VirtualFile root = fileIndex.getClassRootForFile(file);
|
"File: " + libraryRoot;
|
||||||
if (root != null) {
|
badRoots.add(getLocalFile(libraryRoot));
|
||||||
VirtualFile jarFile = JarFileSystem.getInstance().getVirtualFileForJar(root);
|
}
|
||||||
badRoots.add(jarFile != null ? jarFile : root);
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
badRoots.add(file);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ProjectScope.getLibrariesScope(project)
|
|
||||||
);
|
|
||||||
|
|
||||||
return badRoots;
|
return badRoots;
|
||||||
}
|
}
|
||||||
@@ -189,8 +182,10 @@ public class KotlinRuntimeLibraryUtil {
|
|||||||
|
|
||||||
static void replaceFile(File updatedFile, VirtualFile replacedJarFile) {
|
static void replaceFile(File updatedFile, VirtualFile replacedJarFile) {
|
||||||
try {
|
try {
|
||||||
String localPath = com.intellij.util.PathUtil.getLocalPath(replacedJarFile);
|
VirtualFile replacedFile = getLocalFile(replacedJarFile);
|
||||||
assert localPath != null;
|
|
||||||
|
String localPath = getLocalPath(replacedFile);
|
||||||
|
assert localPath != null : "Should be called for replacing valid root file: " + replacedJarFile;
|
||||||
|
|
||||||
File libraryJarPath = new File(localPath);
|
File libraryJarPath = new File(localPath);
|
||||||
|
|
||||||
@@ -199,11 +194,7 @@ public class KotlinRuntimeLibraryUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileUtil.copy(updatedFile, libraryJarPath);
|
FileUtil.copy(updatedFile, libraryJarPath);
|
||||||
|
replacedFile.refresh(false, true);
|
||||||
VirtualFile localFile = JarFileSystem.getInstance().getLocalVirtualFileFor(replacedJarFile);
|
|
||||||
if (localFile != null) {
|
|
||||||
localFile.refresh(false, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user