MCPcopy
hub / github.com/caddyserver/caddy / isNextOnNewLine

Function isNextOnNewLine

caddyconfig/caddyfile/lexer.go:378–400  ·  view source on GitHub ↗

isNextOnNewLine tests whether t2 is on a different line from t1

(t1, t2 Token)

Source from the content-addressed store, hash-verified

376
377// isNextOnNewLine tests whether t2 is on a different line from t1
378func isNextOnNewLine(t1, t2 Token) bool {
379 // If the second token is from a different file,
380 // we can assume it's from a different line
381 if t1.File != t2.File {
382 return true
383 }
384
385 // If the second token is from a different import chain,
386 // we can assume it's from a different line
387 if len(t1.imports) != len(t2.imports) {
388 return true
389 }
390 for i, im := range t1.imports {
391 if im != t2.imports[i] {
392 return true
393 }
394 }
395
396 // If the first token (incl line breaks) ends
397 // on a line earlier than the next token,
398 // then the second token is on a new line
399 return t1.Line+t1.NumLineBreaks() < t2.Line
400}

Callers 5

doImportMethod · 0.85
nextOnSameLineMethod · 0.85
NextLineMethod · 0.85
isNewLineMethod · 0.85
isNextOnNewLineMethod · 0.85

Calls 1

NumLineBreaksMethod · 0.80

Tested by

no test coverage detected