Skip to content

Commit

Permalink
Preserve leading comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 13, 2023
1 parent 0357e24 commit 5238a69
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,9 @@ private Integer getCursor() {
* Consume the provided text if it matches the current cursor position.
*/
private void skip(String text) {
if (source.getText().startsWith(text, getCursor())) {
if (source.hasProperty("text") && source.getStringProperty("text").startsWith(text, getCursor())) {
cursor(getCursor() + text.length());
} else if (source.getText().startsWith(text, getCursor())) {
cursor(getCursor() + text.length());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void parseSourceTexts(Map<Path, String> sourceTexts, BiConsumer<TSCNode,
}

V8ValueObject sourceFileV8 = (V8ValueObject) maybeSourceFileV8;
String sourceText = sourceFileV8.invokeString("getText");
String sourceText = sourceFileV8.getPropertyString("text");
Path filePath = Paths.get(filePathV8.getValue());
try (TSCSourceFileContext sourceFileContext = new TSCSourceFileContext(programContext, sourceText, filePath)) {
TSCNode node = programContext.tscNode(sourceFileV8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.openrewrite.javascript.tree;

import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ExpectedToFail;

@SuppressWarnings("JSUnusedLocalSymbols")
class CommentTest extends ParserTest {
Expand Down Expand Up @@ -100,7 +99,6 @@ function f ( p1 , p2 ) {
);
}

@ExpectedToFail
@Test
void leadingComment() {
rewriteRun(
Expand Down

0 comments on commit 5238a69

Please sign in to comment.