mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Add properties to AST types
I want to have a cleaner API that relies less on the specifics of the grammar and parser.
This commit is contained in:
parent
0b7dbaf90d
commit
6938267952
4 changed files with 34 additions and 10 deletions
|
@ -22,7 +22,7 @@ from .. import gir
|
|||
from .imports import GtkDirective, Import
|
||||
from .gtkbuilder_template import Template
|
||||
from .gobject_object import Object
|
||||
from .gtk_menu import menu
|
||||
from .gtk_menu import menu, Menu
|
||||
from .common import *
|
||||
|
||||
|
||||
|
@ -64,6 +64,24 @@ class UI(AstNode):
|
|||
|
||||
return gir_ctx
|
||||
|
||||
@property
|
||||
def using(self) -> T.List[Import]:
|
||||
return self.children[Import]
|
||||
|
||||
@property
|
||||
def gtk_decl(self) -> GtkDirective:
|
||||
return self.children[GtkDirective][0]
|
||||
|
||||
@property
|
||||
def contents(self) -> T.List[T.Union[Object, Template, Menu]]:
|
||||
return [
|
||||
child
|
||||
for child in self.children
|
||||
if isinstance(child, Object)
|
||||
or isinstance(child, Template)
|
||||
or isinstance(child, Menu)
|
||||
]
|
||||
|
||||
@property
|
||||
def objects_by_id(self):
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue