Refactor KotlinJvmBinaryClass, VirtualFileKotlinClass, etc.
VirtualFileKotlinClass now reads its header and name on creation. This is not lazy enough and may be slower in some circumstances, but has the following advantage: if anything is wrong in the header, a VirtualFileKotlinClass instance will not be created at all, making it nearly impossible for the client code to operate on invalid data causing all kinds of exceptions
This commit is contained in:
@@ -37,23 +37,15 @@ public class CliVirtualFileFinder extends VirtualFileKotlinClassFinder implement
|
||||
@Override
|
||||
public VirtualFile findVirtualFileWithHeader(@NotNull FqName className) {
|
||||
for (VirtualFile root : classPath) {
|
||||
VirtualFile fileInRoot = findKotlinFile(className, root);
|
||||
if (fileInRoot != null) {
|
||||
VirtualFile fileInRoot = findFileInRoot(className.asString(), root, '.');
|
||||
//NOTE: currently we use VirtualFileFinder to find Kotlin binaries only
|
||||
if (fileInRoot != null && KotlinBinaryClassCache.getKotlinBinaryClass(fileInRoot) != null) {
|
||||
return fileInRoot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static VirtualFile findKotlinFile(@NotNull FqName className, @NotNull VirtualFile root) {
|
||||
VirtualFile vFile = findFileInRoot(className.asString(), root, '.');
|
||||
//NOTE: currently we use VirtualFileFinder to find Kotlin binaries only
|
||||
if (vFile != null && KotlinBinaryClassCache.getKotlinBinaryClass(vFile).getClassHeader() != null) {
|
||||
return vFile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findVirtualFile(@NotNull String internalName) {
|
||||
for (VirtualFile root : classPath) {
|
||||
|
||||
Reference in New Issue
Block a user