Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ function handleMemberChainComments(commentNode: CommentNode) {
) {
util.addLeadingComment(enclosingNode, commentNode);
return true;
} else if (
followingNode &&
isMember(followingNode) &&
precedingNode !== enclosingNode &&
!isPrettierIgnore(commentNode)
) {
util.addDanglingComment(followingNode, commentNode, undefined);
return true;
}
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit-test/member_chain/_input.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,10 @@ void methodReferences() {
dtoEntities.stream().map(UserDto::toString).forEach(LOGGER::info);
}

void fieldAccessArgumentComment() {
a(
// comment
b.c
);
}
}
7 changes: 7 additions & 0 deletions test/unit-test/member_chain/_output.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,11 @@ public void multipleInvocationsOnNewExpression() {
void methodReferences() {
dtoEntities.stream().map(UserDto::toString).forEach(LOGGER::info);
}

void fieldAccessArgumentComment() {
a(
// comment
b.c
);
}
}
6 changes: 3 additions & 3 deletions test/unit-test/template-expression/_output.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class TemplateExpression {
file.exists() ? "does" : "does not"
} exist";

String time = STR."The time is \{DateTimeFormatter.ofPattern("HH:mm:ss")
// The java.time.format package is very useful
.format(LocalTime.now())} right now";
String time =
STR."The time is \{// The java.time.format package is very useful
DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalTime.now())} right now";

String data = STR."\{index++}, \{index++}, \{index++}, \{index++}";

Expand Down