mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] more robustness for .class stub builder (IDEA-CR-12160)
This commit is contained in:
@@ -673,11 +673,16 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
return p > 0 ? internalName.substring(0, p).replace('/', '.') : "";
|
||||
}
|
||||
|
||||
private static class FileContentPair extends Pair<VirtualFile, byte[]> {
|
||||
public FileContentPair(VirtualFile file, byte[] content) {
|
||||
static class FileContentPair extends Pair<VirtualFile, byte[]> {
|
||||
public FileContentPair(@NotNull VirtualFile file, @NotNull byte[] content) {
|
||||
super(file, content);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public byte[] getContent() {
|
||||
return second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return first.toString();
|
||||
|
||||
@@ -784,23 +784,23 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
}
|
||||
|
||||
private static Function<String, String> createMapping(Object classSource) {
|
||||
Function<String, String> mapping = null;
|
||||
|
||||
if (classSource instanceof Pair) {
|
||||
Object second = ((Pair)classSource).second;
|
||||
if (second instanceof byte[]) {
|
||||
mapping = createMapping((byte[])second);
|
||||
}
|
||||
byte[] bytes = null;
|
||||
if (classSource instanceof ClsFileImpl.FileContentPair) {
|
||||
bytes = ((ClsFileImpl.FileContentPair)classSource).getContent();
|
||||
}
|
||||
else if (classSource instanceof VirtualFile) {
|
||||
try {
|
||||
byte[] bytes = ((VirtualFile)classSource).contentsToByteArray(false);
|
||||
mapping = createMapping(bytes);
|
||||
}
|
||||
try { bytes = ((VirtualFile)classSource).contentsToByteArray(false); }
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
return mapping != null ? mapping : GUESSING_MAPPER;
|
||||
if (bytes != null) {
|
||||
Function<String, String> mapping = createMapping(bytes);
|
||||
if (mapping != null) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
return GUESSING_MAPPER;
|
||||
}
|
||||
|
||||
private static Function<String, String> createMapping(byte[] classBytes) {
|
||||
|
||||
Reference in New Issue
Block a user