topLevelDeclNames returns every identifier declared at file scope.
(file *ast.File)
| 150 | |
| 151 | // topLevelDeclNames returns every identifier declared at file scope. |
| 152 | func 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 | |
| 174 | func TestBuildServerURLTypeDefinitions(t *testing.T) { |
| 175 | t.Run("synthesises one TypeDefinition per enum-typed used variable", func(t *testing.T) { |
no outgoing calls
no test coverage detected