-
Notifications
You must be signed in to change notification settings - Fork 1
/
function.go
67 lines (58 loc) · 1.64 KB
/
function.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
66
67
package main
import "strings"
type Function struct {
Name string `json:"name"`
Suffix string `json:"-"`
Description string `json:"description"`
Parameters []Parameter `json:"parameters"`
Return Type `json:"returns"`
}
func (f *Function) GetNameUpperInitial() string {
return UpperInitial(f.Name)
}
func (f *Function) GetNameSplit() []string {
return strings.Split(f.Name, ".")
}
func (f *Function) GetFirstDescriptionLine() string {
return FirstDescriptionLine(f.Description)
}
func (f *Function) GetNextDescriptionLines() []string {
return NextDescriptionLines(f.Description)
}
func (f *Function) GetParameterFullString() string {
result := ""
firstParameter := true
for _, parameter := range f.Parameters {
if !IsBugParameter(parameter.Name) {
if firstParameter {
result = result + ConvertGoReserveNames(parameter.Name) + " " + parameter.Type.GetTypeOptionalPointer()
firstParameter = false
} else {
result = result + ", " + ConvertGoReserveNames(parameter.Name) + " " + parameter.Type.GetTypeOptionalPointer()
}
}
}
return result
}
func (f *Function) GetParameterCallString() string {
result := ""
firstParameter := true
for _, parameter := range f.Parameters {
if !IsBugParameter(parameter.Name) {
if firstParameter {
firstParameter = false
result = result + ConvertGoReserveNames(parameter.Name)
} else {
result = result + ", " + ConvertGoReserveNames(parameter.Name)
}
}
}
return result
}
func (f *Function) GetParameterCallStringWithCommaPrefix() string {
result := f.GetParameterCallString()
if result != "" {
result = ", " + result
}
return result
}