MCPcopy
hub / github.com/sqlc-dev/sqlc / LineNumber

Function LineNumber

internal/source/code.go:24–52  ·  view source on GitHub ↗
(source string, head int)

Source from the content-addressed store, hash-verified

22}
23
24func LineNumber(source string, head int) (int, int) {
25 // Calculate the true line and column number for a query, ignoring spaces
26 var comment bool
27 var loc, line, col int
28 for i, char := range source {
29 loc += 1
30 col += 1
31 // TODO: Check bounds
32 if char == '-' && source[i+1] == '-' {
33 comment = true
34 }
35 if char == '\n' {
36 comment = false
37 line += 1
38 col = 0
39 }
40 if loc <= head {
41 continue
42 }
43 if unicode.IsSpace(char) {
44 continue
45 }
46 if comment {
47 continue
48 }
49 break
50 }
51 return line + 1, col
52}
53
54func Pluck(source string, location, length int) (string, error) {
55 head := location

Callers 1

AddMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected