Skip to content

Commit bb12709

Browse files
Drop googleapis/api direct dependency in LSP CEL (#4356)
1 parent db0f95d commit bb12709

6 files changed

Lines changed: 266 additions & 369 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ linters:
192192
- linters:
193193
- gosec
194194
# G115 checks for use of truncating conversions.
195-
path: private/buf/buflsp/semantic_tokens_cel.go
195+
path: private/buf/buflsp/cel.go
196196
text: "G115:"
197197
- linters:
198198
- gosec

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ require (
4545
golang.org/x/sync v0.19.0
4646
golang.org/x/term v0.40.0
4747
golang.org/x/tools v0.42.0
48-
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d
4948
google.golang.org/protobuf v1.36.11
5049
gopkg.in/yaml.v3 v3.0.1
5150
mvdan.cc/xurls/v2 v2.6.0
@@ -109,6 +108,7 @@ require (
109108
golang.org/x/net v0.50.0 // indirect
110109
golang.org/x/sys v0.41.0 // indirect
111110
golang.org/x/text v0.34.0 // indirect
111+
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d // indirect
112112
google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
113113
google.golang.org/grpc v1.75.1 // indirect
114114
)

private/buf/buflsp/cel.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ func fileByteOffsetToCELOffset(fileByteOffset int, exprLiteralSpan source.Span)
193193
return -1
194194
}
195195

196+
// celLocByteOffset converts a CEL source location (line, col) to a byte offset
197+
// within exprString. line and col come from common.Location, which returns int,
198+
// but ComputeOffset requires int32; the conversion is safe for any realistic
199+
// CEL expression length.
200+
func celLocByteOffset(line, col int, sourceInfo *celast.SourceInfo, exprString string) int {
201+
runeOffset := int32(col) + sourceInfo.ComputeOffset(int32(line), 0)
202+
return celRuneOffsetToByteOffset(exprString, runeOffset)
203+
}
204+
196205
// celRuneOffsetToByteOffset converts a CEL source position (Unicode code point offset)
197206
// to a UTF-8 byte offset within the expression string.
198207
//

0 commit comments

Comments
 (0)