omniNodeLoc extracts the Loc field from an ast.Node via type switching. Not every node has a Loc (the Node interface doesn't expose it), so we enumerate the types we care about. Returns zero Loc otherwise.
(n ast.Node)
| 1360 | // Not every node has a Loc (the Node interface doesn't expose it), so we |
| 1361 | // enumerate the types we care about. Returns zero Loc otherwise. |
| 1362 | func omniNodeLoc(n ast.Node) ast.Loc { |
| 1363 | if n == nil { |
| 1364 | return ast.NoLoc() |
| 1365 | } |
| 1366 | if loc, ok := omniExpressionNodeLoc(n); ok { |
| 1367 | return loc |
| 1368 | } |
| 1369 | switch v := n.(type) { |
| 1370 | case *ast.SelectStmt: |
| 1371 | return v.Loc |
| 1372 | case *ast.TableRef: |
| 1373 | return v.Loc |
| 1374 | case *ast.ResTarget: |
| 1375 | return v.Loc |
| 1376 | case *ast.SelectAssign: |
| 1377 | return v.Loc |
| 1378 | default: |
| 1379 | return ast.NoLoc() |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | func omniExpressionNodeLoc(n ast.Node) (ast.Loc, bool) { |
| 1384 | switch v := n.(type) { |
no test coverage detected