Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 519254

Summary: [9] Module declaration name should be validated while creation
Product: [Eclipse Project] JDT Reporter: Thomas Wenzlaff <eclipse>
Component: UIAssignee: Kalyan Prasad Tatavarthi <kalyan_prasad>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, manoj.palat, noopur_gupta, stephan.herrmann
Version: 4.7   
Target Milestone: BETA J9   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/102755
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=6e90489bb8bedb191fdd84efeb8a17859d7dcae4
https://git.eclipse.org/r/103519
https://git.eclipse.org/c/platform/eclipse.platform.images.git/commit/?id=444a228b2769f53a7f81829352f4bc724f68cad4
Whiteboard:
Bug Depends on: 519442, 519560    
Bug Blocks:    

Description Thomas Wenzlaff CLA 2017-07-05 13:15:04 EDT
[1.9] Wrong generate module-info.java with hyphen in project name

Sampel Projekt name: opensky-api 

Project -> Cofigure -> Create module-info

module opensky-api {exports de.wenzlaff.tools;exports org.opensky.api;exports org.opensky.model;exports de.wenzlaff.tools;requires java.base;requires java.corba;requires jdk.compiler;}
Comment 1 Stephan Herrmann CLA 2017-07-05 19:37:45 EDT
Similar rules as for naming an automatic module should apply...
Comment 2 Noopur Gupta CLA 2017-07-10 05:24:41 EDT
Requested the corresponding API via bug 519442.
Comment 3 Noopur Gupta CLA 2017-07-20 07:01:12 EDT
*** Bug 519939 has been marked as a duplicate of this bug. ***
Comment 4 Noopur Gupta CLA 2017-08-08 03:02:11 EDT
From bug 519442 comment #6:

As discussed in the JDT call, we should provide a dialog to the user while creating module-info.java file to ask for the module name. The name in the dialog will be validated with the API from bug 519560. The initial name provided in the dialog will be the project name (or, a valid suggestion based on the project name when comment #5 is implemented in jdt.ui/core).
Comment 5 Eclipse Genie CLA 2017-08-09 05:25:07 EDT
New Gerrit change created: https://git.eclipse.org/r/102755
Comment 6 Noopur Gupta CLA 2017-08-11 05:37:29 EDT
(In reply to Eclipse Genie from comment #5)
> New Gerrit change created: https://git.eclipse.org/r/102755

Thanks for the patch, Kalyan.

General comments:
- It doesn't work when Finish is pressed with a warning - no file is created.
- It doesn't prefill the text field if validation has an error. We should still prefill the text field to help the user create a valid name from the invalid text.
- The wizard looks big - the text field is too long.
- We should add an image to the wizard - this can be handled after other comments.

Code review comments:
Please see Gerrit. This being the first patch from you, I have gone into minute details which are important to maintain the code quality in JDT UI. Please consider this feedback for future patches as well.
Comment 7 Kalyan Prasad Tatavarthi CLA 2017-08-17 02:40:44 EDT
(In reply to Noopur Gupta from comment #6)
> (In reply to Eclipse Genie from comment #5)
> > New Gerrit change created: https://git.eclipse.org/r/102755
> 
> Thanks for the patch, Kalyan.
> 
> General comments:
> - It doesn't work when Finish is pressed with a warning - no file is created.
> - It doesn't prefill the text field if validation has an error. We should
> still prefill the text field to help the user create a valid name from the
> invalid text.
> - The wizard looks big - the text field is too long.
> - We should add an image to the wizard - this can be handled after other
> comments.
> 
> Code review comments:
> Please see Gerrit. This being the first patch from you, I have gone into
> minute details which are important to maintain the code quality in JDT UI.
> Please consider this feedback for future patches as well.

Modified the Gerrit patch to include 
1) The change for handling the case of file creation even if warning is reported.
and 
2) Handle the Gerit Code Review comments

I will be adding a new image to the wizard in the next patch
Also, the reason to not prefill the text field if validation has error is that the wizard convention is that it should never be prefilled with any text reporting an error.
We have 2 ways to fix this 
 a) To leave the field blank and only enable the finish button when user fills the name.(This is the choice I have used)
 b) To derive a valid name removing the erronous characters and prefill with a name which is valid ( This would require a bit of JDT core logic for what is allowed in a module name)
Comment 8 Noopur Gupta CLA 2017-08-17 05:51:09 EDT
(In reply to Kalyan Prasad Tatavarthi from comment #7)
> Also, the reason to not prefill the text field if validation has error is
> that the wizard convention is that it should never be prefilled with any
> text reporting an error.
> We have 2 ways to fix this 
>  a) To leave the field blank and only enable the finish button when user
> fills the name.(This is the choice I have used)
>  b) To derive a valid name removing the erronous characters and prefill with
> a name which is valid ( This would require a bit of JDT core logic for what
> is allowed in a module name)

b) is bug 519442.

Until we get that, we can either prefill it with the error message or leave it blank. Anything is OK for me.
Comment 9 Kalyan Prasad Tatavarthi CLA 2017-08-18 08:19:26 EDT
The Gerrit patch has been modified to add image to the wizard
Comment 10 Kalyan Prasad Tatavarthi CLA 2017-08-20 23:57:23 EDT
The patch has been updated to remove an unnecessary function and to update comments
Comment 12 Eclipse Genie CLA 2017-08-23 07:13:15 EDT
New Gerrit change created: https://git.eclipse.org/r/103519
Comment 13 Kalyan Prasad Tatavarthi CLA 2017-08-23 07:14:36 EDT
The new Gerrit change is to push the new icons to eclipse.platform.images
Comment 15 Noopur Gupta CLA 2017-08-23 07:16:50 EDT
Thanks for the patches, Kalyan!