MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / hasCodeBeforeOnLine

Method hasCodeBeforeOnLine

pkg/sql/tokenizer/tokenizer.go:1815–1831  ·  view source on GitHub ↗

hasCodeBeforeOnLine checks if there are non-whitespace characters on the same line before the given byte index. Used to determine if a comment is inline.

(idx int)

Source from the content-addressed store, hash-verified

1813// hasCodeBeforeOnLine checks if there are non-whitespace characters on the same
1814// line before the given byte index. Used to determine if a comment is inline.
1815func (t *Tokenizer) hasCodeBeforeOnLine(idx int) bool {
1816 // Find the start of the line containing idx
1817 lineStart := 0
1818 for i := len(t.lineStarts) - 1; i >= 0; i-- {
1819 if t.lineStarts[i] <= idx {
1820 lineStart = t.lineStarts[i]
1821 break
1822 }
1823 }
1824 // Check for non-whitespace between lineStart and idx
1825 for i := lineStart; i < idx && i < len(t.input); i++ {
1826 if t.input[i] != ' ' && t.input[i] != '\t' && t.input[i] != '\r' {
1827 return true
1828 }
1829 }
1830 return false
1831}

Callers 1

readPunctuationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected