Skip organize imports on save while the type indexer is busy#3058
Open
vogella wants to merge 1 commit into
Open
Skip organize imports on save while the type indexer is busy#3058vogella wants to merge 1 commit into
vogella wants to merge 1 commit into
Conversation
When Organize Imports runs as a save action, resolving missing imports uses SearchEngine.searchAllTypeNames with WAIT_UNTIL_READY_TO_SEARCH. Right after startup, a branch switch or a large build this blocks the save until indexing finishes, which regularly exceeds the 2s threshold and triggers the 'Slow Save Actions' warning dialog. OrganizeImportsOperation gets a new API setSkipWhenIndexerBusy. When enabled, the type search uses CANCEL_IF_NOT_READY_TO_SEARCH and the operation creates no edit while the indexer is busy instead of waiting. CleanUpPostSaveListener enables this for the save actions, so a save never waits for the index; a missing import is added on the next save once the index is ready. The Clean Up wizard and the manual Organize Imports action keep waiting as before.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When Organize Imports is enabled as a save action, resolving missing imports searches the type index with WAIT_UNTIL_READY_TO_SEARCH. Saving right after startup, a branch switch or a large build therefore blocks until indexing finishes, which regularly exceeds the 2 second threshold and greets the user with the "Slow Save Actions" warning dialog.
This adds OrganizeImportsOperation#setSkipWhenIndexerBusy, which makes the type search use CANCEL_IF_NOT_READY_TO_SEARCH and produce no edit while the indexer is busy. The save actions enable it, so saving stays fast and a missing import is simply added on the next save once the index is ready. The Clean Up wizard and the manual Organize Imports action are unchanged and still wait for the index.