mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
language: Rename extension classes
Rename extension classes to match the syntax reference.
This commit is contained in:
parent
9e82a2fb2a
commit
10806bce1e
11 changed files with 46 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
|||
from .gtk_list_item_factory import ListItemFactory
|
||||
from .adw_message_dialog import Responses
|
||||
from .gtk_list_item_factory import ExtListItemFactory
|
||||
from .adw_message_dialog import ExtAdwMessageDialog
|
||||
from .attributes import BaseAttribute, BaseTypedAttribute
|
||||
from .binding import Binding
|
||||
from .contexts import ValueTypeCtx
|
||||
|
@ -15,14 +15,19 @@ from .expression import (
|
|||
from .gobject_object import Object, ObjectContent
|
||||
from .gobject_property import Property
|
||||
from .gobject_signal import Signal
|
||||
from .gtk_a11y import A11y
|
||||
from .gtk_combo_box_text import Items
|
||||
from .gtk_file_filter import mime_types, patterns, suffixes, Filters
|
||||
from .gtk_layout import Layout
|
||||
from .gtk_a11y import ExtAccessibility
|
||||
from .gtk_combo_box_text import ExtComboBoxItems
|
||||
from .gtk_file_filter import (
|
||||
ext_file_filter_mime_types,
|
||||
ext_file_filter_patterns,
|
||||
ext_file_filter_suffixes,
|
||||
Filters,
|
||||
)
|
||||
from .gtk_layout import ExtLayout
|
||||
from .gtk_menu import menu, Menu, MenuAttribute
|
||||
from .gtk_size_group import Widgets
|
||||
from .gtk_string_list import Strings
|
||||
from .gtk_styles import Styles
|
||||
from .gtk_size_group import ExtSizeGroupWidgets
|
||||
from .gtk_string_list import ExtStringListStrings
|
||||
from .gtk_styles import ExtStyles
|
||||
from .gtkbuilder_child import Child, ChildType, ChildInternal, ChildExtension
|
||||
from .gtkbuilder_template import Template
|
||||
from .imports import GtkDirective, Import
|
||||
|
@ -48,17 +53,17 @@ from .common import *
|
|||
OBJECT_CONTENT_HOOKS.children = [
|
||||
Signal,
|
||||
Property,
|
||||
A11y,
|
||||
Styles,
|
||||
Layout,
|
||||
mime_types,
|
||||
patterns,
|
||||
suffixes,
|
||||
Widgets,
|
||||
Items,
|
||||
Strings,
|
||||
ListItemFactory,
|
||||
Responses,
|
||||
ExtAccessibility,
|
||||
ExtAdwMessageDialog,
|
||||
ExtComboBoxItems,
|
||||
ext_file_filter_mime_types,
|
||||
ext_file_filter_patterns,
|
||||
ext_file_filter_suffixes,
|
||||
ExtLayout,
|
||||
ExtListItemFactory,
|
||||
ExtSizeGroupWidgets,
|
||||
ExtStringListStrings,
|
||||
ExtStyles,
|
||||
Child,
|
||||
]
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class Response(AstNode):
|
|||
)
|
||||
|
||||
|
||||
class Responses(AstNode):
|
||||
class ExtAdwMessageDialog(AstNode):
|
||||
grammar = [
|
||||
Keyword("responses"),
|
||||
Match("[").expected(),
|
||||
|
|
|
@ -159,7 +159,7 @@ class A11yProperty(BaseTypedAttribute):
|
|||
return _get_docs(self.root.gir, self.tokens["name"])
|
||||
|
||||
|
||||
class A11y(AstNode):
|
||||
class ExtAccessibility(AstNode):
|
||||
grammar = [
|
||||
Keyword("accessibility"),
|
||||
"{",
|
||||
|
@ -190,7 +190,7 @@ def a11y_completer(ast_node, match_variables):
|
|||
|
||||
|
||||
@completer(
|
||||
applies_in=[A11y],
|
||||
applies_in=[ExtAccessibility],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def a11y_name_completer(ast_node, match_variables):
|
||||
|
|
|
@ -49,7 +49,7 @@ item = Group(
|
|||
)
|
||||
|
||||
|
||||
class Items(AstNode):
|
||||
class ExtComboBoxItems(AstNode):
|
||||
grammar = [
|
||||
Keyword("items"),
|
||||
"[",
|
||||
|
|
|
@ -67,9 +67,9 @@ def create_node(tag_name: str, singular: str):
|
|||
)
|
||||
|
||||
|
||||
mime_types = create_node("mime-types", "mime-type")
|
||||
patterns = create_node("patterns", "pattern")
|
||||
suffixes = create_node("suffixes", "suffix")
|
||||
ext_file_filter_mime_types = create_node("mime-types", "mime-type")
|
||||
ext_file_filter_patterns = create_node("patterns", "pattern")
|
||||
ext_file_filter_suffixes = create_node("suffixes", "suffix")
|
||||
|
||||
|
||||
@completer(
|
||||
|
|
|
@ -55,7 +55,7 @@ layout_prop = Group(
|
|||
)
|
||||
|
||||
|
||||
class Layout(AstNode):
|
||||
class ExtLayout(AstNode):
|
||||
grammar = Sequence(
|
||||
Keyword("layout"),
|
||||
"{",
|
||||
|
|
|
@ -5,7 +5,7 @@ from .common import *
|
|||
from .contexts import ScopeCtx
|
||||
|
||||
|
||||
class ListItemFactory(AstNode):
|
||||
class ExtListItemFactory(AstNode):
|
||||
grammar = [Keyword("template"), ObjectContent]
|
||||
|
||||
@property
|
||||
|
|
|
@ -44,7 +44,7 @@ class Widget(AstNode):
|
|||
)
|
||||
|
||||
|
||||
class Widgets(AstNode):
|
||||
class ExtSizeGroupWidgets(AstNode):
|
||||
grammar = [
|
||||
Keyword("widgets"),
|
||||
"[",
|
||||
|
|
|
@ -32,7 +32,7 @@ class Item(AstNode):
|
|||
return self.children[StringValue][0]
|
||||
|
||||
|
||||
class Strings(AstNode):
|
||||
class ExtStringListStrings(AstNode):
|
||||
grammar = [
|
||||
Keyword("strings"),
|
||||
"[",
|
||||
|
|
|
@ -26,7 +26,7 @@ class StyleClass(AstNode):
|
|||
grammar = UseQuoted("name")
|
||||
|
||||
|
||||
class Styles(AstNode):
|
||||
class ExtStyles(AstNode):
|
||||
grammar = [
|
||||
Keyword("styles"),
|
||||
"[",
|
||||
|
|
|
@ -46,7 +46,7 @@ class XmlOutput(OutputFormat):
|
|||
xml.end_tag()
|
||||
|
||||
def _emit_object_or_template(
|
||||
self, obj: T.Union[Object, Template, ListItemFactory], xml: XmlEmitter
|
||||
self, obj: T.Union[Object, Template, ExtListItemFactory], xml: XmlEmitter
|
||||
):
|
||||
for child in obj.content.children:
|
||||
if isinstance(child, Property):
|
||||
|
@ -274,7 +274,7 @@ class XmlOutput(OutputFormat):
|
|||
xml.end_tag()
|
||||
|
||||
def _emit_extensions(self, extension, xml: XmlEmitter):
|
||||
if isinstance(extension, A11y):
|
||||
if isinstance(extension, ExtAccessibility):
|
||||
xml.start_tag("accessibility")
|
||||
for prop in extension.properties:
|
||||
self._emit_attribute(prop.tag_name, "name", prop.name, prop.value, xml)
|
||||
|
@ -288,19 +288,19 @@ class XmlOutput(OutputFormat):
|
|||
xml.end_tag()
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Items):
|
||||
elif isinstance(extension, ExtComboBoxItems):
|
||||
xml.start_tag("items")
|
||||
for prop in extension.children:
|
||||
self._emit_attribute("item", "id", prop.name, prop.value, xml)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Layout):
|
||||
elif isinstance(extension, ExtLayout):
|
||||
xml.start_tag("layout")
|
||||
for prop in extension.children:
|
||||
self._emit_attribute("property", "name", prop.name, prop.value, xml)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Responses):
|
||||
elif isinstance(extension, ExtAdwMessageDialog):
|
||||
xml.start_tag("responses")
|
||||
for response in extension.responses:
|
||||
xml.start_tag(
|
||||
|
@ -314,7 +314,7 @@ class XmlOutput(OutputFormat):
|
|||
xml.end_tag()
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Strings):
|
||||
elif isinstance(extension, ExtStringListStrings):
|
||||
xml.start_tag("items")
|
||||
for string in extension.children:
|
||||
value = string.child
|
||||
|
@ -322,7 +322,7 @@ class XmlOutput(OutputFormat):
|
|||
xml.put_text(value.string)
|
||||
xml.end_tag()
|
||||
xml.end_tag()
|
||||
elif isinstance(extension, ListItemFactory):
|
||||
elif isinstance(extension, ExtListItemFactory):
|
||||
child_xml = XmlEmitter()
|
||||
child_xml.start_tag("interface")
|
||||
child_xml.start_tag("template", **{"class": "GtkListItem"})
|
||||
|
@ -333,13 +333,13 @@ class XmlOutput(OutputFormat):
|
|||
xml.put_cdata(child_xml.result)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Styles):
|
||||
elif isinstance(extension, ExtStyles):
|
||||
xml.start_tag("style")
|
||||
for prop in extension.children:
|
||||
xml.put_self_closing("class", name=prop.tokens["name"])
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Widgets):
|
||||
elif isinstance(extension, ExtSizeGroupWidgets):
|
||||
xml.start_tag("widgets")
|
||||
for prop in extension.children:
|
||||
xml.put_self_closing("widget", name=prop.tokens["name"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue