-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextension.go
46 lines (40 loc) · 1.08 KB
/
extension.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package raml
import (
"gopkg.in/yaml.v3"
"github.com/acronis/go-stacktrace"
)
type DomainExtension struct {
ID string
Name string
Extension *Node
DefinedBy *BaseShape
Location string
stacktrace.Position
raml *RAML
}
func (r *RAML) unmarshalCustomDomainExtension(location string, keyNode *yaml.Node,
valueNode *yaml.Node,
) (string, *DomainExtension, error) {
name := keyNode.Value[1 : len(keyNode.Value)-1]
if name == "" {
return "", nil, StacktraceNew("annotation name must not be empty", location,
WithNodePosition(keyNode))
}
n, err := r.makeRootNode(valueNode, location)
if err != nil {
return "", nil, StacktraceNewWrapped("make node", err, location,
WithNodePosition(valueNode))
}
de := &DomainExtension{
Name: name,
Extension: n,
Location: location,
Position: stacktrace.Position{Line: keyNode.Line, Column: keyNode.Column},
raml: r,
}
r.domainExtensions = append(r.domainExtensions, de)
return name, de, nil
}
func IsCustomDomainExtensionNode(name string) bool {
return name != "" && name[0] == '(' && name[len(name)-1] == ')'
}