VirtualFileFinder update to search files without kotlin headers
This commit is contained in:
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.vfilefinder;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.impl.file.impl.JavaFileManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -52,4 +55,26 @@ public final class IDEVirtualFileFinder extends VirtualFileKotlinClassFinder imp
|
||||
}
|
||||
return files.iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findVirtualFile(@NotNull String internalName) {
|
||||
JavaFileManager fileFinder = ServiceManager.getService(project, JavaFileManager.class);
|
||||
|
||||
String qName = internalName.replace('/', '.');
|
||||
PsiClass psiClass = fileFinder.findClass(qName, GlobalSearchScope.allScope(project));
|
||||
if (psiClass == null) {
|
||||
int dollarIndex = qName.indexOf('$');
|
||||
assert dollarIndex > 0 : "Only inner classes could be found with this patch: " + internalName;
|
||||
String newName = qName.substring(0, dollarIndex);
|
||||
psiClass = fileFinder.findClass(newName, GlobalSearchScope.allScope(project));
|
||||
if (psiClass != null) {
|
||||
int i = qName.lastIndexOf('.');
|
||||
return psiClass.getContainingFile().getVirtualFile().getParent().findChild(qName.substring(i + 1) + ".class");
|
||||
}
|
||||
}
|
||||
if (psiClass != null) {
|
||||
return psiClass.getContainingFile().getVirtualFile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user