lsp: Implement "go to definition"

This commit is contained in:
James Westman 2023-07-25 18:40:05 -05:00
parent e087aeb44f
commit 62f74178f7
7 changed files with 64 additions and 4 deletions

View file

@ -339,6 +339,16 @@ class IdentLiteral(AstNode):
token = self.group.tokens["value"]
yield SemanticToken(token.start, token.end, SemanticTokenType.EnumMember)
def get_reference(self, _idx: int) -> T.Optional[LocationLink]:
ref = self.context[ScopeCtx].objects.get(self.ident)
if ref is None and self.root.is_legacy_template(self.ident):
ref = self.root.template
if ref:
return LocationLink(self.range, ref.range, ref.ranges["id"])
else:
return None
class Literal(AstNode):
grammar = AnyOf(