| Summary: | Viewpoint specification project activator location package | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] Sirius | Reporter: | Boubekeur Zendagui <boubekeur.zendagui> | ||||
| Component: | Core | Assignee: | Maxime Porhel <maxime.porhel> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | florian.barbin, maxime.porhel, pierre-charles.david, stephane.thibaudeau | ||||
| Version: | 1.0.0M7 | Keywords: | triaged | ||||
| Target Milestone: | 1.0.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | trivial flash | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 441059 | ||||||
| Attachments: |
|
||||||
The corresponding code is here: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ViewpointSpecificationProject.java?id=7128534330eee84895d474d4bea3a07f56e90364#n335 It should normally use "defaultpackage" only if the project name chosen is not a valid Java identifier (and thus can not be used as a package name for the activator). From your screenshot it looks like you used the default name, so this is surprising. Did you specify any non-default values in the wizard? Or maybe a trailing space (not visible on the screenshot) was added? I didn't change any default data in the wizard. I have the same behaviour if i set project name to org.eclipse.test.sirius for example. I put a breakpoint on the line 335 (http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ViewpointSpecificationProject.java?id=7128534330eee84895d474d4bea3a07f56e90364#n335), the method SourceVersion.isIdentifier(...) consider : 1- "org.eclipse.test.sirius" as NO Java identifier --> so it use defaultpackage. 2- "orgeclipsetestsirius" as a Java Identifier --> so the project name is used. ps: in the second case, i only removed "." character from the name given in the first case (In reply to Pierre-Charles David from comment #1) > The corresponding code is here: > http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org. > eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ > ViewpointSpecificationProject. > java?id=7128534330eee84895d474d4bea3a07f56e90364#n335 > > It should normally use "defaultpackage" only if the project name chosen is > not a valid Java identifier (and thus can not be used as a package name for > the activator). From your screenshot it looks like you used the default > name, so this is surprising. Did you specify any non-default values in the > wizard? Or maybe a trailing space (not visible on the screenshot) was added? See . http://docs.oracle.com/javase/7/docs/api/javax/lang/model/SourceVersion.htm . http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isJavaIdentifierStart(int) . http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isJavaIdentifierPart(int) (See also same uri vith /6/) A project name containing any '.' will not ba a valid identifier. We are looking for a valid package name not a valid sigle identifier. We could split the project name if it contains "." and check each segment. I have done some tests, forcing the package name to be a string containing "." as the default "my.project.design". The remaining code executes as expected and the activator class is created in the right package.
There is even something like
packageName.replaceAll("\\.", "/")
to be sure that "." are correctly handled.
So, we just have to fix the test so that "my.project.design" would be seen as a valid package name and the ticket will be fixed.
The test with SourceVersion.isIdentifier(project.getName()) just seems to be plain wrong. 'my.project.design' is not a valid name according to this test but 'class' is a valid name and the wizard tries to create a 'class' package which is not valid. I think that replacing isIdentifier() with isName() would do the trick. So far, I haven't seen any case where isName() would return a wrong result. The javadoc for SourceVersion.isName() confirm your thoughts: "Returns whether or not name is a syntactically valid qualified name in the latest source version. Unlike isIdentifier, this method returns false for keywords and literals." Corrected on 1.0.x branch by commit 6b91edae4aa0cad872d3f99270bec1bee3b34b7d Available in Sirius 1.0.1. |
Created attachment 243441 [details] project outline When creating a new Viewpoint Specification Project, the plugin activator is created in a java package named "defaultpackage". It may be interesting to name this package like the project.