MCPcopy Index your code
hub / github.com/WendellCraft/ModpackDebuggerKit / getPrimaryModsAndGroupMap

Method getPrimaryModsAndGroupMap

debug.go:48–111  ·  view source on GitHub ↗
(allMods []string)

Source from the content-addressed store, hash-verified

46}
47
48func (a *App) getPrimaryModsAndGroupMap(allMods []string) ([]string, map[string][]string) {
49 a.mu.Lock()
50 deps := a.ProjectData.Dependencies
51 a.mu.Unlock()
52
53 allModsSet := make(map[string]bool)
54 for _, m := range allMods {
55 allModsSet[m] = true
56 }
57
58 allDepsInSet := make(map[string]bool)
59 for _, mod := range allMods {
60 for _, dep := range deps[mod] {
61 if allModsSet[dep] {
62 allDepsInSet[dep] = true
63 }
64 }
65 }
66
67 var primaryMods []string
68 for _, mod := range allMods {
69 if !allDepsInSet[mod] {
70 primaryMods = append(primaryMods, mod)
71 }
72 }
73 sort.Strings(primaryMods)
74
75 if len(primaryMods) == 0 {
76 primaryMods = make([]string, len(allMods))
77 copy(primaryMods, allMods)
78 sort.Strings(primaryMods)
79 }
80
81 groupMap := make(map[string][]string)
82 for _, primary := range primaryMods {
83 group := make(map[string]bool)
84 group[primary] = true
85 queue := make([]string, 0)
86 queue = append(queue, deps[primary]...)
87 processed := make(map[string]bool)
88
89 for len(queue) > 0 {
90 dep := queue[0]
91 queue = queue[1:]
92 if processed[dep] {
93 continue
94 }
95 processed[dep] = true
96 if allModsSet[dep] {
97 group[dep] = true
98 queue = append(queue, deps[dep]...)
99 }
100 }
101
102 var groupList []string
103 for m := range group {
104 groupList = append(groupList, m)
105 }

Callers 1

runDebugScanMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected