Adding custom non-navigatable results to CustomUsageSearcher

I'm trying to add usages that are outside the project and therefore are non-navigateble.

In my first attempt I returned a very naive UsageInfo which basically only has a text and is valid and non-navigateble. The usage search then says that n usages are outside the search scope "All places". I determined this is the case because `com.intellij.usages.impl.UsageViewManagerImpl#isInScope` returns false for this usage. I then made my usage implement `UsageInFile` and return `NullVirtualFile.INSTANCE`.

Now I get the following error:


2022-01-14 12:35:37,058 [ 32711] ERROR - d.findUsages.FindUsagesManager - VirtualFile.NULL_OBJECT
java.lang.UnsupportedOperationException: VirtualFile.NULL_OBJECT
at com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile.unsupported(StubVirtualFile.java:217)
at com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile.getParent(StubVirtualFile.java:67)
at com.intellij.usages.impl.rules.DirectoryGroupingRule.getParentGroupFor(DirectoryGroupingRule.java:70)
at com.intellij.usages.rules.SingleParentUsageGroupingRule.getParentGroupsFor(SingleParentUsageGroupingRule.java:37)
at com.intellij.usages.impl.UsageNodeTreeBuilder.appendOrGet(UsageNodeTreeBuilder.java:60)
at com.intellij.usages.impl.UsageViewImpl.doAppendUsage(UsageViewImpl.java:1368)
at com.intellij.usages.impl.UsageViewImpl.appendUsage(UsageViewImpl.java:1316)
at com.intellij.usages.impl.SearchForUsagesRunnable.lambda$searchUsages$9(SearchForUsagesRunnable.java:421)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:839)
at com.intellij.usages.impl.SearchForUsagesRunnable.lambda$searchUsages$10(SearchForUsagesRunnable.java:421)
at de.sist.tph.intellij.gitlab.referencesearch.ui.CustomUsageSearcher.processElementUsages(CustomUsageSearcher.java:28)

How do I add a custom usage that's actually displayed?

Please sign in to leave a comment.