countStarsInList counts the number of * expressions in a target list
(targets *ast.List)
| 341 | |
| 342 | // countStarsInList counts the number of * expressions in a target list |
| 343 | func countStarsInList(targets *ast.List) int { |
| 344 | if targets == nil { |
| 345 | return 0 |
| 346 | } |
| 347 | count := 0 |
| 348 | for _, target := range targets.Items { |
| 349 | resTarget, ok := target.(*ast.ResTarget) |
| 350 | if !ok { |
| 351 | continue |
| 352 | } |
| 353 | if resTarget.Val == nil { |
| 354 | continue |
| 355 | } |
| 356 | colRef, ok := resTarget.Val.(*ast.ColumnRef) |
| 357 | if !ok { |
| 358 | continue |
| 359 | } |
| 360 | if colRef.Fields == nil { |
| 361 | continue |
| 362 | } |
| 363 | for _, field := range colRef.Fields.Items { |
| 364 | if _, ok := field.(*ast.A_Star); ok { |
| 365 | count++ |
| 366 | break |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | return count |
| 371 | } |
| 372 | |
| 373 | // countNonStarsInList counts the number of non-* expressions in a target list |
| 374 | func countNonStarsInList(targets *ast.List) int { |