Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PsiInvalidElementAccessException when clicking on stale element in Find view #147

Open
fbricon opened this issue Feb 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@fbricon
Copy link
Contributor

fbricon commented Feb 20, 2024

I haven't managed to reproduce it, but basically, after finding usages of an element, if you delete the reference in the code, then matching reference in the Find view becomes stale and I ended up with this exception:

com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.psi.impl.source.PsiPlainTextFileImpl #TEXT  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=file:///Users/fbricon/Dev/projects/lemminx/foo/src/main/typescript/index.ts, vFileId=311, content=VirtualFileContent{size=239}, eventSystemEnabled=true}(79c9e275); com.intellij.psi.SingleRootFileViewProvider{vFile=file:///Users/fbricon/Dev/projects/lemminx/foo/src/main/typescript/index.ts, vFileId=311, content=VirtualFileContent{size=239}, eventSystemEnabled=true}(3df47da6)
invalidated at: see attachment; Element class com.redhat.devtools.lsp4ij.usages.LSPUsagePsiElement(Language: ANY) claims to be valid but returns invalid containing file
	at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.ensureValid(SmartPointerManagerImpl.java:114)
	at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:82)
	at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:75)
	at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:70)
	at com.intellij.psi.impl.ElementBase$ElementIconRequest.<init>(ElementBase.java:164)
	at com.intellij.psi.impl.ElementBase$ElementIconRequest.<init>(ElementBase.java:159)
	at com.intellij.psi.impl.ElementBase.computeIcon(ElementBase.java:80)
	at com.intellij.psi.impl.ElementBase.getIcon(ElementBase.java:60)
	at com.intellij.psi.impl.FakePsiElement.getIcon(FakePsiElement.java:121)
	at com.intellij.usages.UsageInfo2UsageAdapter.computeIcon(UsageInfo2UsageAdapter.java:555)
	at com.intellij.usages.UsageInfo2UsageAdapter.doUpdateCachedPresentation(UsageInfo2UsageAdapter.java:484)
	at com.intellij.usages.UsageInfo2UsageAdapter.updateCachedPresentation(UsageInfo2UsageAdapter.java:476)
	at com.intellij.usages.impl.UsageNode.updateCachedPresentation(UsageNode.java:74)
	at com.intellij.usages.impl.Node.update(Node.java:98)
	at com.intellij.usages.impl.UsageViewImpl.lambda$queueUpdateBulk$37(UsageViewImpl.java:1522)

I believe the problem is LSPPsiElement.isValid() always returns true.

When deleting a java reference for instance, the usage should show as INVALID
Screenshot 2024-02-20 at 10 03 50

When the exception isn't thrown, I see the element in the find view is just updated to a blank line or the code replacing the deleted reference.

Feb-20-2024.12-00-24.mp4
@fbricon fbricon added the bug Something isn't working label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant