mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Support completions
This commit is contained in:
parent
afecd744ca
commit
408f3ebce5
8 changed files with 460 additions and 106 deletions
|
@ -22,6 +22,8 @@ import typing as T
|
|||
from .ast_utils import *
|
||||
from .errors import assert_true, AlreadyCaughtError, CompileError, CompilerBugError, MultipleErrors
|
||||
from .gir import GirContext, get_namespace
|
||||
from .lsp_utils import Completion, CompletionItemKind
|
||||
from .tokenizer import Token
|
||||
from .utils import lazy_prop
|
||||
from .xml_emitter import XmlEmitter
|
||||
|
||||
|
@ -29,11 +31,16 @@ from .xml_emitter import XmlEmitter
|
|||
class AstNode:
|
||||
""" Base class for nodes in the abstract syntax tree. """
|
||||
|
||||
completers: T.List = []
|
||||
|
||||
def __init__(self):
|
||||
self.group = None
|
||||
self.parent = None
|
||||
self.child_nodes = None
|
||||
|
||||
def __init_subclass__(cls):
|
||||
cls.completers = []
|
||||
|
||||
@lazy_prop
|
||||
def root(self):
|
||||
if self.parent is None:
|
||||
|
@ -263,6 +270,17 @@ class ObjectContent(AstNode):
|
|||
self.children = children
|
||||
self.style = style
|
||||
|
||||
|
||||
@validate()
|
||||
def gir_class(self):
|
||||
parent = self.parent
|
||||
if isinstance(parent, Template):
|
||||
return parent.gir_parent
|
||||
elif isinstance(parent, Object):
|
||||
return parent.gir_class
|
||||
else:
|
||||
raise CompilerBugError()
|
||||
|
||||
@validate()
|
||||
def only_one_style_class(self):
|
||||
if len(self.style) > 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue