MCPcopy Create free account
hub / github.com/bytebase/bytebase / omniNodeLoc

Function omniNodeLoc

backend/plugin/parser/tsql/query_span_extractor_omni.go:1362–1381  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1362func 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
1383func omniExpressionNodeLoc(n ast.Node) (ast.Loc, bool) {
1384 switch v := n.(type) {

Callers 2

dmlNodeLocFunction · 0.70
sliceNameMethod · 0.70

Calls 1

omniExpressionNodeLocFunction · 0.85

Tested by

no test coverage detected