A command-line argument to transform file names to *.java
This commit is contained in:
@@ -11,7 +11,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
@@ -112,7 +111,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
funClass,
|
||||
new String[0]
|
||||
);
|
||||
cv.visitSource(fun.getContainingFile().getName(), null);
|
||||
cv.visitSource(state.transformFileName(fun.getContainingFile().getName()), null);
|
||||
|
||||
|
||||
generateBridge(name, funDescriptor, fun, cv);
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.compiler.FileNameTransformer;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||
@@ -33,11 +34,18 @@ public class GenerationState {
|
||||
private final JetStandardLibrary standardLibrary;
|
||||
private final IntrinsicMethods intrinsics;
|
||||
|
||||
private final FileNameTransformer fileNameTransformer;
|
||||
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory) {
|
||||
this(project, builderFactory, FileNameTransformer.IDENTITY);
|
||||
}
|
||||
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, FileNameTransformer fileNameTransformer) {
|
||||
this.project = project;
|
||||
this.standardLibrary = JetStandardLibrary.getJetStandardLibrary(project);
|
||||
this.factory = new ClassFileFactory(builderFactory, this);
|
||||
this.intrinsics = new IntrinsicMethods(project, standardLibrary);
|
||||
this.fileNameTransformer = fileNameTransformer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -186,4 +194,9 @@ public class GenerationState {
|
||||
|
||||
return answer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String transformFileName(@NotNull String fileName) {
|
||||
return fileNameTransformer.transformFileName(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
import org.objectweb.asm.commons.Method;
|
||||
@@ -91,7 +90,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
signature.getSuperclassName(),
|
||||
signature.getInterfaces().toArray(new String[0])
|
||||
);
|
||||
v.visitSource(myClass.getContainingFile().getName(), null);
|
||||
v.visitSource(state.transformFileName(myClass.getContainingFile().getName()), null);
|
||||
|
||||
ClassDescriptor container = getContainingClassDescriptor(descriptor);
|
||||
if(container != null) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class NamespaceCodegen {
|
||||
new String[0]
|
||||
);
|
||||
// TODO figure something out for a namespace that spans multiple files
|
||||
v.visitSource(sourceFile.getName(), null);
|
||||
v.visitSource(state.transformFileName(sourceFile.getName()), null);
|
||||
}
|
||||
|
||||
public void generate(JetFile file) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
"java/lang/Object",
|
||||
new String[0]
|
||||
);
|
||||
v.visitSource(myClass.getContainingFile().getName(), null);
|
||||
v.visitSource(state.transformFileName(myClass.getContainingFile().getName()), null);
|
||||
}
|
||||
|
||||
private String jvmName() {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.jetbrains.jet.compiler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface FileNameTransformer {
|
||||
FileNameTransformer IDENTITY = new FileNameTransformer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String transformFileName(@NotNull String fileName) {
|
||||
return fileName;
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
String transformFileName(@NotNull String fileName);
|
||||
}
|
||||
Reference in New Issue
Block a user