Change KotlinClassFileHeader loading interface
It should be able to load the header based on an abstract KotlinJvmBinaryClass, not only the VirtualFile-based one
This commit is contained in:
+1
-1
@@ -110,7 +110,7 @@ public final class DeserializedDescriptorResolver {
|
||||
|
||||
@Nullable
|
||||
private String[] readData(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
KotlinClassFileHeader header = KotlinClassFileHeader.readKotlinHeaderFromClassFile(kotlinClass.getFile());
|
||||
KotlinClassFileHeader header = KotlinClassFileHeader.readKotlinHeaderFromClassFile(kotlinClass);
|
||||
if (header instanceof SerializedDataHeader) {
|
||||
return ((SerializedDataHeader) header).getAnnotationData();
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.kotlin.header;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.ClassReader;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinJvmBinaryClass;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -28,12 +28,12 @@ import static org.jetbrains.asm4.ClassReader.*;
|
||||
|
||||
public abstract class KotlinClassFileHeader {
|
||||
@Nullable
|
||||
public static KotlinClassFileHeader readKotlinHeaderFromClassFile(@NotNull VirtualFile virtualFile) {
|
||||
public static KotlinClassFileHeader readKotlinHeaderFromClassFile(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
try {
|
||||
ClassReader reader = new ClassReader(virtualFile.contentsToByteArray());
|
||||
ClassReader reader = new ClassReader(kotlinClass.getFile().contentsToByteArray());
|
||||
ReadDataFromAnnotationVisitor visitor = new ReadDataFromAnnotationVisitor();
|
||||
reader.accept(visitor, SKIP_CODE | SKIP_FRAMES | SKIP_DEBUG);
|
||||
return visitor.createHeader(virtualFile);
|
||||
return visitor.createHeader(kotlinClass);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
+3
-3
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.kotlin.header;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.AnnotationVisitor;
|
||||
@@ -26,6 +25,7 @@ import org.jetbrains.asm4.Opcodes;
|
||||
import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinJvmBinaryClass;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -75,13 +75,13 @@ import static org.jetbrains.jet.lang.resolve.java.AbiVersionUtil.isAbiVersionCom
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KotlinClassFileHeader createHeader(@NotNull VirtualFile virtualFile) {
|
||||
public KotlinClassFileHeader createHeader(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
if (foundType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fqName == null) {
|
||||
LOG.error("Class doesn't have a name in the bytecode: " + virtualFile);
|
||||
LOG.error("Class doesn't have a name in the bytecode: " + kotlinClass);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user