mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Implement "go to definition"
This commit is contained in:
parent
e087aeb44f
commit
62f74178f7
7 changed files with 64 additions and 4 deletions
|
@ -50,6 +50,7 @@ from ..lsp_utils import (
|
|||
Completion,
|
||||
CompletionItemKind,
|
||||
DocumentSymbol,
|
||||
LocationLink,
|
||||
SemanticToken,
|
||||
SemanticTokenType,
|
||||
SymbolKind,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue