Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Improved line spacing for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Sep 9, 2024
1 parent c5e40e5 commit 54b3424
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jaclang/compiler/passes/tool/jac_formatter_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,16 @@ def exit_sub_node_list(self, node: ast.SubNodeList) -> None:
and isinstance(prev_token.kid[-1], ast.SubNodeList)
and isinstance(prev_token.kid[-1].kid[-1], ast.CommentToken)
):
self.emit(node, "")
if (
prev_token
and stmt.loc.first_line - prev_token.kid[-1].kid[-1].line_no
> 1
):
self.indent_level -= 1
self.emit_ln(node, "")
self.indent_level += 1
else:
self.emit(node, "")
else:
self.indent_level -= 1
self.emit_ln(node, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import:py math;
glob RAD = 5;
glob DIA = 10;

# this comment is for walker
walker decorator_walk {
can hash(func: Any) {
can inner(a: Any) {
Expand Down Expand Up @@ -36,12 +37,16 @@ walker decorator_walk {
}

# Entry point for the walker

can start with entry {
# Apply decorators to greeter
decorated_greeter = hash(exclaim(tilde(greeter)));

# Call the decorated greeter function
decorated_greeter("World");

# this is another comment

}
}

Expand Down

0 comments on commit 54b3424

Please sign in to comment.