Bug 542106 - [9][quick fix] "The fix 'Remove unused import' generated a null change." in module-info.java
Summary: [9][quick fix] "The fix 'Remove unused import' generated a null change." in m...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.10   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.11 RC1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-04 15:32 EST by Stephan Herrmann CLA
Modified: 2019-02-28 02:24 EST (History)
2 users (show)

See Also:
manoj.palat: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2018-12-04 15:32:25 EST
(1) Have unused imports in module-info.java
(2) Try to get rid of them
(2.a) Quick fix from the editor
(2.b) Multi fix from the Problems view

Result with either (2.a) or (2.b):
org.eclipse.core.runtime.CoreException: The fix 'Remove unused import' generated a null change.
	at org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.createChange(CompilationUnitRewriteOperationsFixCore.java:103)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.createTextChange(FixCorrectionProposal.java:152)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:203)
	at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:328)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.getTextChange(CUCorrectionProposal.java:214)
	at org.eclipse.jdt.core.manipulation.CUCorrectionProposalCore.getAdditionalProposalInfo(CUCorrectionProposalCore.java:132)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:138)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.getAdditionalProposalInfo(FixCorrectionProposal.java:134)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$Timer$2$1.run(AdditionalInfoController.java:116)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)


Additionally, in the editor you may see:

java.lang.NullPointerException
	at org.eclipse.jdt.core.manipulation.CUCorrectionProposalCore.getAdditionalProposalInfo(CUCorrectionProposalCore.java:133)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:138)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.getAdditionalProposalInfo(FixCorrectionProposal.java:134)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$Timer$2$1.run(AdditionalInfoController.java:116)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 1 Stephan Herrmann CLA 2018-12-04 15:51:31 EST
The quick fix is not to blame, bug JDT/Core's ASTRewriteAnalyzer.visit(CompilationUnit) skips package & imports if it detects a module. Outch.
Comment 2 Eclipse Genie CLA 2018-12-04 17:34:37 EST
New Gerrit change created: https://git.eclipse.org/r/133491
Comment 3 Stephan Herrmann CLA 2018-12-04 17:50:40 EST
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/133491

Draft of a fix. Not tests yet.
Comment 4 Stephan Herrmann CLA 2019-02-19 16:37:07 EST
Test has been added in patch set #2 (rebased as #3) - which, when run without the fix, demonstrates that rewriting of imports in module-info does not work.

@Jay, @Manoj, can one of you please +1 for RC1? TIA.
Comment 5 Stephan Herrmann CLA 2019-02-19 16:48:56 EST
I also smoke-tested in the IDE that organize imports now works in module-info.
Comment 6 Manoj N Palat CLA 2019-02-26 05:10:13 EST
(In reply to Stephan Herrmann from comment #4)
> Test has been added in patch set #2 (rebased as #3) - which, when run
> without the fix, demonstrates that rewriting of imports in module-info does
> not work.
> 
> @Jay, @Manoj, can one of you please +1 for RC1? TIA.

+1
Comment 8 Stephan Herrmann CLA 2019-02-26 06:09:52 EST
(In reply to Eclipse Genie from comment #7)
> Gerrit change https://git.eclipse.org/r/133491 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=9a6c75cf8038040b323dac130925f5927eb35cc5

Thanks Manoj, the change has thus been released for 4.11 RC1
Comment 9 Jay Arthanareeswaran CLA 2019-02-28 02:24:12 EST
Verified for 4.11 RC1 using build I20190227-1800