Skip to content

Classify each Find All References line while the search runs - #20533

Draft
xperiandri wants to merge 2 commits into
dotnet:mainfrom
xperiandri:feature/find-references-classified-lines
Draft

xperiandri wants to merge 2 commits into
dotnet:mainfrom
xperiandri:feature/find-references-classified-lines

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

Description

Find All References lists each reference with its line classified. C# and VB classify that line as they find the reference and hand it over. F# handed nothing, so after the search the window asked the F# classification service for the syntactic and semantic classification of every line again, one reference at a time. For a file that is not open, the semantic part comes from a whole-file classification kept for five seconds, so a long result list can outlive it and pay for it again.

dotnet/roslyn#85281 adds a FSharpSourceReferenceItem constructor that takes the classified line. This fills it while the search still has the checked file at hand.

ClassifiedReferenceLine classifies the line the way Roslyn's ClassifiedSpansAndHighlightSpanFactory and ClassifierHelper do:

  • the line runs from its first non-whitespace character to its end;
  • spans are sorted, clipped to the line, and a span overlapping the one before is dropped;
  • semantic spans win over the syntactic spans they overlap;
  • gaps are filled with plain text.

The references found in C# and VB projects are still classified by the window, which asks Roslyn.

Checklist

  • Test cases added: ClassifiedReferenceLineTests checks that an indented reference line is covered from its first non-whitespace character to its end, that the reference keeps its semantic classification, and that a literal keeps its syntactic one.
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated

Draft

This cannot build until dotnet/roslyn#85281 has flowed. Against a local build of dotnet/roslyn#85280 and #85281 together, the affected FSharp.Editor.Tests classes pass (145): Navigate To search, persistent cache, loading search and multi-target search, Find All References and multi-target Find All References, semantic classification, Copilot mentions, and the new tests.

🤖 Generated with Claude Code

C# and VB classify the line of each reference as they find it and hand it to
Find All References. F# handed nothing, so the window asked the F# classification
service for every line again after the search, one reference at a time.

ClassifiedReferenceLine classifies the line the way Roslyn does for them: from
the first non-whitespace character to the end of the line, semantic spans over
syntactic ones, gaps filled with text.

Needs the FSharpSourceReferenceItem constructor that takes the classified line,
from dotnet/roslyn#85281.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`vsintegration/src` docs/release-notes/.VisualStudio/18.vNext.md

Comment on lines 48 to 50
|> Array.tryFind (snd >> (=) doc.Project.FilePath)
|> Option.map (fun (definitionItem, _) -> definitionItem)
|> Option.defaultValue externalDefinitionItem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|> Option.defaultValue externalDefinitionItem
|> Array.tryFindV (snd >> (=) doc.Project.FilePath)
|> ValueOption.map (fun (definitionItem, _) -> definitionItem)
|> ValueOption.defaultValue externalDefinitionItem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split out as #20534 — this line isn't touched by this PR.

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖🕵️ Please shorten the description using this guidance. Focus on the problem and why the change is needed, in simplified technical English. Leave the implementation inventory to the Files tab and retain necessary caveats.

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants