currentStatement returns the statement containing byte position pos within statement, along with pos translated to an offset within that statement. It uses omni's splitter so completion sees only the caret's statement, not table references from earlier statements in the buffer.
(statement string, pos int)
| 547 | // uses omni's splitter so completion sees only the caret's statement, not table |
| 548 | // references from earlier statements in the buffer. |
| 549 | func currentStatement(statement string, pos int) (string, int) { |
| 550 | for _, seg := range tidbparser.Split(statement) { |
| 551 | if pos >= seg.ByteStart && pos <= seg.ByteEnd { |
| 552 | return seg.Text, pos - seg.ByteStart |
| 553 | } |
| 554 | } |
| 555 | return statement, pos |
| 556 | } |
| 557 | |
| 558 | // omniCandidateTypeToBase maps omni TiDB completion candidate types to the |
| 559 | // Bytebase base types. The six core types (keyword/database/table/view/column/ |