Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ linters:
- linters:
- gosec
# G115 checks for use of truncating conversions.
path: private/buf/buflsp/semantic_tokens_cel.go
path: private/buf/buflsp/cel.go
text: "G115:"
- linters:
- gosec
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ require (
golang.org/x/sync v0.19.0
golang.org/x/term v0.40.0
golang.org/x/tools v0.42.0
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
mvdan.cc/xurls/v2 v2.6.0
Expand Down Expand Up @@ -109,6 +108,7 @@ require (
golang.org/x/net v0.50.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
google.golang.org/grpc v1.75.1 // indirect
)
9 changes: 9 additions & 0 deletions private/buf/buflsp/cel.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ func fileByteOffsetToCELOffset(fileByteOffset int, exprLiteralSpan source.Span)
return -1
}

// celLocByteOffset converts a CEL source location (line, col) to a byte offset
// within exprString. line and col come from common.Location, which returns int,
// but ComputeOffset requires int32; the conversion is safe for any realistic
// CEL expression length.
func celLocByteOffset(line, col int, sourceInfo *celast.SourceInfo, exprString string) int {
runeOffset := int32(col) + sourceInfo.ComputeOffset(int32(line), 0)
return celRuneOffsetToByteOffset(exprString, runeOffset)
}

// celRuneOffsetToByteOffset converts a CEL source position (Unicode code point offset)
// to a UTF-8 byte offset within the expression string.
//
Expand Down
Loading