MCPcopy Create free account
hub / github.com/bytebase/bytebase / positionFromByteOffset

Function positionFromByteOffset

backend/plugin/parser/tsql/backup.go:526–542  ·  view source on GitHub ↗
(start *storepb.Position, source string, offset int)

Source from the content-addressed store, hash-verified

524}
525
526func positionFromByteOffset(start *storepb.Position, source string, offset int) *storepb.Position {
527 if offset < 0 {
528 offset = 0
529 }
530 if offset >= len(source) && len(source) > 0 {
531 offset = len(source) - 1
532 }
533 line, column := base.CalculateLineAndColumn(source, offset)
534 startLine := int32(1)
535 if start != nil {
536 startLine = start.Line
537 }
538 return &storepb.Position{
539 Line: startLine + int32(line),
540 Column: int32(column),
541 }
542}
543
544func dmlEndOffset(source string, loc ast.Loc) int {
545 if loc.End >= 0 && loc.End < len(source) && source[loc.End] == ';' {

Callers 2

prepareTransformationFunction · 0.85
statementPositionsFunction · 0.85

Calls 1

CalculateLineAndColumnFunction · 0.92

Tested by

no test coverage detected