Skip to content

Show progress when pre-calculating the AST during save #2414 - #2415

Open
fedejeanne wants to merge 1 commit into
eclipse-jdt:masterfrom
fedejeanne:show_progress_post_save_actions_ast
Open

Show progress when pre-calculating the AST during save #2414#2415
fedejeanne wants to merge 1 commit into
eclipse-jdt:masterfrom
fedejeanne:show_progress_post_save_actions_ast

Conversation

@fedejeanne

@fedejeanne fedejeanne commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

What it does

Fixes #2414

Show a progress dialog (after a delay) if the precalculation of the AST during a save takes too long.

Requires May be tested together with

The aforementioned PRs must not necessarily be merged before this one, but it would be nice to have them since they would avoid the "flickering" of the progress dialog showing up and immediately disappearing when the calculations of the AST and/or the cleanup changes take just a few milliseconds.

How to test

  • Activate a save action that requires an AST, e.g. "Organize imports"
  • Open a big class and make a modification
  • Save

Expected outcome
If the AST takes a while to calculate then you should see a (non-cancelable) progress dialog with a moving progress bar (IProgressMonitor.UNKNOWN).

image

Also, if calculating the changes takes a while, you should see another (non-cancelable) progress dialog with a moving progress bar (IProgressMonitor.UNKNOWN).

image

A small hack to help testing

You can simulate these long-running operations from the issue...

image

... by adding a delay like this one...

for (int i=0; i<5;i++) {
	try {
		Thread.sleep(1000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}

...to org.eclipse.jdt.internal.corext.fix.CleanUpPostSaveListener.createAst(ICompilationUnit, Map<String, String>, IProgressMonitor) (1) and another delay in org.eclipse.jdt.core.dom.ASTParser.createAST(IProgressMonitor) (2). Technically, the delay in the ASTParser should be enough to simulate both scenarios, but since the call to SharedASTProviderCore.getAST(...); inside CleanUpPostSaveListener.createAst(...) passes SharedASTProviderCore.WAIT_NO as parameter, it is really unlikely that the call will reach as deep as ASTParser::createAST.

Author checklist

@fedejeanne

Copy link
Copy Markdown
Contributor Author

Test failures are unrelated. I ran them all and they pass locally.

@carstenartur

Copy link
Copy Markdown
Contributor

Test failures are unrelated. I ran them all and they pass locally.

In general you cannot conclude that there is no issue when tests run through locally. It might be right in this case but is not in general.
See
#2213 (comment)

@fedejeanne
fedejeanne force-pushed the show_progress_post_save_actions_ast branch from 596a4ae to 086a0a4 Compare August 20, 2025 07:04
@fedejeanne

Copy link
Copy Markdown
Contributor Author

@carstenartur the test failures are unrelated and they are documented in #2423.

Since that issue has been fixed last week (see https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-github/job/master/474/testReport/), I rebased on master. That should get rid of the errors.

@fedejeanne
fedejeanne marked this pull request as draft August 20, 2025 07:06
@fedejeanne

Copy link
Copy Markdown
Contributor Author

I'm drafting this PR since I have no intention of merging it before M1

@fedejeanne

Copy link
Copy Markdown
Contributor Author

This PR is ready to be reviewed.

Even if the progress bar doesn't move (which is outside of the control of this PR), showing the progress dialog will IMO still improve the UX since the user at least will know that something is being done in the background. Better than a UI freeze.

@r-mennig
r-mennig force-pushed the show_progress_post_save_actions_ast branch 2 times, most recently from d36ec68 to abffb5f Compare June 11, 2026 07:43
@fedejeanne
fedejeanne force-pushed the show_progress_post_save_actions_ast branch from abffb5f to f8d950e Compare August 5, 2026 13:17
@fedejeanne
fedejeanne force-pushed the show_progress_post_save_actions_ast branch from f8d950e to fcd1c39 Compare August 5, 2026 13:18
@fedejeanne

Copy link
Copy Markdown
Contributor Author

I used m.beginTask(..., IProgressMonitor.UNKNOWN); in order to show indefinite progress in the dialog and I also added a second call to the newly added runUsingProgressService(...) so that both expensive calls from the issue show a progress dialog if necessary.

I updated the description of this PR to reflect these changes.

This PR is ready to be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] Precalculating AST during save freezes UI

2 participants