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