Skip to content

Commit

Permalink
Refactor line break logic in JacFormatPass
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Jan 7, 2025
1 parent f53efae commit 62f8bd7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion jac/jaclang/compiler/passes/tool/jac_formatter_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,8 @@ def exit_bool_expr(self, node: ast.BoolExpr) -> None:
test_str += f" {node.op.value} "

# Check if line break is needed
if self.is_line_break_needed(test_str):
adjusted_line_length = self.MAX_LINE_LENGTH * 2 - self.indent_size * 2
if self.is_line_break_needed(test_str, max_line_length=adjusted_line_length):
for i in node.values:
if i != end:
self.emit_ln(node, f"{i.gen.jac}")
Expand Down
3 changes: 1 addition & 2 deletions jac/jaclang/compiler/passes/tool/tests/fixtures/corelib.jac
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ obj JacPlugin {
:obj:Memory:can:get_obj
(caller_id: UUID, item_id: UUID, override: bool=False) -> Element {
ret = item_id |> self.index.get;
if override
or (ret is not None and caller_id |> ret.__is_readable) {
if override or (ret is not None and caller_id |> ret.__is_readable) {
return ret;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ obj JacPlugin {
:obj:Memory:can:get_obj
(caller_id: UUID, item_id: UUID, override: bool=False) -> Element {
ret = item_id |> self.index.get;
if override
or (ret is not None and caller_id |> ret.__is_readable) {
if override or (ret is not None and caller_id |> ret.__is_readable) {
return ret;
}
}
Expand Down

0 comments on commit 62f8bd7

Please sign in to comment.