Extracted buildClassReaderByInternalName into InlineCodegenUtil
This commit is contained in:
committed by
Andrey Breslav
parent
fc1d8dd9ce
commit
74ca304931
+1
-19
@@ -17,10 +17,8 @@
|
||||
package org.jetbrains.jet.codegen.inline;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.OutputFile;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
@@ -31,7 +29,6 @@ import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
|
||||
import org.jetbrains.org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
@@ -69,22 +66,7 @@ public class AnonymousObjectTransformer {
|
||||
this.oldObjectType = Type.getObjectType(objectInternalName);
|
||||
this.newLambdaType = newLambdaType;
|
||||
|
||||
//try to find just compiled classes then in dependencies
|
||||
try {
|
||||
OutputFile outputFile = state.getFactory().get(objectInternalName + ".class");
|
||||
if (outputFile != null) {
|
||||
reader = new ClassReader(outputFile.asByteArray());
|
||||
} else {
|
||||
VirtualFile file = InlineCodegenUtil.findVirtualFile(state.getProject(), objectInternalName);
|
||||
if (file == null) {
|
||||
throw new RuntimeException("Couldn't find virtual file for " + objectInternalName);
|
||||
}
|
||||
reader = new ClassReader(file.contentsToByteArray());
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
reader = InlineCodegenUtil.buildClassReaderByInternalName(state, objectInternalName);
|
||||
}
|
||||
|
||||
private void buildInvokeParamsFor(@NotNull ParametersBuilder builder, @NotNull MethodNode node) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.OutputFile;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.context.PackageContext;
|
||||
@@ -367,6 +368,26 @@ public class InlineCodegenUtil {
|
||||
return node.name + " " + node.desc + ": \n " + sw.getBuffer().toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
/* package */ static ClassReader buildClassReaderByInternalName(@NotNull GenerationState state, @NotNull String internalName) {
|
||||
//try to find just compiled classes then in dependencies
|
||||
try {
|
||||
OutputFile outputFile = state.getFactory().get(internalName + ".class");
|
||||
if (outputFile != null) {
|
||||
return new ClassReader(outputFile.asByteArray());
|
||||
} else {
|
||||
VirtualFile file = findVirtualFile(state.getProject(), internalName);
|
||||
if (file == null) {
|
||||
throw new RuntimeException("Couldn't find virtual file for " + internalName);
|
||||
}
|
||||
return new ClassReader(file.contentsToByteArray());
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LabelTextifier extends Textifier {
|
||||
|
||||
public LabelTextifier() {
|
||||
|
||||
Reference in New Issue
Block a user