MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / topLevelDeclNames

Function topLevelDeclNames

pkg/codegen/server_urls_test.go:152–172  ·  view source on GitHub ↗

topLevelDeclNames returns every identifier declared at file scope.

(file *ast.File)

Source from the content-addressed store, hash-verified

150
151// topLevelDeclNames returns every identifier declared at file scope.
152func topLevelDeclNames(file *ast.File) []string {
153 var names []string
154 for _, decl := range file.Decls {
155 switch d := decl.(type) {
156 case *ast.FuncDecl:
157 names = append(names, d.Name.Name)
158 case *ast.GenDecl:
159 for _, spec := range d.Specs {
160 switch s := spec.(type) {
161 case *ast.ValueSpec:
162 for _, n := range s.Names {
163 names = append(names, n.Name)
164 }
165 case *ast.TypeSpec:
166 names = append(names, s.Name.Name)
167 }
168 }
169 }
170 }
171 return names
172}
173
174func TestBuildServerURLTypeDefinitions(t *testing.T) {
175 t.Run("synthesises one TypeDefinition per enum-typed used variable", func(t *testing.T) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected