Repository navigation
Let integrations mark references as read or write access in Find Usages #1676
Closed
ShiningPluto
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Is there any chance to have a PR? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm working on a Rider plugin for Unreal Engine AngelScript that uses LSP4IJ to talk to the AngelScript language server. One thing I've been missing is that Find Usages can't tell reads from writes the way it does for C++ in the same IDE. For a variable that's used all over the place, being able to hide the reads and only see where it gets assigned is pretty handy.
The server can't help with this, since
textDocument/referencesonly returns locations. But the plugin has its own parser for AngelScript, so it can work out read/write for each reference by itself. The problem is getting that into the usage view:ReadWriteAccessUsage. That has to be theUsageobject itself, andLSPUsageSearcheralways creates a plainUsageInfo2UsageAdapter.UsageTypeProviderregistered withorder="first", so references can be grouped as "Value read" / "Value write". But I found no way to make the filters work. Registering our own filtering rules just adds a second pair of toggle buttons, and we can't replaceLSPUsageSearcherfor our files without also turning off LSP4IJ's Find Usages handler, since both go through the same check.So I'd like to propose a small opt-in hook on
LSPUsageFeature, next toisUsageSupportedfrom #1522:It would be called in a read action, and only for results of
textDocument/references. When it returns an access,LSPUsageSearchercreates aReadWriteAccessUsageInfo2UsageAdapterinstead of the plain adapter, andLSPUsageTypeProviderreturnsUsageType.READ/UsageType.WRITEinstead of "References". When it returns null, which is the default, nothing changes, so existing integrations aren't affected.I also looked at going through the platform's
ReadWriteAccessDetector(viaUsageInfoToUsageConverter), but I don't think it fits well here:ReadWriteUtilcalls every registered detector without catching anything, so a single detector that throws on LSP4IJ's PSI elements would break Find Usages for all language servers.getExpressionAccesshas to return an access, so declarations and definitions would get one too, and hiding reads would hide them as well.A more generic option could be to use the
DocumentHighlightKindfromtextDocument/documentHighlightas a default. I left that out because it means an extra request per file on every search, and servers tend to mark only plain assignments as writes. The hook wouldn't get in the way of adding that later, though.One more thing I noticed while testing, in case it's useful: Rider unregisters the platform's
UsageGroupingRuleProviderImpl(inRiderExtensionsConfigurator), so in Rider the usage types fromLSPUsageTypeProvidernever show up at all, not even "References" or "Declarations". I checked this in 2025.2 and 2026.2. So in Rider this change would only show up as the icons and the filters, and the grouping still needs something on the plugin side. Not sure whether that's something LSP4IJ wants to deal with, just mentioning it.Thanks!
All reactions