Addition note about intention and quick-fixes execution in UI thread

This commit is contained in:
Nikolay Krasko
2019-04-22 14:39:20 +03:00
parent bd78e7e0aa
commit 01c0c3c924
@@ -39,6 +39,11 @@ function when descriptor is absent.
invalidated by the moment of the actual quick fix execution. Avoid the code that can throw exceptions because of that. Re-checks with early
exit from the quick fix can be used to workaround it.
- Intentions and quick fixes execution happens in the UI thread so do not call long operations such as usages search or resolve to avoid
freezes. `PSI` elements obtained from resolve during the applicability check can be stored in `SmartPsiElementPointer` for the postponed
modification in quick-fixes. All complex searches should be executed in a background thread under a progress indicator. Some tests
already assert that resolve operations are not called from UI thread while applying fixes.
- There shouldn't be PSI elements stored in QuickFix classes (`val psi: PsiElement`) as such elements might be invalidated and can lead
to memory leaks. Smart pointer (check `SmartPsiElementPointer` class and `createSmartPointer()` function) can be used when such storage
is absolutely necessary.