Skip to content
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

If no editor is open apply the resolution directly #1961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Jan 22, 2025

What it does

Currently if one applies a QuickFix without the java editor open (e.g. from the Problems view), then JDT opens a new editor, applies the quickfix and then leave the user in a dirty state, so the error/warning is still shown in the problems view unless one manually save the editor.

This now changes the behavior by apply the resolution directly on the document and commit (or save) the compilation unit.

How to test

I use this simple test class:

@SuppressWarnings("restriction")
public class TestWarning {

}

it will produce:

Description	Resource	Path	Location	Type
Unnecessary @SuppressWarnings("restriction")	TestWarning.java   ...	line 4	Java Problem
  1. Open the file and apply the quickfix in the editor --> works as before with dirty editor
  2. No restore the file and make sure all editors are closed
  3. Make sure all editors are closed
  4. Got to the problem view and rightclick on the warning choose "QuickFix" to open the Wizard

grafik

You will end up with the problem resolved and no dirty editor.

Author checklist

@akurtakov
Copy link
Contributor

@jjohnstn What do you think? I am in favor of this approach but want to be sure that there isn't some obscure detail missed.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 23, 2025

Build is green!

Copy link
Contributor

@jukzi jukzi left a comment

Choose a reason for hiding this comment

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

I have no opinion if this change is any good but i think all Quickfixes should behave the same. So if changing this, then also change org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.apply(IDocument) and org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator.CorrectionMarkerResolution.run(IMarker[], IProgressMonitor) the same way

@jukzi
Copy link
Contributor

jukzi commented Jan 23, 2025

also
org.eclipse.jdt.internal.ui.text.correction.proposals.CreatePackageInfoWithDefaultNullnessProposal.apply(IDocument)

@laeubi
Copy link
Contributor Author

laeubi commented Jan 23, 2025

If this is fixed (and proven to work) then yes one can maybe change other places as well, I just have no test-case to validate any other problem right now.

Currently if one applies a QuickFix without the java editor open (e.g.
from the Problems view), then JDT opens a new editor, applies the
quickfix and then leave the user in a dirty state, so the error/warning
is still shown in the problems view unless one manually save the editor.

This now changes the behavior by apply the resolution directly on the
document and commit (or save) the compilation unit.
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.

3 participants