Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 525808 - [9][quick fix] Export of non-existent or empty package should offer quick fixes
Summary: [9][quick fix] Export of non-existent or empty package should offer quick fixes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.7.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.8 M7   Edit
Assignee: Kalyan Prasad Tatavarthi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-10 05:02 EDT by Andreas Sewe CLA
Modified: 2018-04-16 06:20 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2017-10-10 05:02:44 EDT
A simple module-info.java like the following

module example {
	exports org.example;
}

should offer a quickfix to create the package org.example if it does not exist.

Granted, the compilation error will not go away, as the package is still empty, but opening the New Java Package wizard would still be helpful. (FWIW, this is the same logic as for the Create Java Class quickfix on provides...with, which is covered in Bug 522205.)
Comment 1 Stephan Herrmann CLA 2017-10-10 09:36:15 EDT
Makes sense, to some degree.

In JLS speak, you'd need to create a CU declaring the package in order to create the package. That's why our Create Package wizard is not enough to resolve the error.

Hence: what do you think about opening a new class / new interface wizard, with the package pre-fill and prompting the user to provide a type name? Makes more sense to me, but not sure if this will confuse users.
Comment 2 Andreas Sewe CLA 2017-10-10 10:03:16 EDT
(In reply to Stephan Herrmann from comment #1)
> In JLS speak, you'd need to create a CU declaring the package in order to
> create the package. That's why our Create Package wizard is not enough to
> resolve the error.

True, although a package-info.java is enough to satisfy the CU requirement.

That being said, I imagine the average user doesn't think about the JLS but rather about the steps he or she has to do to fix this:

 1. New > Package
 2. New > Class, New > Interface, ...

Then my original proposal would at least automate step 1.

> Hence: what do you think about opening a new class / new interface wizard,
> with the package pre-fill and prompting the user to provide a type name?
> Makes more sense to me, but not sure if this will confuse users.

Interesting, although it probably requires *multiple* quickfixes. After all, you don't know whether the user has New > Class, New > Interface, or something else in mind for Step 2 above. But then pre-filling the package makes absolutely sense.
Comment 3 Noopur Gupta CLA 2017-10-15 09:51:35 EDT
Based on comment #2, it will be good to open the New Package wizard when the package does not exist.

In case the package exists and is empty or, after it was created by the first quick fix, we can offer other quick fixes to create class/interface etc.
Comment 4 Eclipse Genie CLA 2018-02-07 03:33:28 EST
New Gerrit change created: https://git.eclipse.org/r/116832
Comment 6 Pierre-Charles David CLA 2018-02-20 11:35:51 EST
Sorry for the noise, the Gerrit change mentioned in the above two comments was about https://bugs.eclipse.org/bugs/show_bug.cgi?id=525803; I mistyped the bug number in the commit message.
Comment 7 Noopur Gupta CLA 2018-03-20 10:15:29 EDT
Kalyan, it will be nice to have this for M7 if possible. We can implement it as mentioned in comment #3.
Comment 8 Noopur Gupta CLA 2018-03-27 06:26:36 EDT
(In reply to Noopur Gupta from comment #3)
> Based on comment #2, it will be good to open the New Package wizard when the
> package does not exist.
> 
> In case the package exists and is empty or, after it was created by the
> first quick fix, we can offer other quick fixes to create class/interface
> etc.
We don't need to open a New Package wizard first. New Class/Interface/Enum/Annotation wizards will create the package if it doesn't exist yet.
Comment 9 Eclipse Genie CLA 2018-03-28 02:54:51 EDT
New Gerrit change created: https://git.eclipse.org/r/120327
Comment 10 Noopur Gupta CLA 2018-04-10 07:07:37 EDT
(In reply to Eclipse Genie from comment #9)
> New Gerrit change created: https://git.eclipse.org/r/120327

Looks good. Please release the patch and keep the bug open to add N&N entry for M7.
Comment 12 Eclipse Genie CLA 2018-04-16 06:17:26 EDT
New Gerrit change created: https://git.eclipse.org/r/121195
Comment 14 Kalyan Prasad Tatavarthi CLA 2018-04-16 06:20:07 EDT
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/121195 was merged to [master].
> Commit:
> http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/
> ?id=81803114e22f75d09710b4483ce6c8fb9ce00366

This commit contains the N&N entry of this bug added for M7.