diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageRenderer.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageRenderer.java index bcb395bff8c..281dd5d4615 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageRenderer.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/messages/MessageRenderer.java @@ -17,10 +17,11 @@ package org.jetbrains.jet.cli.common.messages; import com.intellij.openapi.util.text.StringUtil; +import kotlin.io.IoPackage; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.File; public interface MessageRenderer { @@ -57,24 +58,48 @@ public interface MessageRenderer { } }; - MessageRenderer PLAIN = new MessageRenderer() { + MessageRenderer PLAIN = new PlainText() { + @Nullable + @Override + protected String getPath(@NotNull CompilerMessageLocation location) { + return location.getPath(); + } + }; + + MessageRenderer PLAIN_WITH_RELATIVE_PATH = new PlainText() { + private final File cwd = new File(".").getAbsoluteFile(); + + @Nullable + @Override + protected String getPath(@NotNull CompilerMessageLocation location) { + String path = location.getPath(); + return cwd == null || path == null ? path : IoPackage.relativePath(cwd, new File(path)); + } + }; + + abstract class PlainText implements MessageRenderer { @Override public String renderPreamble() { return ""; } @Override - public String render(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location) { - String path = location.getPath(); + public String render( + @NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location + ) { + String path = getPath(location); String position = path == null ? "" : path + ": (" + (location.getLine() + ", " + location.getColumn()) + ") "; return severity + ": " + position + message; } + @Nullable + protected abstract String getPath(@NotNull CompilerMessageLocation location); + @Override public String renderConclusion() { return ""; } - }; + } String renderPreamble(); String render(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location); diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java index 12bfcd8fe42..15752783cb8 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java @@ -34,7 +34,6 @@ import java.util.List; import static org.jetbrains.jet.cli.common.ExitCode.*; public abstract class CLICompiler { - @NotNull private List compilerPlugins = Lists.newArrayList(); @@ -49,7 +48,7 @@ public abstract class CLICompiler { @NotNull public ExitCode exec(@NotNull PrintStream errStream, @NotNull String... args) { - return exec(errStream, MessageRenderer.PLAIN, args); + return exec(errStream, MessageRenderer.PLAIN_WITH_RELATIVE_PATH, args); } @SuppressWarnings("UnusedDeclaration") // Used via reflection in CompilerRunnerUtil#invokeExecMethod diff --git a/compiler/integration-tests/testData/smoke/compilationFailed/hello.compile.expected b/compiler/integration-tests/testData/smoke/compilationFailed/hello.compile.expected index bced8604933..918457b2ff1 100644 --- a/compiler/integration-tests/testData/smoke/compilationFailed/hello.compile.expected +++ b/compiler/integration-tests/testData/smoke/compilationFailed/hello.compile.expected @@ -1,5 +1,5 @@ ERR: -ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a +ERROR: hello.kt: (4, 5) Unresolved reference: a Return code: 1 diff --git a/compiler/integration-tests/testData/smoke/syntaxErrors/test.compile.expected b/compiler/integration-tests/testData/smoke/syntaxErrors/test.compile.expected index 8878148bf50..9e491e21bf7 100644 --- a/compiler/integration-tests/testData/smoke/syntaxErrors/test.compile.expected +++ b/compiler/integration-tests/testData/smoke/syntaxErrors/test.compile.expected @@ -1,5 +1,5 @@ ERR: -ERROR: [TestData]/test.kt: (4, 20) Expecting an element +ERROR: test.kt: (4, 20) Expecting an element Return code: 1 diff --git a/compiler/testData/cli/jvm/classpath.out b/compiler/testData/cli/jvm/classpath.out index 1faf98166d8..c86a967e06b 100644 --- a/compiler/testData/cli/jvm/classpath.out +++ b/compiler/testData/cli/jvm/classpath.out @@ -1,6 +1,6 @@ -WARNING: $TESTDATA_DIR$/classpath.kt: (8, 9) Variable 'a' is never used -WARNING: $TESTDATA_DIR$/classpath.kt: (9, 9) Variable 'c' is never used -WARNING: $TESTDATA_DIR$/classpath.kt: (10, 9) Variable 'e' is never used -WARNING: $TESTDATA_DIR$/classpath.kt: (11, 9) Variable 'f' is never used -WARNING: $TESTDATA_DIR$/classpath.kt: (12, 9) Variable 'j' is never used +WARNING: compiler/testData/cli/jvm/classpath.kt: (8, 9) Variable 'a' is never used +WARNING: compiler/testData/cli/jvm/classpath.kt: (9, 9) Variable 'c' is never used +WARNING: compiler/testData/cli/jvm/classpath.kt: (10, 9) Variable 'e' is never used +WARNING: compiler/testData/cli/jvm/classpath.kt: (11, 9) Variable 'f' is never used +WARNING: compiler/testData/cli/jvm/classpath.kt: (12, 9) Variable 'j' is never used OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/conflictingOverloads.out b/compiler/testData/cli/jvm/conflictingOverloads.out index c48cc2270f0..06500d6a3bd 100644 --- a/compiler/testData/cli/jvm/conflictingOverloads.out +++ b/compiler/testData/cli/jvm/conflictingOverloads.out @@ -1,3 +1,3 @@ -ERROR: $TESTDATA_DIR$/conflictingOverloads.kt: (1, 1) 'internal fun a(): kotlin.List' is already defined in root package -ERROR: $TESTDATA_DIR$/conflictingOverloads.kt: (2, 1) 'internal fun a(): kotlin.List' is already defined in root package +ERROR: compiler/testData/cli/jvm/conflictingOverloads.kt: (1, 1) 'internal fun a(): kotlin.List' is already defined in root package +ERROR: compiler/testData/cli/jvm/conflictingOverloads.kt: (2, 1) 'internal fun a(): kotlin.List' is already defined in root package COMPILATION_ERROR \ No newline at end of file diff --git a/compiler/testData/cli/jvm/diagnosticsOrder.out b/compiler/testData/cli/jvm/diagnosticsOrder.out index e26af3e886c..9e432583a62 100644 --- a/compiler/testData/cli/jvm/diagnosticsOrder.out +++ b/compiler/testData/cli/jvm/diagnosticsOrder.out @@ -1,10 +1,10 @@ -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (1, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (2, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (3, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (4, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (5, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (6, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder1.kt: (7, 5) Redeclaration: x -ERROR: $TESTDATA_DIR$/diagnosticsOrder2.kt: (1, 5) Redeclaration: y -ERROR: $TESTDATA_DIR$/diagnosticsOrder2.kt: (2, 5) Redeclaration: y +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (1, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (2, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (3, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (4, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (5, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (6, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (7, 5) Redeclaration: x +ERROR: compiler/testData/cli/jvm/diagnosticsOrder2.kt: (1, 5) Redeclaration: y +ERROR: compiler/testData/cli/jvm/diagnosticsOrder2.kt: (2, 5) Redeclaration: y COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out index f59519a0ecf..9e6cd1d34db 100644 --- a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out +++ b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out @@ -1,4 +1,4 @@ -ERROR: $TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Cannot weaken access privilege 'public' for 'c' in 'A' -ERROR: $TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Incompatible modifiers: 'private protected' -ERROR: $TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt: (6, 24) Incompatible modifiers: 'private protected' +ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Cannot weaken access privilege 'public' for 'c' in 'A' +ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Incompatible modifiers: 'private protected' +ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 24) Incompatible modifiers: 'private protected' COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/signatureClash.out b/compiler/testData/cli/jvm/signatureClash.out index 44c4829597f..26d449d589e 100644 --- a/compiler/testData/cli/jvm/signatureClash.out +++ b/compiler/testData/cli/jvm/signatureClash.out @@ -1,29 +1,29 @@ -WARNING: $TESTDATA_DIR$/signatureClash.kt: (26, 17) Parameter 'c' is never used -ERROR: $TESTDATA_DIR$/signatureClash.kt: (6, 5) Accidental override: The following declarations have the same JVM signature (getX()I): +WARNING: compiler/testData/cli/jvm/signatureClash.kt: (26, 17) Parameter 'c' is never used +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (6, 5) Accidental override: The following declarations have the same JVM signature (getX()I): fun getX(): kotlin.Int fun (): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (8, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (8, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): fun getA(): kotlin.Int fun (): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (9, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (9, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): fun getA(): kotlin.Int fun (): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (12, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (12, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): fun (): kotlin.Int fun getB(): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (13, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (13, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): fun (): kotlin.Int fun getB(): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (16, 5) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (16, 5) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): fun (): kotlin.Int fun getTr(): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (20, 5) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (20, 5) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): fun (): kotlin.Int fun getTr(): kotlin.Int -ERROR: $TESTDATA_DIR$/signatureClash.kt: (24, 7) Platform declaration clash: The following declarations have the same JVM signature (f$b$0(LC;)V): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (24, 7) Platform declaration clash: The following declarations have the same JVM signature (f$b$0(LC;)V): fun f$b$0(c: C): kotlin.Unit fun f(): kotlin.Unit -ERROR: $TESTDATA_DIR$/signatureClash.kt: (26, 5) Platform declaration clash: The following declarations have the same JVM signature (f$b$0(LC;)V): +ERROR: compiler/testData/cli/jvm/signatureClash.kt: (26, 5) Platform declaration clash: The following declarations have the same JVM signature (f$b$0(LC;)V): fun f$b$0(c: C): kotlin.Unit fun f(): kotlin.Unit COMPILATION_ERROR \ No newline at end of file diff --git a/compiler/testData/cli/jvm/wrongAbiVersion.out b/compiler/testData/cli/jvm/wrongAbiVersion.out index 08c94b49d1f..a3fa7102b1c 100644 --- a/compiler/testData/cli/jvm/wrongAbiVersion.out +++ b/compiler/testData/cli/jvm/wrongAbiVersion.out @@ -1,5 +1,5 @@ -ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/ClassWithWrongAbiVersion.class: (0, 0) Class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ -ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/wrong/WrongPackage.class: (0, 0) Class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ -WARNING: $TESTDATA_DIR$/wrongAbiVersion.kt: (3, 9) Parameter 'x' is never used -ERROR: $TESTDATA_DIR$/wrongAbiVersion.kt: (4, 3) Unresolved reference: bar +ERROR: compiler/testData/cli/jvm/wrongAbiVersionLib/ClassWithWrongAbiVersion.class: (0, 0) Class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ +ERROR: compiler/testData/cli/jvm/wrongAbiVersionLib/wrong/WrongPackage.class: (0, 0) Class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ +WARNING: compiler/testData/cli/jvm/wrongAbiVersion.kt: (3, 9) Parameter 'x' is never used +ERROR: compiler/testData/cli/jvm/wrongAbiVersion.kt: (4, 3) Unresolved reference: bar COMPILATION_ERROR \ No newline at end of file