-
Notifications
You must be signed in to change notification settings - Fork 229
Fix incorrect SubMonitor usage patterns #3542
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
base: master
Are you sure you want to change the base?
Fix incorrect SubMonitor usage patterns #3542
Conversation
4a53ae5 to
4391a91
Compare
326c667 to
cf4e18d
Compare
This commit addresses SubMonitor anti-patterns as described in https://www.eclipse.org/articles/Article-Progress-Monitors/article.html Changes: 1. Removed unnecessary done() calls on monitors after SubMonitor.convert() - SubMonitor automatically handles done() when work is complete - Affected files: * Refactoring.java * PerformChangeOperation.java * PerformRefactoringOperation.java * MultiStateTextFileChange.java * TextChange.java * SmartImportJob.java (2 instances) * SaveablesList.java * SaveableHelper.java * CheckConditionsContext.java 2. Removed redundant isCanceled() checks after split() calls - split() already includes implicit cancellation checks - Affected files: * ProcessorBasedRefactoring.java (4 instances) * CheckConditionsContext.java * SaveablesList.java * SaveableHelper.java These changes improve code quality by following SubMonitor best practices and removing redundant code that could mask issues.
cf4e18d to
1c845b0
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
| throw Changes.asCoreException(e); | ||
| } finally { | ||
| releaseDocument(document, subMon.newChild(1)); | ||
| subMon.done(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this cause eclipse-jdt/eclipse.jdt.ui#1833 to reappear? Or is this why the call to done() in getCurrentDocument(IProgressMonitor) remains?
My understanding is that the call to done() is only irrelevant, if the progress monitor is always used correctly. But I have yet to see a project where that is actually the case.
I.e. I would expect test failures in other components, which then also need to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. So should we leave it as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can already expect test failures in other components then I would definitely leave it out. For the rest, I'd have to take a closer look to see which are definitely save and which might cause side-effects.
Perhaps it makes sense to split this PR up? Have one for the removal of the isCanceled() check (which at first glance looks safe) and one for the removal of done().
This addresses the proposal by ptziegler in PR eclipse-platform#3542 to split the removal of isCanceled checks.
This addresses the proposal by ptziegler in PR #3542 to split the removal of isCanceled checks.
This commit addresses SubMonitor anti-patterns as described in https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
Changes:
Removed unnecessary done() calls on monitors after SubMonitor.convert()
Removed redundant isCanceled() checks after split() calls
These changes improve code quality by following SubMonitor best practices and removing redundant code that could mask issues.