Visitors in tests migrated to ASM 4.0
This commit is contained in:
@@ -25,16 +25,13 @@ import com.intellij.psi.impl.PsiFileFactoryImpl;
|
|||||||
import com.intellij.testFramework.LightVirtualFile;
|
import com.intellij.testFramework.LightVirtualFile;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.asm4.*;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.Label;
|
|
||||||
import org.objectweb.asm.MethodVisitor;
|
|
||||||
import org.objectweb.asm.commons.EmptyVisitor;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -189,13 +186,17 @@ public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<LocalVariable> readLocalVariable(ClassReader cr, final String methodName) throws Exception {
|
private List<LocalVariable> readLocalVariable(ClassReader cr, final String methodName) throws Exception {
|
||||||
class Visitor extends EmptyVisitor {
|
class Visitor extends ClassVisitor {
|
||||||
List<LocalVariable> readVariables = new ArrayList<LocalVariable>();
|
List<LocalVariable> readVariables = new ArrayList<LocalVariable>();
|
||||||
|
|
||||||
|
public Visitor() {
|
||||||
|
super(Opcodes.ASM4);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod(int access, String name, final String desc, final String signature, String[] exceptions) {
|
public MethodVisitor visitMethod(int access, String name, final String desc, final String signature, String[] exceptions) {
|
||||||
if (methodName.equals(name + desc)) {
|
if (methodName.equals(name + desc)) {
|
||||||
return new EmptyVisitor() {
|
return new MethodVisitor(Opcodes.ASM4) {
|
||||||
@Override
|
@Override
|
||||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||||
readVariables.add(new LocalVariable(name, desc, index));
|
readVariables.add(new LocalVariable(name, desc, index));
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.intellij.testFramework.LightVirtualFile;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.asm4.*;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||||
@@ -37,11 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
|||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.jetbrains.asm4.commons.Method;
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.MethodVisitor;
|
|
||||||
import org.objectweb.asm.commons.EmptyVisitor;
|
|
||||||
import org.objectweb.asm.commons.Method;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -60,6 +57,8 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class WriteSignatureTest extends TestCaseWithTmpdir {
|
public class WriteSignatureTest extends TestCaseWithTmpdir {
|
||||||
|
|
||||||
|
private static final AnnotationVisitor EMPTY_ANNOTATION_VISITOR = new AnnotationVisitor(Opcodes.ASM4) {};
|
||||||
|
|
||||||
private final File ktFile;
|
private final File ktFile;
|
||||||
private JetCoreEnvironment jetCoreEnvironment;
|
private JetCoreEnvironment jetCoreEnvironment;
|
||||||
|
|
||||||
@@ -122,16 +121,20 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
|||||||
// ugly unreadable code begin
|
// ugly unreadable code begin
|
||||||
FileInputStream classInputStream = new FileInputStream(tmpdir + "/" + className.replace('.', '/') + ".class");
|
FileInputStream classInputStream = new FileInputStream(tmpdir + "/" + className.replace('.', '/') + ".class");
|
||||||
try {
|
try {
|
||||||
class Visitor extends EmptyVisitor {
|
class Visitor extends ClassVisitor {
|
||||||
ActualSignature readSignature;
|
ActualSignature readSignature;
|
||||||
|
|
||||||
|
public Visitor() {
|
||||||
|
super(Opcodes.ASM4);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod(int access, String name, final String desc, final String signature, String[] exceptions) {
|
public MethodVisitor visitMethod(int access, String name, final String desc, final String signature, String[] exceptions) {
|
||||||
if (name.equals(methodName)) {
|
if (name.equals(methodName)) {
|
||||||
|
|
||||||
final int parameterCount = new Method(name, desc).getArgumentTypes().length;
|
final int parameterCount = new Method(name, desc).getArgumentTypes().length;
|
||||||
|
|
||||||
return new EmptyVisitor() {
|
return new MethodVisitor(Opcodes.ASM4) {
|
||||||
String typeParameters = "";
|
String typeParameters = "";
|
||||||
String returnType;
|
String returnType;
|
||||||
String[] parameterTypes = new String[parameterCount];
|
String[] parameterTypes = new String[parameterCount];
|
||||||
@@ -139,7 +142,7 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
|||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||||
if (desc.equals(JvmStdlibNames.JET_METHOD.getDescriptor())) {
|
if (desc.equals(JvmStdlibNames.JET_METHOD.getDescriptor())) {
|
||||||
return new EmptyVisitor() {
|
return new AnnotationVisitor(Opcodes.ASM4) {
|
||||||
@Override
|
@Override
|
||||||
public void visit(String name, Object value) {
|
public void visit(String name, Object value) {
|
||||||
if (name.equals(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD)) {
|
if (name.equals(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD)) {
|
||||||
@@ -151,25 +154,25 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
public AnnotationVisitor visitAnnotation(String s, String s1) {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitArray(String name) {
|
public AnnotationVisitor visitArray(String name) {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitParameterAnnotation(final int parameter, String desc, boolean visible) {
|
public AnnotationVisitor visitParameterAnnotation(final int parameter, String desc, boolean visible) {
|
||||||
if (desc.equals(JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor())) {
|
if (desc.equals(JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor())) {
|
||||||
return new EmptyVisitor() {
|
return new AnnotationVisitor(Opcodes.ASM4) {
|
||||||
@Override
|
@Override
|
||||||
public void visit(String name, Object value) {
|
public void visit(String name, Object value) {
|
||||||
if (name.equals(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD)) {
|
if (name.equals(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD)) {
|
||||||
@@ -178,24 +181,24 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
public AnnotationVisitor visitAnnotation(String name, String desc) {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitArray(String name) {
|
public AnnotationVisitor visitArray(String name) {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotationDefault() {
|
public AnnotationVisitor visitAnnotationDefault() {
|
||||||
return new EmptyVisitor();
|
return EMPTY_ANNOTATION_VISITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
Reference in New Issue
Block a user