From 2d4f261d407e6f80a8595714c36170de713843a3 Mon Sep 17 00:00:00 2001 From: traceyyoshima Date: Fri, 30 Jun 2023 12:05:19 -0600 Subject: [PATCH] Polish. Added missing import back in KotlinParser. Added styles to K.CU. --- src/main/java/org/openrewrite/kotlin/KotlinParser.java | 2 ++ .../openrewrite/kotlin/internal/KotlinParserVisitor.java | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openrewrite/kotlin/KotlinParser.java b/src/main/java/org/openrewrite/kotlin/KotlinParser.java index 76336e67a..9b1ed495d 100644 --- a/src/main/java/org/openrewrite/kotlin/KotlinParser.java +++ b/src/main/java/org/openrewrite/kotlin/KotlinParser.java @@ -65,6 +65,7 @@ import org.openrewrite.kotlin.internal.KotlinParserVisitor; import org.openrewrite.kotlin.tree.K; import org.openrewrite.style.NamedStyles; +import org.openrewrite.tree.ParseError; import org.openrewrite.tree.ParsingEventListener; import org.openrewrite.tree.ParsingExecutionContextView; @@ -168,6 +169,7 @@ public Stream parseInputs(Iterable sources, @Nullable Path re compiled.getInput().getRelativePath(relativeTo), compiled.getInput().getFileAttributes(), compiled.getInput().getSource(ctx), + styles, typeCache, firSession, ctx diff --git a/src/main/java/org/openrewrite/kotlin/internal/KotlinParserVisitor.java b/src/main/java/org/openrewrite/kotlin/internal/KotlinParserVisitor.java index f365672c9..596b8aa1c 100644 --- a/src/main/java/org/openrewrite/kotlin/internal/KotlinParserVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/internal/KotlinParserVisitor.java @@ -54,6 +54,7 @@ import org.openrewrite.kotlin.marker.*; import org.openrewrite.kotlin.tree.K; import org.openrewrite.marker.Markers; +import org.openrewrite.style.NamedStyles; import java.nio.charset.Charset; import java.nio.file.Path; @@ -79,6 +80,7 @@ public class KotlinParserVisitor extends FirDefaultVisitor private final String source; private final Charset charset; private final boolean charsetBomMarked; + private final List styles; private final KotlinTypeMapping typeMapping; private final ExecutionContext ctx; private final FirSession firSession; @@ -90,12 +92,13 @@ public class KotlinParserVisitor extends FirDefaultVisitor private static final Pattern whitespaceSuffixPattern = Pattern.compile("\\s*[^\\s]+(\\s*)"); - public KotlinParserVisitor(Path sourcePath, @Nullable FileAttributes fileAttributes, EncodingDetectingInputStream source, JavaTypeCache typeCache, FirSession firSession, ExecutionContext ctx) { + public KotlinParserVisitor(Path sourcePath, @Nullable FileAttributes fileAttributes, EncodingDetectingInputStream source, List styles, JavaTypeCache typeCache, FirSession firSession, ExecutionContext ctx) { this.sourcePath = sourcePath; this.fileAttributes = fileAttributes; this.source = source.readFully(); this.charset = source.getCharset(); this.charsetBomMarked = source.isCharsetBomMarked(); + this.styles = styles; this.typeMapping = new KotlinTypeMapping(typeCache, firSession); this.ctx = ctx; this.firSession = firSession; @@ -162,7 +165,7 @@ public J visitFile(FirFile file, ExecutionContext ctx) { return new K.CompilationUnit( randomId(), Space.EMPTY, - Markers.EMPTY, + Markers.build(styles), sourcePath, fileAttributes, charset.name(),