mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Add GtkScale mark positions
This commit is contained in:
parent
8f3ae9a626
commit
d5b2ee3589
1 changed files with 29 additions and 14 deletions
|
@ -23,22 +23,20 @@ from .values import StringValue
|
||||||
|
|
||||||
|
|
||||||
class ExtScaleMark(AstNode):
|
class ExtScaleMark(AstNode):
|
||||||
grammar = [
|
grammar = Statement(
|
||||||
Keyword("mark"),
|
Keyword("mark"),
|
||||||
Match("(").expected(),
|
Match("(").expected(),
|
||||||
[
|
Optional(AnyOf(UseExact("sign", "-"), UseExact("sign", "+"))),
|
||||||
Optional(AnyOf(UseExact("sign", "-"), UseExact("sign", "+"))),
|
UseNumber("value").expected("value"),
|
||||||
UseNumber("value"),
|
Optional(
|
||||||
Optional(
|
[
|
||||||
[
|
",",
|
||||||
",",
|
UseIdent("position").expected("position"),
|
||||||
UseIdent("position"),
|
Optional([",", to_parse_node(StringValue).expected("label")]),
|
||||||
Optional([",", StringValue]),
|
]
|
||||||
]
|
),
|
||||||
),
|
end=")",
|
||||||
],
|
)
|
||||||
Match(")").expected(),
|
|
||||||
]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> float:
|
def value(self) -> float:
|
||||||
|
@ -153,6 +151,23 @@ def complete_mark(_ctx: CompletionContext):
|
||||||
yield Completion("mark", CompletionItemKind.Keyword, snippet="mark ($0),")
|
yield Completion("mark", CompletionItemKind.Keyword, snippet="mark ($0),")
|
||||||
|
|
||||||
|
|
||||||
|
@completer(
|
||||||
|
applies_in=[ExtScaleMark],
|
||||||
|
matches=[[(TokenType.NUMBER, None), (TokenType.PUNCTUATION, ",")]],
|
||||||
|
)
|
||||||
|
def complete_mark_position(ctx: CompletionContext):
|
||||||
|
gir = ctx.ast_node.root.gir
|
||||||
|
response_type = gir.get_type("PositionType", "Gtk")
|
||||||
|
yield from [
|
||||||
|
Completion(
|
||||||
|
name,
|
||||||
|
kind=CompletionItemKind.EnumMember,
|
||||||
|
docs=member.doc,
|
||||||
|
)
|
||||||
|
for name, member in response_type.members.items()
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@decompiler("marks")
|
@decompiler("marks")
|
||||||
def decompile_marks(
|
def decompile_marks(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue