MCPcopy Create free account
hub / github.com/rilldata/rill / findLineNumber

Function findLineNumber

runtime/parser/parse_model.go:412–428  ·  view source on GitHub ↗

findLineNumber returns the line number of the pos in the given text. Lines are counted starting from 1, and positions start from 0.

(text string, pos int)

Source from the content-addressed store, hash-verified

410// findLineNumber returns the line number of the pos in the given text.
411// Lines are counted starting from 1, and positions start from 0.
412func findLineNumber(text string, pos int) int {
413 if pos < 0 || pos >= len(text) {
414 return -1
415 }
416
417 lineNumber := 1
418 for i, char := range text {
419 if i == pos {
420 break
421 }
422 if char == '\n' {
423 lineNumber++
424 }
425 }
426
427 return lineNumber
428}
429
430// parseChangeModeYAML parses the change mode from the YAML file.
431func parseChangeModeYAML(mode string) (runtimev1.ModelChangeMode, error) {

Callers 1

inferSQLRefsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected