JetBrains / JetBrains/resharper-unity

Fix presentation of asset results for ReSharper

Open
#1,782 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

Find Usage results on asset occurrences is broken in ReSharper:

* *No grouping*. The occurrence has an `IPsiSourceFile` instance, but no `IProjectFile`, and this is required for grouping by project structure. I'm not sure if we've ever done this - it's worth checking history of `UnityMiscFilesProjectPsiModuleProvider.cs` and `UnityExternalFilesModuleProcessor.cs`
* *No presentation*. When doing Show Usages, `UnityEditorOccurrencePresenter` is called. This isn't called for Find Usages, so we don't get a pretty printed component path. Looks like `OccurrenceBrowserPresenter` only handles a certain set of occurrences, such as `RangeOccurrence`, `IDeclaredElementOccurrence`, `ProjectItemOccurrence` and so on. `IOccurrence` is supported, but gets base level presntation. Perhaps our asset occurrences should be instances of `RangeOccurrence` or `FileSystemPathOccurrence`? Or perhaps `OccurrenceBrowserPresenter.PresentBaseOccurrence` should use `IOccurrencePresenter`?
* *No offset in presentation*. Normal C# usages show an offset to the usage (in blue) as part of the output. This is missing in both Find Usages + Show Usages.
* *No navigation*. ReSharper doesn't have an [implementation for this](https://github.com/JetBrains/resharper-unity/blob/f612fb116b882ecafe940109404b3d50126accb3/resharper/resharper-unity/src/Yaml/Feature/Services/Navigation/UnityAssetOccurrenceNavigator.cs#L10). There's not much we can do, as we don't have a connection to the Unity Editor. The only thing we could do is open the file, which isn't really useful, as the files are not editable, and could be massive. Maybe just show a dialog to say "unsupported" instead of silently doing nothing?
* Unity occurrences are grouped as "textual occurrences". A better classification is "late bound occurrences", as they are used programmatically, but dynamically.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the history of UnityMiscFilesProjectPsiModuleProvider.cs and UnityExternalFilesModuleProcessor.cs, then inspect OccurrenceBrowserPresenter and UnityAssetOccurrenceNavigator.cs. Compare the listed grouping, presentation, offset, navigation, and occurrence-classification concerns with the existing occurrence types; done means the ReSharper asset results have an agreed, working treatment for each concern.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.