@@ -287,6 +287,15 @@ struct ProviderArchitectureGatekeeperTests {
287287 #expect( references. first? . providerIDs == [ " claude " , " codex " ] )
288288 }
289289
290+ @Test
291+ func `provider reference scanner sees through inline block comments`() {
292+ let assignment = " let provider: UsageProvider = /* fallback */ .claude "
293+ let labeled = " choose(provider: /* fallback */ .claude) "
294+
295+ #expect( Self . providerReferences ( in: assignment, providerIDs: [ " claude " ] ) . count == 1 )
296+ #expect( Self . providerReferences ( in: labeled, providerIDs: [ " claude " ] ) . count == 1 )
297+ }
298+
290299 @Test
291300 func `single provider argument remains an architecture finding`() {
292301 let failures = Self . analyze (
@@ -4402,21 +4411,38 @@ struct ProviderArchitectureGatekeeperTests {
44024411 private static func codeBeforeLineComment( _ line: String ) -> String {
44034412 var previous : Character ?
44044413 var isInsideString = false
4405- var index = line. startIndex
4406- while index < line. endIndex {
4407- let character = line [ index]
4414+ var characters = Array ( line)
4415+ var index = 0
4416+ while index < characters. count {
4417+ let character = characters [ index]
44084418 if character == " \" " , previous != " \\ " {
44094419 isInsideString. toggle ( )
4410- } else if character == " / " , !isInsideString {
4411- let next = line. index ( after: index)
4412- if next < line. endIndex, line [ next] == " / " {
4413- return String ( line [ ..< index] )
4420+ } else if character == " / " , !isInsideString, index + 1 < characters. count {
4421+ if characters [ index + 1 ] == " / " {
4422+ return String ( characters [ ..< index] )
4423+ }
4424+ if characters [ index + 1 ] == " * " {
4425+ // Blank single-line block comments with spaces so punctuation adjacency stays
4426+ // visible to position heuristics while every character index is preserved.
4427+ var end = index + 2
4428+ while end + 1 < characters. count, !( characters [ end] == " * " && characters [ end + 1 ] == " / " ) {
4429+ end += 1
4430+ }
4431+ guard end + 1 < characters. count else {
4432+ return String ( characters [ ..< index] )
4433+ }
4434+ for blank in index... ( end + 1 ) {
4435+ characters [ blank] = " "
4436+ }
4437+ previous = " "
4438+ index = end + 2
4439+ continue
44144440 }
44154441 }
44164442 previous = character
4417- index = line . index ( after : index )
4443+ index += 1
44184444 }
4419- return line
4445+ return String ( characters )
44204446 }
44214447
44224448 private static func isIdentifierCharacter( _ character: Character ) -> Bool {
0 commit comments