mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Add types in typeof<> and as<>
This commit is contained in:
parent
d5b2ee3589
commit
e9206809d6
10 changed files with 124 additions and 39 deletions
|
@ -57,14 +57,21 @@ new_statement_patterns = [
|
|||
[(TokenType.PUNCTUATION, "}")],
|
||||
[(TokenType.PUNCTUATION, "]")],
|
||||
[(TokenType.PUNCTUATION, ";")],
|
||||
[(TokenType.OP, "<")],
|
||||
]
|
||||
|
||||
|
||||
completers = []
|
||||
|
||||
|
||||
def completer(applies_in: T.List, matches: T.List = [], applies_in_subclass=None):
|
||||
def decorator(func: T.Callable[[CompletionContext], T.Generator[Completion]]):
|
||||
def inner(
|
||||
prev_tokens: T.List[Token], next_token: Token, ast_node, lsp, idx: int
|
||||
):
|
||||
if not any(isinstance(ast_node, rule) for rule in applies_in):
|
||||
return
|
||||
|
||||
# For completers that apply in ObjectContent nodes, we can further
|
||||
# check that the object is the right class
|
||||
if applies_in_subclass is not None:
|
||||
|
@ -118,8 +125,7 @@ def completer(applies_in: T.List, matches: T.List = [], applies_in_subclass=None
|
|||
)
|
||||
yield from func(context)
|
||||
|
||||
for c in applies_in:
|
||||
c.completers.append(inner)
|
||||
completers.append(inner)
|
||||
return inner
|
||||
|
||||
return decorator
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue