File name transforming is unnecessary and thus, removed.
This commit is contained in:
@@ -56,9 +56,6 @@ public class CompilerArguments {
|
||||
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
|
||||
public boolean tags;
|
||||
|
||||
@Argument(value = "transformNamesToJava", description = "Transform Kotlin file names to *.java. This option is needed for compiling kotlinized Java library headers")
|
||||
public boolean transformNamesToJava;
|
||||
|
||||
|
||||
public String getClasspath() {
|
||||
return classpath;
|
||||
@@ -147,12 +144,4 @@ public class CompilerArguments {
|
||||
public void setTags(boolean tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public boolean isTransformNamesToJava() {
|
||||
return transformNamesToJava;
|
||||
}
|
||||
|
||||
public void setTransformNamesToJava(boolean transformNamesToJava) {
|
||||
this.transformNamesToJava = transformNamesToJava;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
package org.jetbrains.jet.cli;
|
||||
|
||||
import com.sampullara.cli.Args;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.compiler.*;
|
||||
import org.jetbrains.jet.compiler.CompileEnvironment;
|
||||
import org.jetbrains.jet.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.compiler.MessageRenderer;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
@@ -28,13 +29,6 @@ import java.io.PrintStream;
|
||||
*/
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
public class KotlinCompiler {
|
||||
private static final FileNameTransformer ANY_EXTENSION_TO_JAVA = new FileNameTransformer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String transformFileName(@NotNull String fileName) {
|
||||
return fileName.replaceFirst("\\.\\w+$", ".java");
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String... args) {
|
||||
doMain(new KotlinCompiler(), args);
|
||||
@@ -78,11 +72,8 @@ public class KotlinCompiler {
|
||||
}
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
|
||||
FileNameTransformer fileNameTransformer = arguments.transformNamesToJava
|
||||
? ANY_EXTENSION_TO_JAVA
|
||||
: FileNameTransformer.IDENTITY;
|
||||
MessageRenderer messageRenderer = arguments.tags ? MessageRenderer.TAGS : MessageRenderer.PLAIN;
|
||||
CompileEnvironment environment = new CompileEnvironment(fileNameTransformer, messageRenderer);
|
||||
CompileEnvironment environment = new CompileEnvironment(messageRenderer);
|
||||
try {
|
||||
configureEnvironment(environment, arguments, errStream);
|
||||
|
||||
|
||||
@@ -59,24 +59,22 @@ public class CompileEnvironment {
|
||||
private final MessageRenderer myMessageRenderer;
|
||||
private PrintStream myErrorStream = System.err;
|
||||
|
||||
private final FileNameTransformer myFileNameTransformer;
|
||||
private URL myStdlib;
|
||||
|
||||
private boolean ignoreErrors = false;
|
||||
private boolean stubs = false;
|
||||
|
||||
public CompileEnvironment() {
|
||||
this(FileNameTransformer.IDENTITY, MessageRenderer.PLAIN);
|
||||
this(MessageRenderer.PLAIN);
|
||||
}
|
||||
|
||||
public CompileEnvironment(FileNameTransformer fileNameTransformer, MessageRenderer messageRenderer) {
|
||||
public CompileEnvironment(MessageRenderer messageRenderer) {
|
||||
myRootDisposable = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
myEnvironment = new JetCoreEnvironment(myRootDisposable);
|
||||
myFileNameTransformer = fileNameTransformer;
|
||||
myMessageRenderer = messageRenderer;
|
||||
}
|
||||
|
||||
@@ -181,7 +179,7 @@ public class CompileEnvironment {
|
||||
|
||||
final String directory = new File(moduleScriptFile).getParent();
|
||||
for (Module moduleBuilder : modules) {
|
||||
CompileEnvironment compileEnvironment = new CompileEnvironment(myFileNameTransformer, myMessageRenderer);
|
||||
CompileEnvironment compileEnvironment = new CompileEnvironment(myMessageRenderer);
|
||||
compileEnvironment.setIgnoreErrors(ignoreErrors);
|
||||
compileEnvironment.setErrorStream(myErrorStream);
|
||||
// copy across any compiler plugins
|
||||
@@ -206,7 +204,7 @@ public class CompileEnvironment {
|
||||
}
|
||||
|
||||
public List<Module> loadModuleScript(String moduleFile) {
|
||||
CompileSession scriptCompileSession = new CompileSession(myEnvironment, myFileNameTransformer);
|
||||
CompileSession scriptCompileSession = new CompileSession(myEnvironment);
|
||||
scriptCompileSession.addSources(moduleFile);
|
||||
ensureRuntime();
|
||||
|
||||
@@ -353,7 +351,7 @@ public class CompileEnvironment {
|
||||
}
|
||||
|
||||
public ClassLoader compileText(String code) {
|
||||
CompileSession session = new CompileSession(myEnvironment, myFileNameTransformer);
|
||||
CompileSession session = new CompileSession(myEnvironment);
|
||||
session.addSources(new LightVirtualFile("script" + LocalTimeCounter.currentTime() + ".kt", JetLanguage.INSTANCE, code));
|
||||
|
||||
if (!session.analyze(myErrorStream, myMessageRenderer) && !ignoreErrors) {
|
||||
@@ -365,7 +363,7 @@ public class CompileEnvironment {
|
||||
}
|
||||
|
||||
public boolean compileBunchOfSources(String sourceFileOrDir, String jar, String outputDir, boolean includeRuntime) {
|
||||
CompileSession session = new CompileSession(myEnvironment, myFileNameTransformer);
|
||||
CompileSession session = new CompileSession(myEnvironment);
|
||||
session.setStubs(stubs);
|
||||
|
||||
session.addSources(sourceFileOrDir);
|
||||
|
||||
@@ -42,7 +42,8 @@ import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -55,7 +56,6 @@ import java.util.List;
|
||||
public class CompileSession {
|
||||
private final JetCoreEnvironment myEnvironment;
|
||||
private final List<JetFile> mySourceFiles = new ArrayList<JetFile>();
|
||||
private final FileNameTransformer myFileNameTransformer;
|
||||
private List<String> myErrors = new ArrayList<String>();
|
||||
private boolean stubs = false;
|
||||
|
||||
@@ -66,12 +66,7 @@ public class CompileSession {
|
||||
private BindingContext myBindingContext;
|
||||
|
||||
public CompileSession(JetCoreEnvironment environment) {
|
||||
this(environment, FileNameTransformer.IDENTITY);
|
||||
}
|
||||
|
||||
public CompileSession(JetCoreEnvironment environment, FileNameTransformer fileNameTransformer) {
|
||||
myEnvironment = environment;
|
||||
myFileNameTransformer = fileNameTransformer;
|
||||
}
|
||||
|
||||
public void setStubs(boolean stubs) {
|
||||
@@ -211,7 +206,7 @@ public class CompileSession {
|
||||
@NotNull
|
||||
public ClassFileFactory generate(boolean module) {
|
||||
Project project = myEnvironment.getProject();
|
||||
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), myFileNameTransformer);
|
||||
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs));
|
||||
generationState.compileCorrectFiles(myBindingContext, mySourceFiles, CompilationErrorHandler.THROW_EXCEPTION, true);
|
||||
ClassFileFactory answer = generationState.getFactory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user