completions: Add completions for response IDs

This commit is contained in:
James Westman 2025-01-17 16:44:21 -06:00
parent 866092ccf7
commit b26433d865
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
16 changed files with 123 additions and 42 deletions

View file

@ -329,8 +329,9 @@ class Statement(ParseNode):
"""ParseNode that attempts to match all of its children in sequence. If any
child raises an error, the error will be logged but parsing will continue."""
def __init__(self, *children):
def __init__(self, *children, end: str = ";"):
self.children = [to_parse_node(child) for child in children]
self.end = end
def _parse(self, ctx) -> bool:
for child in self.children:
@ -340,11 +341,16 @@ class Statement(ParseNode):
except CompileError as e:
ctx.errors.append(e)
ctx.set_group_incomplete()
token = ctx.peek_token()
if str(token) == self.end:
ctx.next_token()
return True
token = ctx.peek_token()
if str(token) != ";":
ctx.errors.append(CompileError("Expected `;`", token.range))
if str(token) != self.end:
ctx.errors.append(CompileError(f"Expected `{self.end}`", token.range))
else:
ctx.next_token()
return True