Skip to content

Commit

Permalink
Polish. Added missing import back in KotlinParser. Added styles to K.CU.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Jun 30, 2023
1 parent 946cc5c commit 2d4f261
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/openrewrite/kotlin/KotlinParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -168,6 +169,7 @@ public Stream<SourceFile> parseInputs(Iterable<Input> sources, @Nullable Path re
compiled.getInput().getRelativePath(relativeTo),
compiled.getInput().getFileAttributes(),
compiled.getInput().getSource(ctx),
styles,
typeCache,
firSession,
ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -79,6 +80,7 @@ public class KotlinParserVisitor extends FirDefaultVisitor<J, ExecutionContext>
private final String source;
private final Charset charset;
private final boolean charsetBomMarked;
private final List<NamedStyles> styles;
private final KotlinTypeMapping typeMapping;
private final ExecutionContext ctx;
private final FirSession firSession;
Expand All @@ -90,12 +92,13 @@ public class KotlinParserVisitor extends FirDefaultVisitor<J, ExecutionContext>

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<NamedStyles> 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;
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 2d4f261

Please sign in to comment.