diff --git a/src/main/java/org/openrewrite/kotlin/KotlinParser.java b/src/main/java/org/openrewrite/kotlin/KotlinParser.java index 82694526f..c9e108960 100644 --- a/src/main/java/org/openrewrite/kotlin/KotlinParser.java +++ b/src/main/java/org/openrewrite/kotlin/KotlinParser.java @@ -173,7 +173,7 @@ public Stream parseInputs(Iterable sources, @Nullable Path re assert kotlinSource.getFirFile().getSource() != null; PsiElement psi = ((KtRealPsiSourceElement) kotlinSource.getFirFile().getSource()).getPsi(); AnalyzerWithCompilerReport.SyntaxErrorReport report = - AnalyzerWithCompilerReport.Companion.reportSyntaxErrors(psi, MessageCollector.Companion.getNONE()); + AnalyzerWithCompilerReport.Companion.reportSyntaxErrors(psi, new PrintingMessageCollector(System.err, PLAIN_FULL_PATHS, true)); if (report.isHasErrors()) { return ParseError.build(KotlinParser.this, kotlinSource.getInput(), relativeTo, ctx, new RuntimeException()); } diff --git a/src/test/java/org/openrewrite/kotlin/AssertionsTest.java b/src/test/java/org/openrewrite/kotlin/AssertionsTest.java index e5b2ccfc4..ddad7dbf2 100644 --- a/src/test/java/org/openrewrite/kotlin/AssertionsTest.java +++ b/src/test/java/org/openrewrite/kotlin/AssertionsTest.java @@ -15,6 +15,7 @@ */ package org.openrewrite.kotlin; +import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.ExpectedToFail; import org.openrewrite.ExecutionContext; @@ -61,11 +62,17 @@ class A { ); } + /** + * This test is expected to fail due to invalid syntax and exists to prevent a regression in the compiler configuration. + * {@link AnalyzerWithCompilerReport} is used to analyze the syntax in each source to produce a ParserError if a syntax + * error exists in the source code. + */ @ExpectedToFail @Test void invalidSyntax() { rewriteRun( kotlin( + //language=none """ a++ """