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
|
@ -24,6 +24,7 @@ from dataclasses import dataclass
|
|||
from enum import Enum
|
||||
|
||||
from .errors import CompileError, CompilerBugError
|
||||
from . import utils
|
||||
|
||||
|
||||
class TokenType(Enum):
|
||||
|
@ -127,3 +128,12 @@ class Range:
|
|||
if b is None:
|
||||
return a
|
||||
return Range(min(a.start, b.start), max(a.end, b.end), a.original_text)
|
||||
|
||||
def __contains__(self, other: T.Union[int, "Range"]) -> bool:
|
||||
if isinstance(other, int):
|
||||
return self.start <= other <= self.end
|
||||
else:
|
||||
return self.start <= other.start and self.end >= other.end
|
||||
|
||||
def to_json(self):
|
||||
return utils.idxs_to_range(self.start, self.end, self.original_text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue