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
|
@ -26,7 +26,7 @@ from .common import *
|
|||
from .contexts import ExprValueCtx, ScopeCtx, ValueTypeCtx
|
||||
from .expression import Expression
|
||||
from .gobject_object import Object
|
||||
from .types import TypeName
|
||||
from .types import BracketedTypeName, TypeName
|
||||
|
||||
|
||||
class Translated(AstNode):
|
||||
|
@ -80,11 +80,7 @@ class TypeLiteral(AstNode):
|
|||
grammar = [
|
||||
"typeof",
|
||||
AnyOf(
|
||||
[
|
||||
"<",
|
||||
to_parse_node(TypeName).expected("type name"),
|
||||
Match(">").expected(),
|
||||
],
|
||||
BracketedTypeName,
|
||||
[
|
||||
UseExact("lparen", "("),
|
||||
to_parse_node(TypeName).expected("type name"),
|
||||
|
@ -98,8 +94,13 @@ class TypeLiteral(AstNode):
|
|||
return gir.TypeType()
|
||||
|
||||
@property
|
||||
def type_name(self) -> TypeName:
|
||||
return self.children[TypeName][0]
|
||||
def type_name(self) -> T.Optional[TypeName]:
|
||||
if len(self.children[BracketedTypeName]) == 1:
|
||||
return self.children[BracketedTypeName][0].type_name
|
||||
elif len(self.children[TypeName]) == 1:
|
||||
return self.children[TypeName][0]
|
||||
else:
|
||||
return None
|
||||
|
||||
@validate()
|
||||
def validate_for_type(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue