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

Extend symbol signature to work FnCall #24913

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Changes from 2 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
27 changes: 27 additions & 0 deletions tools/chpl-language-server/src/symbol_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def _get_symbol_signature(node: chapel.AstNode) -> List[Component]:
return _var_to_string(node)
elif isinstance(node, chapel.Function):
return _proc_to_string(node)
elif isinstance(node, chapel.TypeQuery):
return [_wrap_str(f"?{node.name()}")]

return [_wrap_str(node.name())]

Expand Down Expand Up @@ -171,6 +173,8 @@ def _node_to_string(node: chapel.AstNode) -> List[Component]:
return [_wrap_str('"' + node.value() + '"')]
elif isinstance(node, chapel.CStringLiteral):
return [_wrap_str('c"' + node.value() + '"')]
elif isinstance(node, chapel.FnCall):
return _fncall_to_string(node)
return [Component(ComponentTag.PLACEHOLDER, None)]


Expand Down Expand Up @@ -300,3 +304,26 @@ def _intent_to_string(intent: Optional[str]) -> str:
}
# use 'intent' as the default, so if no remap no work done
return remap.get(intent, intent) if intent else ""

def _fncall_to_string(call: chapel.FnCall) -> List[Component]:
"""
Convert a call to a string
"""
comps = []

comps.extend(_node_to_string(call.called_expression()))
comps.append(_wrap_str("[" if call.used_square_brackets() else "("))
jabraham17 marked this conversation as resolved.
Show resolved Hide resolved
sep = ""
for a in call.actuals():
comps.append(_wrap_str(sep))
sep = ", "
if isinstance(a, tuple):
comps.append(_wrap_str(a[0]))
comps.append(_wrap_str(" = "))
comps.extend(_node_to_string(a[1]))
else:
assert(isinstance(a, chapel.AstNode))
comps.extend(_node_to_string(a))
comps.append(_wrap_str("]" if call.used_square_brackets() else ")"))

return comps
Loading