VirtualFileFinder refactoring
This commit is contained in:
@@ -106,7 +106,7 @@ public class InlineCodegenUtil {
|
||||
public static VirtualFile findVirtualFile(@NotNull Project project, @NotNull FqName containerFqName, boolean onlyKotlin) {
|
||||
VirtualFileFinder fileFinder = ServiceManager.getService(project, VirtualFileFinder.class);
|
||||
if (onlyKotlin) {
|
||||
return fileFinder.findVirtualFile(containerFqName);
|
||||
return fileFinder.findVirtualFileWithHeader(containerFqName);
|
||||
} else {
|
||||
return fileFinder.findVirtualFile(containerFqName.asString().replace('.', '/'));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CliVirtualFileFinder extends VirtualFileKotlinClassFinder implement
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile findVirtualFile(@NotNull FqName className) {
|
||||
public VirtualFile findVirtualFileWithHeader(@NotNull FqName className) {
|
||||
for (VirtualFile root : classPath) {
|
||||
VirtualFile fileInRoot = findKotlinFile(className, root);
|
||||
if (fileInRoot != null) {
|
||||
@@ -46,6 +46,7 @@ public class CliVirtualFileFinder extends VirtualFileKotlinClassFinder implement
|
||||
|
||||
private 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 && createKotlinClass(vFile).getClassHeader() != null) {
|
||||
return vFile;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public interface VirtualFileFinder extends KotlinClassFinder {
|
||||
|
||||
// TODO: support scope
|
||||
@Nullable
|
||||
VirtualFile findVirtualFile(@NotNull FqName className);
|
||||
VirtualFile findVirtualFileWithHeader(@NotNull FqName className);
|
||||
|
||||
/*Also finds files without kotlin header*/
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public abstract class VirtualFileKotlinClassFinder implements VirtualFileFinder
|
||||
@Nullable
|
||||
@Override
|
||||
public KotlinJvmBinaryClass findKotlinClass(@NotNull FqName fqName) {
|
||||
VirtualFile file = findVirtualFile(fqName);
|
||||
VirtualFile file = findVirtualFileWithHeader(fqName);
|
||||
return file == null ? null : createKotlinClass(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class DecompiledNavigationUtils {
|
||||
return null;
|
||||
}
|
||||
VirtualFileFinder fileFinder = VirtualFileFinder.SERVICE.getInstance(project);
|
||||
VirtualFile virtualFile = fileFinder.findVirtualFile(containerFqName);
|
||||
VirtualFile virtualFile = fileFinder.findVirtualFileWithHeader(containerFqName);
|
||||
if (virtualFile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class IDEVirtualFileFinder extends VirtualFileKotlinClassFinder imp
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile findVirtualFile(@NotNull FqName className) {
|
||||
public VirtualFile findVirtualFileWithHeader(@NotNull FqName className) {
|
||||
Collection<VirtualFile> files =
|
||||
FileBasedIndex.getInstance().getContainingFiles(KotlinClassFileIndex.KEY, className, GlobalSearchScope.allScope(project));
|
||||
if (files.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user