diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java index c301de030a4..abba156db1f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java @@ -38,6 +38,7 @@ public class ClassFileFactory { } ClassBuilder newVisitor(String filePath) { + state.getProgress().log("Emitting: " + filePath); final ClassBuilder answer = builderFactory.newClassBuilder(); generators.put(filePath, answer); return answer; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java index 91068ab67de..af08c69cac9 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -31,8 +31,8 @@ import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; -import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Type; @@ -128,7 +128,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen { funClass, new String[0] ); - cv.visitSource(state.transformFileName(fun.getContainingFile().getName()), null); + cv.visitSource(fun.getContainingFile().getName(), null); generateBridge(name, funDescriptor, fun, cv); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java index 5cfb8b6ba57..3ba126291e3 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java @@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; +import org.jetbrains.jet.utils.Progress; import java.util.Collections; import java.util.List; @@ -51,9 +52,15 @@ public class GenerationState { private final Stack bindingContexts = new Stack(); private final JetStandardLibrary standardLibrary; private final IntrinsicMethods intrinsics; + private final Progress progress; public GenerationState(Project project, ClassBuilderFactory builderFactory) { + this(project, builderFactory, Progress.DEAF); + } + + public GenerationState(Project project, ClassBuilderFactory builderFactory, Progress progress) { this.project = project; + this.progress = progress; this.standardLibrary = JetStandardLibrary.getInstance(); this.factory = new ClassFileFactory(builderFactory, this); this.intrinsics = new IntrinsicMethods(project, standardLibrary); @@ -64,6 +71,10 @@ public class GenerationState { return factory; } + public Progress getProgress() { + return progress; + } + public Project getProject() { return project; } @@ -133,14 +144,15 @@ public class GenerationState { typeMapper = new JetTypeMapper(standardLibrary, bindingContext, closureAnnotator); bindingContexts.push(bindingContext); try { - for (JetFile namespace : files) { - if (namespace == null) throw new IllegalArgumentException("A null file given for compilation"); + for (JetFile file : files) { + if (file == null) throw new IllegalArgumentException("A null file given for compilation"); + VirtualFile vFile = file.getVirtualFile(); + progress.log("For source: " + vFile.getPath()); try { - generateNamespace(namespace); + generateNamespace(file); } catch (Throwable e) { - VirtualFile virtualFile = namespace.getContainingFile().getVirtualFile(); - errorHandler.reportException(e, virtualFile == null ? "no file" : virtualFile.getUrl()); + errorHandler.reportException(e, vFile == null ? "no file" : vFile.getUrl()); DiagnosticUtils.throwIfRunningOnServer(e); if (ApplicationManager.getApplication().isInternal()) { e.printStackTrace(); @@ -188,9 +200,4 @@ public class GenerationState { return answer.toString(); } - - @NotNull - public String transformFileName(@NotNull String fileName) { - return fileName; - } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 446762aac84..d1cdde50073 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -21,12 +21,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.codegen.signature.BothSignatureWriter; -import org.jetbrains.jet.codegen.signature.JvmClassSignature; -import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind; -import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature; -import org.jetbrains.jet.codegen.signature.JvmMethodSignature; -import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature; +import org.jetbrains.jet.codegen.signature.*; import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWriter; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; @@ -115,7 +110,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { signature.getSuperclassName(), signature.getInterfaces().toArray(new String[0]) ); - v.visitSource(state.transformFileName(myClass.getContainingFile().getName()), null); + v.visitSource(myClass.getContainingFile().getName(), null); ClassDescriptor container = getContainingClassDescriptor(descriptor); if(container != null) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java index e2aafb25ed7..ca2fe73e250 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java @@ -51,7 +51,7 @@ public class NamespaceCodegen { new String[0] ); // TODO figure something out for a namespace that spans multiple files - v.visitSource(state.transformFileName(sourceFile.getName()), null); + v.visitSource(sourceFile.getName(), null); } public void generate(JetFile file) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java index 904875cc4d0..3ebe94c13c0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java @@ -21,8 +21,8 @@ import com.intellij.psi.PsiElement; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.objectweb.asm.Opcodes; import java.util.List; @@ -70,7 +70,7 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen { "java/lang/Object", new String[0] ); - v.visitSource(state.transformFileName(myClass.getContainingFile().getName()), null); + v.visitSource(myClass.getContainingFile().getName(), null); } private String jvmName() { diff --git a/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java b/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java index 46884482d80..6aceae7ea6c 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java @@ -56,6 +56,9 @@ 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 = "verbose", description = "Enable verbose logging output") + public boolean verbose; + public String getClasspath() { return classpath; diff --git a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java index 57434101076..cb740def484 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java @@ -73,7 +73,7 @@ public class KotlinCompiler { System.setProperty("java.awt.headless", "true"); MessageRenderer messageRenderer = arguments.tags ? MessageRenderer.TAGS : MessageRenderer.PLAIN; - CompileEnvironment environment = new CompileEnvironment(messageRenderer); + CompileEnvironment environment = new CompileEnvironment(messageRenderer, arguments.verbose); try { configureEnvironment(environment, arguments, errStream); diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java b/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java index e5441b3bfa8..a92578a240e 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java @@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.FqName; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.plugin.JetLanguage; import org.jetbrains.jet.plugin.JetMainDetector; -import org.jetbrains.jet.plugin.compiler.PathUtil; +import org.jetbrains.jet.utils.PathUtil; import java.io.*; import java.lang.reflect.Method; @@ -63,12 +63,14 @@ public class CompileEnvironment { private boolean ignoreErrors = false; private boolean stubs = false; + private final boolean verbose; public CompileEnvironment() { - this(MessageRenderer.PLAIN); + this(MessageRenderer.PLAIN, false); } - public CompileEnvironment(MessageRenderer messageRenderer) { + public CompileEnvironment(MessageRenderer messageRenderer, boolean verbose) { + this.verbose = verbose; myRootDisposable = new Disposable() { @Override public void dispose() { @@ -179,7 +181,7 @@ public class CompileEnvironment { final String directory = new File(moduleScriptFile).getParent(); for (Module moduleBuilder : modules) { - CompileEnvironment compileEnvironment = new CompileEnvironment(myMessageRenderer); + CompileEnvironment compileEnvironment = new CompileEnvironment(myMessageRenderer, verbose); compileEnvironment.setIgnoreErrors(ignoreErrors); compileEnvironment.setErrorStream(myErrorStream); // copy across any compiler plugins @@ -204,11 +206,11 @@ public class CompileEnvironment { } public List loadModuleScript(String moduleFile) { - CompileSession scriptCompileSession = new CompileSession(myEnvironment); + CompileSession scriptCompileSession = newCompileSession(); scriptCompileSession.addSources(moduleFile); ensureRuntime(); - if (!scriptCompileSession.analyze(myErrorStream, myMessageRenderer)) { + if (!scriptCompileSession.analyze()) { return null; } final ClassFileFactory factory = scriptCompileSession.generate(true); @@ -242,7 +244,7 @@ public class CompileEnvironment { } public ClassFileFactory compileModule(Module moduleBuilder, String directory) { - CompileSession moduleCompileSession = new CompileSession(myEnvironment); + CompileSession moduleCompileSession = newCompileSession(); moduleCompileSession.setStubs(stubs); if (moduleBuilder.getSourceFiles().isEmpty()) { @@ -267,7 +269,7 @@ public class CompileEnvironment { ensureRuntime(); - if (!moduleCompileSession.analyze(myErrorStream, myMessageRenderer) && !ignoreErrors) { + if (!moduleCompileSession.analyze() && !ignoreErrors) { return null; } return moduleCompileSession.generate(false); @@ -351,10 +353,10 @@ public class CompileEnvironment { } public ClassLoader compileText(String code) { - CompileSession session = new CompileSession(myEnvironment); + CompileSession session = newCompileSession(); session.addSources(new LightVirtualFile("script" + LocalTimeCounter.currentTime() + ".kt", JetLanguage.INSTANCE, code)); - if (!session.analyze(myErrorStream, myMessageRenderer) && !ignoreErrors) { + if (!session.analyze() && !ignoreErrors) { return null; } @@ -363,7 +365,7 @@ public class CompileEnvironment { } public boolean compileBunchOfSources(String sourceFileOrDir, String jar, String outputDir, boolean includeRuntime) { - CompileSession session = new CompileSession(myEnvironment); + CompileSession session = newCompileSession(); session.setStubs(stubs); session.addSources(sourceFileOrDir); @@ -379,7 +381,7 @@ public class CompileEnvironment { ensureRuntime(); - if (!session.analyze(myErrorStream, myMessageRenderer) && !ignoreErrors) { + if (!session.analyze() && !ignoreErrors) { return false; } @@ -400,6 +402,10 @@ public class CompileEnvironment { return true; } + private CompileSession newCompileSession() { + return new CompileSession(myEnvironment, myMessageRenderer, myErrorStream, verbose); + } + public static void writeToOutputDirectory(ClassFileFactory factory, final String outputDir) { List files = factory.files(); for (String file : files) { diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java index 9e67675a583..2c34047a07c 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java @@ -41,6 +41,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.plugin.JetFileType; +import org.jetbrains.jet.utils.Progress; import java.io.File; import java.io.PrintStream; @@ -55,9 +56,13 @@ import java.util.List; */ public class CompileSession { private final JetCoreEnvironment myEnvironment; + private final MessageCollector myMessageCollector; private final List mySourceFiles = new ArrayList(); private List myErrors = new ArrayList(); private boolean stubs = false; + private final MessageRenderer myMessageRenderer; + private final PrintStream myErrorStream; + private final boolean myIsVerbose; public BindingContext getMyBindingContext() { return myBindingContext; @@ -65,8 +70,12 @@ public class CompileSession { private BindingContext myBindingContext; - public CompileSession(JetCoreEnvironment environment) { + public CompileSession(JetCoreEnvironment environment, MessageRenderer messageRenderer, PrintStream errorStream, boolean verbose) { myEnvironment = environment; + myMessageRenderer = messageRenderer; + myErrorStream = errorStream; + myIsVerbose = verbose; + myMessageCollector = new MessageCollector(myMessageRenderer); } public void setStubs(boolean stubs) { @@ -130,19 +139,17 @@ public class CompileSession { return mySourceFiles; } - public boolean analyze(@NotNull PrintStream out, @NotNull MessageRenderer renderer) { - MessageCollector collector = new MessageCollector(renderer); - + public boolean analyze() { for (String error : myErrors) { - collector.report(Severity.ERROR, error, null, -1, -1); + myMessageCollector.report(Severity.ERROR, error, null, -1, -1); } - reportSyntaxErrors(collector); - analyzeAndReportSemanticErrors(collector); + reportSyntaxErrors(); + analyzeAndReportSemanticErrors(); - collector.printTo(out); + myMessageCollector.printTo(myErrorStream); - return !collector.hasErrors(); + return !myMessageCollector.hasErrors(); } /** @@ -158,17 +165,17 @@ public class CompileSession { } } - private void analyzeAndReportSemanticErrors(MessageCollector collector) { + private void analyzeAndReportSemanticErrors() { Predicate filesToAnalyzeCompletely = stubs ? Predicates.alwaysFalse() : Predicates.alwaysTrue(); myBindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration( myEnvironment.getProject(), mySourceFiles, filesToAnalyzeCompletely, JetControlFlowDataTraceFactory.EMPTY); for (Diagnostic diagnostic : myBindingContext.getDiagnostics()) { - reportDiagnostic(collector, diagnostic); + reportDiagnostic(myMessageCollector, diagnostic); } - reportIncompleteHierarchies(collector); + reportIncompleteHierarchies(myMessageCollector); } private void reportIncompleteHierarchies(MessageCollector collector) { @@ -182,7 +189,7 @@ public class CompileSession { } } - private void reportSyntaxErrors(final MessageCollector messageCollector) { + private void reportSyntaxErrors() { for (JetFile file : mySourceFiles) { file.accept(new PsiRecursiveElementWalkingVisitor() { @Override @@ -190,7 +197,7 @@ public class CompileSession { String description = element.getErrorDescription(); String message = StringUtil.isEmpty(description) ? "Syntax error" : description; Diagnostic diagnostic = DiagnosticFactory.create(Severity.ERROR, message).on(element); - reportDiagnostic(messageCollector, diagnostic); + reportDiagnostic(myMessageCollector, diagnostic); } }); } @@ -206,7 +213,7 @@ public class CompileSession { @NotNull public ClassFileFactory generate(boolean module) { Project project = myEnvironment.getProject(); - GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs)); + GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), myIsVerbose ? new BackendProgress() : Progress.DEAF); generationState.compileCorrectFiles(myBindingContext, mySourceFiles, CompilationErrorHandler.THROW_EXCEPTION, true); ClassFileFactory answer = generationState.getFactory(); @@ -220,4 +227,11 @@ public class CompileSession { } return answer; } + + private class BackendProgress implements Progress { + @Override + public void log(String message) { + myErrorStream.println(myMessageRenderer.render(Severity.LOGGING, message, null, -1, -1)); + } + } } diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/JetCoreEnvironment.java b/compiler/cli/src/org/jetbrains/jet/compiler/JetCoreEnvironment.java index 7a887f58351..3b2775fd8a1 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/JetCoreEnvironment.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/JetCoreEnvironment.java @@ -24,7 +24,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.jet.lang.parsing.JetParserDefinition; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; import org.jetbrains.jet.plugin.JetFileType; -import org.jetbrains.jet.plugin.compiler.PathUtil; +import org.jetbrains.jet.utils.PathUtil; import java.io.File; import java.net.URL; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.java index ad81c3ac7cf..bf66e2f6384 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/alt/AltClassFinder.java @@ -26,7 +26,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.FqName; -import org.jetbrains.jet.plugin.compiler.PathUtil; +import org.jetbrains.jet.utils.PathUtil; import java.util.List; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Severity.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Severity.java index 654da08f2f7..47386211b6e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Severity.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Severity.java @@ -20,6 +20,7 @@ package org.jetbrains.jet.lang.diagnostics; * @author abreslav */ public enum Severity { + LOGGING, INFO, ERROR, WARNING diff --git a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java index 6e8f3d3cfb5..c0852b71004 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java @@ -69,7 +69,7 @@ public class TestlibTest extends CodegenTestCase { private TestSuite doBuildSuite() { try { - CompileSession session = new CompileSession(myEnvironment); + CompileSession session = new CompileSession(myEnvironment, MessageRenderer.PLAIN, System.err, false); myEnvironment.addToClasspath(ForTestCompileStdlib.stdlibJarForTests()); @@ -85,7 +85,7 @@ public class TestlibTest extends CodegenTestCase { session.addSources(localFileSystem.findFileByPath(JetParsingTest.getTestDataDir() + "/../../libraries/stdlib/test")); session.addSources(localFileSystem.findFileByPath(JetParsingTest.getTestDataDir() + "/../../libraries/kunit/src")); - if (!session.analyze(System.err, MessageRenderer.PLAIN)) { + if (!session.analyze()) { throw new RuntimeException("There were compilation errors"); } diff --git a/compiler/util/src/org/jetbrains/jet/plugin/compiler/PathUtil.java b/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java similarity index 98% rename from compiler/util/src/org/jetbrains/jet/plugin/compiler/PathUtil.java rename to compiler/util/src/org/jetbrains/jet/utils/PathUtil.java index 0d4625a9e5f..01e5077daff 100644 --- a/compiler/util/src/org/jetbrains/jet/plugin/compiler/PathUtil.java +++ b/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java @@ -17,7 +17,7 @@ /* * @author max */ -package org.jetbrains.jet.plugin.compiler; +package org.jetbrains.jet.utils; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.vfs.VirtualFile; diff --git a/compiler/util/src/org/jetbrains/jet/utils/Progress.java b/compiler/util/src/org/jetbrains/jet/utils/Progress.java new file mode 100644 index 00000000000..0aee7fa48d8 --- /dev/null +++ b/compiler/util/src/org/jetbrains/jet/utils/Progress.java @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * @author max + */ +package org.jetbrains.jet.utils; + +public interface Progress { + Progress DEAF = new Progress() { + @Override + public void log(String message) { + } + }; + void log(String message); +} diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java index 028d359877a..a1ae12fb9b3 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java @@ -42,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.diagnostics.Severity; import org.jetbrains.jet.plugin.JetFileType; +import org.jetbrains.jet.utils.PathUtil; import java.io.*; import java.lang.ref.SoftReference; @@ -262,7 +263,7 @@ public class JetCompiler implements TranslatingCompiler { Class kompiler = Class.forName(compilerClassName, true, loader); Method exec = kompiler.getDeclaredMethod("exec", PrintStream.class, String[].class); - String[] arguments = { "-module", scriptFile.getAbsolutePath(), "-output", path(outputDir), "-tags" }; + String[] arguments = { "-module", scriptFile.getAbsolutePath(), "-output", path(outputDir), "-tags", "-verbose" }; context.addMessage(INFORMATION, "Using kotlinHome=" + kotlinHome, "", -1, -1); context.addMessage(INFORMATION, "Invoking in-process compiler " + compilerClassName + " with arguments " + Arrays.asList(arguments), "", -1, -1); @@ -312,6 +313,7 @@ public class JetCompiler implements TranslatingCompiler { params.getProgramParametersList().add("-module", scriptFile.getAbsolutePath()); params.getProgramParametersList().add("-output", path(outputDir)); params.getProgramParametersList().add("-tags"); + params.getProgramParametersList().add("-verbose"); for (File jar : kompilerClasspath(kotlinHome, compileContext)) { params.getClassPath().add(jar); @@ -383,10 +385,10 @@ public class JetCompiler implements TranslatingCompiler { } private static class CompilerProcessListener extends ProcessAdapter { - private static final Pattern DIAGNOSTIC_PATTERN = Pattern.compile("<(ERROR|WARNING|INFO|EXCEPTION)", Pattern.MULTILINE); + private static final Pattern DIAGNOSTIC_PATTERN = Pattern.compile("<(ERROR|WARNING|INFO|EXCEPTION|LOGGING)", Pattern.MULTILINE); private static final Pattern OPEN_TAG_END_PATTERN = Pattern.compile(">", Pattern.MULTILINE | Pattern.DOTALL); private static final Pattern ATTRIBUTE_PATTERN = Pattern.compile("\\s*(path|line|column)\\s*=\\s*\"(.*?)\"", Pattern.MULTILINE | Pattern.DOTALL); - private static final Pattern MESSAGE_PATTERN = Pattern.compile("(.*?)", Pattern.MULTILINE | Pattern.DOTALL); + private static final Pattern MESSAGE_PATTERN = Pattern.compile("(.*?)", Pattern.MULTILINE | Pattern.DOTALL); private enum State { WAITING, ATTRIBUTES, MESSAGE @@ -409,6 +411,9 @@ public class JetCompiler implements TranslatingCompiler { else if (Severity.WARNING.toString().equals(tagName)) { messageCategory = WARNING; } + else if (Severity.LOGGING.toString().equals(tagName)) { + messageCategory = STATISTICS; + } else { messageCategory = INFORMATION; } @@ -441,9 +446,17 @@ public class JetCompiler implements TranslatingCompiler { } public void reportTo(CompileContext compileContext) { - compileContext.addMessage(messageCategory, message, url == null ? "" : url, line == null ? -1 : line, column == null ? -1 : column); - if (isException) { - LOG.error(message); + if (messageCategory == STATISTICS) { + compileContext.getProgressIndicator().setText(message); + } + else { + compileContext.addMessage(messageCategory, message, url == null ? "" : url, line == null ? -1 : line, + column == null + ? -1 + : column); + if (isException) { + LOG.error(message); + } } } } diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ConfigureKotlinLibraryNotificationProvider.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ConfigureKotlinLibraryNotificationProvider.java index 0a8701f4ab3..95825aa0b34 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ConfigureKotlinLibraryNotificationProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ConfigureKotlinLibraryNotificationProvider.java @@ -50,7 +50,7 @@ import com.intellij.ui.EditorNotificationPanel; import com.intellij.ui.EditorNotifications; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.plugin.JetFileType; -import org.jetbrains.jet.plugin.compiler.PathUtil; +import org.jetbrains.jet.utils.PathUtil; import javax.swing.*; import java.io.File;