completions: Lookup expressions

This commit is contained in:
James Westman 2025-05-15 19:56:10 -05:00
parent 684ed7dc02
commit ddcd77f212
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
2 changed files with 43 additions and 16 deletions

View file

@ -80,20 +80,24 @@ class Binding(AstNode):
@property
def simple_binding(self) -> T.Optional["SimpleBinding"]:
if isinstance(self.expression.last, LookupOp):
if isinstance(self.expression.last.lhs, LiteralExpr):
from .values import IdentLiteral
from .values import IdentLiteral
if isinstance(self.expression.last.lhs.literal.value, IdentLiteral):
flags = [x.flag for x in self.flags]
return SimpleBinding(
self.expression.last.lhs.literal.value.ident,
self.expression.last.property_name,
no_sync_create="no-sync-create" in flags,
bidirectional="bidirectional" in flags,
inverted="inverted" in flags,
)
return None
if (
not isinstance(self.expression.last, LookupOp)
or not isinstance(self.expression.last.lhs, LiteralExpr)
or not isinstance(self.expression.last.lhs.literal.value, IdentLiteral)
or self.expression.last.property_name is None
):
return None
flags = [x.flag for x in self.flags]
return SimpleBinding(
self.expression.last.lhs.literal.value.ident,
self.expression.last.property_name,
no_sync_create="no-sync-create" in flags,
bidirectional="bidirectional" in flags,
inverted="inverted" in flags,
)
@validate("bind")
def bind_property(self):