MCPcopy Create free account
hub / github.com/google/gapid / AllCommands

Method AllCommands

gapil/template/api.go:121–142  ·  view source on GitHub ↗

AllCommands returns a list of all cmd entries for a given API, regardless of whether they are free functions, class methods or pseudonym methods.

(api interface{})

Source from the content-addressed store, hash-verified

119// AllCommands returns a list of all cmd entries for a given API, regardless
120// of whether they are free functions, class methods or pseudonym methods.
121func (f *Functions) AllCommands(api interface{}) ([]*semantic.Function, error) {
122 switch api := api.(type) {
123 case *semantic.API:
124 var commands []*semantic.Function
125 for _, function := range api.Functions {
126 commands = append(commands, function)
127 }
128 for _, class := range api.Classes {
129 for _, method := range class.Methods {
130 commands = append(commands, method)
131 }
132 }
133 for _, pseudonym := range api.Pseudonyms {
134 for _, method := range pseudonym.Methods {
135 commands = append(commands, method)
136 }
137 }
138 return commands, nil
139 default:
140 return nil, fmt.Errorf("first argument must be of type *semantic.API, was %T", api)
141 }
142}
143
144// AllCommandsSorted returns the list of commands retuned by AllCommands, sorted
145// lexicographically.

Callers 1

AllCommandsSortedMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected