@@ -252,21 +252,62 @@ type TestType() =
252252
253253 let ranges = getRanges sourceText
254254
255- // The parameter name "optional" should be classified as a parameter/local value, not as a type
256- // After the fix, QuickParse correctly handles the ? prefix and doesn't confuse semantic classification
257- let optionalParamRanges =
255+ // Debug: print all ranges to understand what we're getting
256+ let allClassifications =
258257 ranges
259- |> List.filter ( fun item ->
260- let text =
261- sourceText.Substring( item.Range.StartColumn, item.Range.EndColumn - item.Range.StartColumn)
262-
263- text = " optional" )
264-
265- // Verify that we have classification data for "optional"
266- Assert.True( optionalParamRanges.Length > 0 , " Should have classification data for 'optional' parameter" )
258+ |> List.map ( fun item ->
259+ let startLine = item.Range.StartLine
260+ let startCol = item.Range.StartColumn
261+ let endLine = item.Range.EndLine
262+ let endCol = item.Range.EndColumn
263+ let lines = sourceText.Split( '\n' )
267264
268- // The first occurrence should be the parameter (not incorrectly classified as a type/namespace)
269- let firstOptional = optionalParamRanges.[ 0 ]
265+ let text =
266+ if startLine = endLine && startLine < lines.Length then
267+ let line = lines.[ startLine]
268+
269+ if startCol < line.Length && endCol <= line.Length then
270+ line.Substring( startCol, endCol - startCol)
271+ else
272+ sprintf " [out of bounds: %d -%d in line length %d ]" startCol endCol line.Length
273+ else
274+ " [multi-line]"
275+
276+ sprintf " Line %d , Col %d -%d : '%s ' (%A )" startLine startCol endCol text item.Type)
277+ |> String.concat " \n "
278+
279+ // The test should verify that optional parameter usage (the return value) is classified
280+ // We check for "optional" identifier in the body (after =)
281+ let optionalUsageRanges =
282+ ranges
283+ |> List.filter ( fun item ->
284+ let startLine = item.Range.StartLine
285+ let startCol = item.Range.StartColumn
286+ let endCol = item.Range.EndColumn
287+ let lines = sourceText.Split( '\n' )
288+
289+ if startLine < lines.Length then
290+ let line = lines.[ startLine]
291+
292+ if startCol < line.Length && endCol <= line.Length then
293+ let text = line.Substring( startCol, endCol - startCol)
294+ text = " optional"
295+ else
296+ false
297+ else
298+ false )
299+
300+ // Provide detailed error message if test fails
301+ let errorMessage =
302+ sprintf
303+ " Should have classification data for 'optional' identifier.\n Found %d ranges total.\n All classifications:\n %s "
304+ ranges.Length
305+ allClassifications
306+
307+ Assert.True( optionalUsageRanges.Length > 0 , errorMessage)
308+
309+ // If we found "optional", verify it's not classified as a type or namespace
310+ let firstOptional = optionalUsageRanges.[ 0 ]
270311
271312 let classificationType =
272313 FSharpClassificationTypes.getClassificationTypeName firstOptional.Type
0 commit comments