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 2 times, most recently 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.

@iloveeclipse
iloveeclipse requested a balanced review from Copilot August 12, 2026 15:23
@iloveeclipse

Copy link
Copy Markdown
Member

I'm going to vacation after M3, and progress things are tricky, so better schedule that for next release cycle. Please ping me once 4.42 starts.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds delayed, non-cancelable progress reporting for expensive save-action processing.

Changes:

  • Runs AST creation and cleanup calculation through the workbench progress service.
  • Adds localized task names for both operations.
  • Preserves exception propagation for cleanup failures.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
CleanUpPostSaveListener.java Adds progress-service execution around expensive save operations.
FixMessages.properties Adds progress task labels.
FixMessages.java Exposes the new localized messages.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@fedejeanne
fedejeanne force-pushed the show_progress_post_save_actions_ast branch from fcd1c39 to ff930f4 Compare August 13, 2026 10:11
@fedejeanne
fedejeanne force-pushed the show_progress_post_save_actions_ast branch from ff930f4 to a7ea642 Compare August 13, 2026 10:21
@fedejeanne

Copy link
Copy Markdown
Contributor Author

Please ping me once 4.42 starts.

ping @iloveeclipse :-)

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

4 participants