Minor: report error instead of crash with exceptions when collect JetFiles to compile and remove obsolete (wrong now) code

#EA-61681 Obsolete
This commit is contained in:
Zalim Bashorov
2015-09-10 22:32:24 +03:00
parent 909cbc6817
commit 1b00eb3a17
9 changed files with 43 additions and 8 deletions
@@ -171,19 +171,22 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.getModules(), directory)
environment = createCoreEnvironment(rootDisposable, compilerConfiguration)
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
KotlinToJVMBytecodeCompiler.compileModules(environment, configuration, moduleScript.getModules(), directory, jar, arguments.includeRuntime)
}
else if (arguments.script) {
val scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size())
environment = createCoreEnvironment(rootDisposable, configuration)
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
KotlinToJVMBytecodeCompiler.compileAndExecuteScript(configuration, paths, environment, scriptArgs)
}
else {
environment = createCoreEnvironment(rootDisposable, configuration)
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) {
return COMPILATION_ERROR
}
if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR
if (environment.getSourceFiles().isEmpty()) {
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, "No source files", CompilerMessageLocation.NO_LOCATION)
@@ -85,11 +85,6 @@ public class KotlinToJVMBytecodeCompiler {
if (!source.isAbsolute()) {
source = new File(directory, sourceFile);
}
if (!source.exists()) {
throw new CompileEnvironmentException("'" + source + "' does not exist in module " + module.getModuleName());
}
result.add(source.getAbsolutePath());
}
return result;