-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_map_doclink_renaming.go
76 lines (59 loc) · 2.29 KB
/
setup_map_doclink_renaming.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
68
69
70
71
72
73
74
75
76
package models
import (
"sort"
gong_models "github.com/fullstack-lang/gong/go/models"
)
// to be removed after fix of [issue](https://github.com/golang/go/issues/57559)
func SetupMapDocLinkRenaming(gongStage *gong_models.StageStruct, gongdocStage *StageStruct) {
gongstructOrdered := []*gong_models.GongStruct{}
for gongstruct := range *gong_models.GetGongstructInstancesSet[gong_models.GongStruct](gongStage) {
gongstructOrdered = append(gongstructOrdered, gongstruct)
}
sort.Slice(gongstructOrdered[:], func(i, j int) bool {
return gongstructOrdered[i].Name < gongstructOrdered[j].Name
})
for _, gongStruct := range gongstructOrdered {
ident := GongStructNameToIdentifier(gongStruct.Name)
var identifier GONG__Identifier
identifier.Ident = ident
identifier.Type = GONG__STRUCT_INSTANCE
gongdocStage.Map_DocLink_Renaming[ident] = identifier
for _, field := range gongStruct.Fields {
ident := GongstructAndFieldnameToFieldIdentifier(
gongStruct.Name, field.GetName())
var identifier GONG__Identifier
identifier.Ident = ident
identifier.Type = GONG__FIELD_VALUE
gongdocStage.Map_DocLink_Renaming[ident] = identifier
}
}
for gongEnum := range *gong_models.GetGongstructInstancesSet[gong_models.GongEnum](gongStage) {
ident := GongStructNameToIdentifier(gongEnum.Name)
var identifier GONG__Identifier
identifier.Ident = ident
switch gongEnum.Type {
case gong_models.Int:
identifier.Type = GONG__ENUM_CAST_INT
case gong_models.String:
identifier.Type = GONG__ENUM_CAST_STRING
}
gongdocStage.Map_DocLink_Renaming[ident] = identifier
for _, value := range gongEnum.GongEnumValues {
ident := GongStructNameToIdentifier(value.Name)
var identifier GONG__Identifier
identifier.Ident = ident
identifier.Type = GONG__IDENTIFIER_CONST
gongdocStage.Map_DocLink_Renaming[ident] = identifier
}
// to do after fix of https://github.com/fullstack-lang/gongdoc/issues/100
// stage.Map_DocLink_Renaming[ident] = ident
}
for gongNote := range *gong_models.GetGongstructInstancesSet[gong_models.GongNote](gongStage) {
ident := GongStructNameToIdentifier(gongNote.Name)
var identifier GONG__Identifier
identifier.Ident = ident
identifier.Type = GONG__IDENTIFIER_CONST
gongdocStage.Map_DocLink_Renaming[ident] = identifier
}
// end of TO BE REMOVED
}