Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 2d4f261

Browse files
committed
Polish. Added missing import back in KotlinParser. Added styles to K.CU.
1 parent 946cc5c commit 2d4f261

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/org/openrewrite/kotlin/KotlinParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.openrewrite.kotlin.internal.KotlinParserVisitor;
6666
import org.openrewrite.kotlin.tree.K;
6767
import org.openrewrite.style.NamedStyles;
68+
import org.openrewrite.tree.ParseError;
6869
import org.openrewrite.tree.ParsingEventListener;
6970
import org.openrewrite.tree.ParsingExecutionContextView;
7071

@@ -168,6 +169,7 @@ public Stream<SourceFile> parseInputs(Iterable<Input> sources, @Nullable Path re
168169
compiled.getInput().getRelativePath(relativeTo),
169170
compiled.getInput().getFileAttributes(),
170171
compiled.getInput().getSource(ctx),
172+
styles,
171173
typeCache,
172174
firSession,
173175
ctx

src/main/java/org/openrewrite/kotlin/internal/KotlinParserVisitor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.openrewrite.kotlin.marker.*;
5555
import org.openrewrite.kotlin.tree.K;
5656
import org.openrewrite.marker.Markers;
57+
import org.openrewrite.style.NamedStyles;
5758

5859
import java.nio.charset.Charset;
5960
import java.nio.file.Path;
@@ -79,6 +80,7 @@ public class KotlinParserVisitor extends FirDefaultVisitor<J, ExecutionContext>
7980
private final String source;
8081
private final Charset charset;
8182
private final boolean charsetBomMarked;
83+
private final List<NamedStyles> styles;
8284
private final KotlinTypeMapping typeMapping;
8385
private final ExecutionContext ctx;
8486
private final FirSession firSession;
@@ -90,12 +92,13 @@ public class KotlinParserVisitor extends FirDefaultVisitor<J, ExecutionContext>
9092

9193
private static final Pattern whitespaceSuffixPattern = Pattern.compile("\\s*[^\\s]+(\\s*)");
9294

93-
public KotlinParserVisitor(Path sourcePath, @Nullable FileAttributes fileAttributes, EncodingDetectingInputStream source, JavaTypeCache typeCache, FirSession firSession, ExecutionContext ctx) {
95+
public KotlinParserVisitor(Path sourcePath, @Nullable FileAttributes fileAttributes, EncodingDetectingInputStream source, List<NamedStyles> styles, JavaTypeCache typeCache, FirSession firSession, ExecutionContext ctx) {
9496
this.sourcePath = sourcePath;
9597
this.fileAttributes = fileAttributes;
9698
this.source = source.readFully();
9799
this.charset = source.getCharset();
98100
this.charsetBomMarked = source.isCharsetBomMarked();
101+
this.styles = styles;
99102
this.typeMapping = new KotlinTypeMapping(typeCache, firSession);
100103
this.ctx = ctx;
101104
this.firSession = firSession;
@@ -162,7 +165,7 @@ public J visitFile(FirFile file, ExecutionContext ctx) {
162165
return new K.CompilationUnit(
163166
randomId(),
164167
Space.EMPTY,
165-
Markers.EMPTY,
168+
Markers.build(styles),
166169
sourcePath,
167170
fileAttributes,
168171
charset.name(),

0 commit comments

Comments
 (0)