Skip to content

Commit

Permalink
Apply black.
Browse files Browse the repository at this point in the history
Node, Jade, I did not get bitten by the CI check :^)

Signed-off-by: Danila Fedorin <[email protected]>
  • Loading branch information
DanilaFe committed Jun 10, 2024
1 parent 3f02de9 commit 20c47e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/chpl-language-server/src/chpl-language-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
REAL_NUMBERIC = (chapel.RealLiteral, chapel.IntLiteral, chapel.UintLiteral)
NUMERIC = REAL_NUMBERIC + (chapel.ImagLiteral,)


def is_basic_literal_like(node: chapel.AstNode) -> Optional[chapel.Literal]:
"""
Check for "basic" literals: basically, 1, "hello", -42, etc.
Expand All @@ -155,14 +156,19 @@ def is_basic_literal_like(node: chapel.AstNode) -> Optional[chapel.Literal]:
if isinstance(node, chapel.Literal):
return node

if isinstance(node, chapel.OpCall) and node.op() == "-" and node.num_actuals() == 1:
if (
isinstance(node, chapel.OpCall)
and node.op() == "-"
and node.num_actuals() == 1
):
# Do not recurse; do not consider --42 as a basic literal.
act = node.actual(0)
if isinstance(act, NUMERIC):
return act

return None


def is_literal_like(node: chapel.AstNode) -> bool:
if is_basic_literal_like(node):
return True
Expand Down

0 comments on commit 20c47e3

Please sign in to comment.