Repository navigation
Resolve cref links in hover and documentation - #1527
Conversation
|
Ok this is sick as hell |
|
Pushed follow-up commit Local verification on that commit:
GitHub created a new workflow run for |
|
This still isn't quite ready actually, will drop a note when it's tested to my satisfaction. |
|
Okay I'm good with this now. |
|
🤖 This is an automated response from Repo Assist. Great contribution, What this adds (nicely):
One thing worth confirming: The If this is already handled, feel free to disregard — just flagging it as a potential hot path concern. Overall this is well-structured and fills a real usability gap. Nice work!
|
|
Good call. It was being rebuilt in the hover and documentation paths for the same I pushed Rechecked with:
|
f0adfde to
7f29134
Compare
Three fixes that came out of measuring FSAC's memory on the Fantomas solution with the transparent compiler. One commit each. `CHANGELOG.md` gets a 0.85.1 section, so merging this publishes 0.85.1. ## Changes - **Build the cref resolver only when a doc comment has a cref** (`ParseAndCheckResults.fs`). Hover asked for the resolver on every tooltip, and building it lists every entity of every referenced assembly. Now it is built on the first cref it resolves. This came in with #1527, so 0.85.0 has it. - **Skip files without the symbol's name in Find References** (`AdaptiveServerState.fs`, `String.containsIdentifier` in `Utils.fs`). FCS 43.12 imports all references of a project before it parses a file of it, also when the file then fails FCS's own identifier test. FSAC now checks the text of the file for the name as a whole identifier first. FCS takes its identifiers from the tokens of the file, so this skips no file FCS would search. Transparent compiler only: the background compiler path searches without an identifier test, so the filter could change its results. - **Make `DisableInMemoryProjectReferences` work again** (`ProjectWorkspace.fs`, `AdaptiveServerState.fs`). It has done nothing since #1174. With the setting on, a referenced F# project comes from its output DLL, for both compilers, and Find References follows MSBuild's project references to find dependent projects. The unused `FSharpCompilerServiceChecker.DisableInMemoryProjectReferences` property is removed. The setting stays off by default: a DLL does not show changes made since the last build. ## Results Fantomas solution, transparent compiler, replaying a reading session: open `CodePrinter.fs`, hover, navigate, read `SyntaxOak.fs`, then Find References on `SyntaxOak.Expr`. | | Before | After | |---|--:|--:| | Memory at the end of the session | 1,170 MB | 770 MB | | Memory added by the first hover | 65 MB | 1 MB | | Memory added by Find References | 480 MB | 215 MB | | First hover | 1.1 s | 50 ms | | Find References | 3.0 s | 1.5 s | Averages of four runs before and three after; runs differ by up to 40 MB. Find References returns the same 672 references in 9 files before and after, and with `DisableInMemoryProjectReferences` on. ## Tests - `CoreUtilsTests.fs`: `String.containsIdentifier` (whole identifiers, `'a`, backticks, operators). - `SnapshotTests.fs`: with the setting on, Console1 references `Library1.dll` as a PE reference. - Full suite, net10.0, both compilers: 5,863 passed, 0 failed. ## Related - dotnet/fsharp#20704 parses a file without the bootstrap info. With it, FCS would not import references for a file that fails the identifier test, and the text filter here would only save the parse. - dotnet/fsharp#20755: the transparent compiler keeps every file's name resolution sink, whatever `keepAllBackgroundResolutions` and `keepAllBackgroundSymbolUses` say. - ionide/proj-info#248: MSBuild's in-process node keeps the evaluated projects, about 45 MB here.
Summary
<see cref>and<seealso cref>targets with clean display textdocumentationSymbolresilient when matching symbols from metadataWhy
The original issue started in tooltip formatting, but there was a second problem in the click path. Hover links only carried the target symbol, so the VS Code side sometimes had to fall back to the current cursor position when resolving the clicked link. If the cursor had already moved, the Info Panel could open the wrong symbol or stay blank.
This change makes the link payload self-contained. The new source-context fields are optional, so existing callers still work.
Testing
dotnet fantomas --check build.fsx srcdotnet test test/FsAutoComplete.Tests.Lsp/FsAutoComplete.Tests.Lsp.fsproj -f net8.0 --filter "cref link integration tests"xthen clickAsyncopensAsyncdocs across fresh launchesContext