-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverb_discriminate.go
66 lines (50 loc) · 1.77 KB
/
verb_discriminate.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import "go/ast"
import "text/template"
type DiscriminateVerbPhrase struct {
baseVerbPhrase
}
var _ VerbPhrase = (*DiscriminateVerbPhrase)(nil)
// var _ GlobalsTemplateParameter = (*DiscriminateVerbPhrase)(nil)
func (vp *DiscriminateVerbPhrase) StructBody() (string, error) {
return "", nil
}
type Verb_Discriminate struct {}
var _ VerbDefinition = (*Verb_Discriminate)(nil)
func init() {
vd := &Verb_Discriminate{}
VerbDefinitions[vd.Tag()] = vd
}
// Tag is part of the VerbDefinition interface.
func (vd *Verb_Discriminate) Tag() string { return "discriminate" }
// Description is part of the VerbDefinition interface.
func (vd *Verb_Discriminate) Description() string {
return "the empty method that distinguishes implementors of this interface from those that would otherwise have the same method set."
}
// NewVerbPhrase is part of the VerbDefinition interface.
func (vd *Verb_Discriminate) NewVerbPhrase(ctx *context, idef *InterfaceDefinition, field *ast.Field, comment *ast.Comment) (VerbPhrase, error) {
_, err, _ := CheckSignatures(ctx, vd, idef.Package(), field, vd.GlobalsTemplate())
if err != nil {
return nil, err
}
vp := &DiscriminateVerbPhrase{
baseVerbPhrase: baseVerbPhrase {
verb: vd,
idef: idef,
field: field,
},
}
return vp, nil
}
var discriminate_method_template = template.Must(
template.New("discriminate_method_template").Parse(`
// {{.MethodName}} is part of the {{.InterfaceName}} interface. defimpl verb {{.Verb.Tag}}.
func (x *{{.StructName}}) {{.MethodName}}() {}
`))
// GlobalsTemplate is part of the VerbDefinition interface.
func (vd *Verb_Discriminate) GlobalsTemplate() *template.Template {
return discriminate_method_template
}
func (vd *Verb_Discriminate) StructBody(VerbPhrase) (string, error) {
return "", nil
}