...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package compiler
16
17 import (
18 yaml "gopkg.in/yaml.v3"
19 )
20
21
22 type Context struct {
23 Parent *Context
24 Name string
25 Node *yaml.Node
26 ExtensionHandlers *[]ExtensionHandler
27 }
28
29
30 func NewContextWithExtensions(name string, node *yaml.Node, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
31 return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: extensionHandlers}
32 }
33
34
35 func NewContext(name string, node *yaml.Node, parent *Context) *Context {
36 if parent != nil {
37 return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers}
38 }
39 return &Context{Name: name, Parent: parent, ExtensionHandlers: nil}
40 }
41
42
43 func (context *Context) Description() string {
44 name := context.Name
45 if context.Parent != nil {
46 name = context.Parent.Description() + "." + name
47 }
48 return name
49 }
50
View as plain text