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
|
@ -22,7 +22,7 @@ from collections import ChainMap, defaultdict
|
|||
from functools import cached_property
|
||||
|
||||
from .errors import *
|
||||
from .lsp_utils import DocumentSymbol, SemanticToken
|
||||
from .lsp_utils import DocumentSymbol, SemanticToken, LocationLink
|
||||
from .tokenizer import Range
|
||||
|
||||
TType = T.TypeVar("TType")
|
||||
|
@ -185,9 +185,8 @@ class AstNode:
|
|||
return getattr(self, name)
|
||||
|
||||
for child in self.children:
|
||||
if child.group.start <= idx < child.group.end:
|
||||
docs = child.get_docs(idx)
|
||||
if docs is not None:
|
||||
if idx in child.range:
|
||||
if docs := child.get_docs(idx):
|
||||
return docs
|
||||
|
||||
return None
|
||||
|
@ -196,6 +195,13 @@ class AstNode:
|
|||
for child in self.children:
|
||||
yield from child.get_semantic_tokens()
|
||||
|
||||
def get_reference(self, idx: int) -> T.Optional[LocationLink]:
|
||||
for child in self.children:
|
||||
if idx in child.range:
|
||||
if ref := child.get_reference(idx):
|
||||
return ref
|
||||
return None
|
||||
|
||||
@property
|
||||
def document_symbol(self) -> T.Optional[DocumentSymbol]:
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue