Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add smithy-syntax package and smithy format command #1830

Merged
merged 19 commits into from
Jun 19, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Attempt to fix windows issues
  • Loading branch information
mtdowling committed Jun 16, 2023
commit abe9e5cc8be753c763446206aa564eef7fbc29a2
Original file line number Diff line number Diff line change
@@ -59,7 +59,16 @@ public IdlToken next() {
docStart = start + 3;
}

docCommentLines.add(getModel(docStart, getCurrentTokenEnd()));
// Strip the \n and \r\n from the end.
int end = getCurrentTokenEnd();
if (model.charAt(end - 1) == '\n') {
end--;
if (end >= 0 && model.charAt(end - 1) == '\r') {
end--;
}
}

docCommentLines.add(getModel(docStart, end));
}

return token;
@@ -158,14 +167,10 @@ String removePendingDocCommentLines() {
} else {
StringBuilder result = new StringBuilder();
while (!docCommentLines.isEmpty()) {
result.append(docCommentLines.removeFirst());
}
if (result.charAt(result.length() - 1) == '\n') {
result.setLength(result.length() - 1);
}
if (result.charAt(result.length() - 1) == '\r') {
result.setLength(result.length() - 1);
result.append(docCommentLines.removeFirst()).append("\n");
}
// Strip ending \n.
result.setLength(result.length() - 1);
return result.toString();
}
}
Original file line number Diff line number Diff line change
@@ -173,7 +173,10 @@ public void handlesMultilineDocComments() {
.unwrap();

Shape shape = model.expectShape(ShapeId.from("smithy.example#MyStruct$myMember"));
String docs = shape.getTrait(DocumentationTrait.class).map(StringTrait::getValue).orElse("");
String docs = shape.getTrait(DocumentationTrait.class)
.map(StringTrait::getValue)
.orElse("")
.replace("\r\n", "\n");

assertThat(docs, equalTo("This is the first line.\nThis is the second line."));
}