@@ -221,24 +221,22 @@ func collectMacroTokens(
221221 if startLoc .Line () <= 0 {
222222 continue
223223 }
224- celRuneOffset := int32 (startLoc .Column ()) + sourceInfo .ComputeOffset (int32 (startLoc .Line ()), 0 )
225-
226224 // For method-style macros like this.all(...), we need to find the method name
227225 // For standalone macros like has(...), we need to find the function name
228226 if call .IsMemberFunction () {
229227 // Method call - search for ".funcName" after the target
230228 targetID := call .Target ().ID ()
231229 targetLoc := sourceInfo .GetStartLocation (targetID )
232230 if targetLoc .Line () > 0 {
233- targetByteOffset := celRuneOffsetToByteOffset ( exprString , int32 ( targetLoc .Column ()) + sourceInfo . ComputeOffset ( int32 ( targetLoc .Line ()), 0 ) )
231+ targetByteOffset := celLocByteOffset ( targetLoc .Line (), targetLoc .Column (), sourceInfo , exprString )
234232 tokenSpan := findNameAfterDot (targetByteOffset , funcName , exprString , exprLiteralSpan )
235233 if ! tokenSpan .IsZero () {
236234 collectToken (tokenSpan , semanticTypeMacro , 0 , keyword .Unknown )
237235 }
238236 }
239237 } else {
240238 // Standalone function call - CEL position points to opening paren, look backwards
241- celByteOffset := celRuneOffsetToByteOffset ( exprString , celRuneOffset )
239+ celByteOffset := celLocByteOffset ( startLoc . Line (), startLoc . Column (), sourceInfo , exprString )
242240 funcStart := celByteOffset - len (funcName )
243241 funcEnd := funcStart + len (funcName )
244242 if funcStart >= 0 && funcEnd <= len (exprString ) {
@@ -273,7 +271,7 @@ func walkCELExprWithVars(
273271 if startLoc .Line () <= 0 {
274272 return
275273 }
276- celByteOffset := celRuneOffsetToByteOffset ( exprString , int32 ( startLoc .Column ()) + sourceInfo . ComputeOffset ( int32 ( startLoc .Line ()), 0 ) )
274+ celByteOffset := celLocByteOffset ( startLoc .Line (), startLoc .Column (), sourceInfo , exprString )
277275
278276 var tokenSpan source.Span
279277
@@ -318,7 +316,7 @@ func walkCELExprWithVars(
318316 if sel .Operand () != nil {
319317 targetLoc := sourceInfo .GetStartLocation (sel .Operand ().ID ())
320318 if targetLoc .Line () > 0 {
321- targetByteOffset := celRuneOffsetToByteOffset ( exprString , int32 ( targetLoc .Column ()) + sourceInfo . ComputeOffset ( int32 ( targetLoc .Line ()), 0 ) )
319+ targetByteOffset := celLocByteOffset ( targetLoc .Line (), targetLoc .Column (), sourceInfo , exprString )
322320 tokenSpan = findNameAfterDot (targetByteOffset , sel .FieldName (), exprString , exprLiteralSpan )
323321 if ! tokenSpan .IsZero () {
324322 collectToken (tokenSpan , semanticTypeProperty , 0 , keyword .Unknown )
@@ -373,7 +371,7 @@ func walkCELExprWithVars(
373371 // Method call - search for the function name after the target
374372 targetLoc := sourceInfo .GetStartLocation (call .Target ().ID ())
375373 if targetLoc .Line () > 0 {
376- targetByteOffset := celRuneOffsetToByteOffset ( exprString , int32 ( targetLoc .Column ()) + sourceInfo . ComputeOffset ( int32 ( targetLoc .Line ()), 0 ) )
374+ targetByteOffset := celLocByteOffset ( targetLoc .Line (), targetLoc .Column (), sourceInfo , exprString )
377375 tokenSpan = findNameAfterDot (targetByteOffset , funcName , exprString , exprLiteralSpan )
378376 if ! tokenSpan .IsZero () {
379377 collectToken (tokenSpan , tokenType , tokenModifier , keyword .Unknown )
0 commit comments