isNextOnNewLine tests whether t2 is on a different line from t1
(t1, t2 Token)
| 376 | |
| 377 | // isNextOnNewLine tests whether t2 is on a different line from t1 |
| 378 | func 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 | } |
no test coverage detected