Bug 16736

Summary: Comment before package statement not associated with it
Product: [Eclipse Project] JDT Reporter: Jerome Lanneluc <jerome_lanneluc>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 F2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Jerome Lanneluc CLA 2002-05-22 06:26:39 EDT
Build 20020521

1. Create the following CU:
/* Some comment before the package statement */
package p;

/* Some comment before the class declaration */
public class X {
}
2. Open in java editor
3. Show source of selected element only
4. In Outline, select p
Observe: The comment before p IS NOT shown
5. Select X
Observe: The comment before X IS shown.
Comment 1 Olivier Thomann CLA 2002-05-22 11:28:12 EDT
This makes sense. We associate the preceeding comment with its declaration only for methods, 
fields and types. We don't do it for package declarations. If we want to do it, we can, but so far it is 
intentional.
Comment 2 Olivier Thomann CLA 2002-05-25 19:54:46 EDT
So I guess we want the comment to be associated with the package declaration. I disagree with that, 
but if you want it, I will add it. My point is that this comment is very often related to the 
compilation unit and not the package declaration. So displaying it with the package declaration 
doesn't seem the right thing to do.
Any comment?
Comment 3 Jerome Lanneluc CLA 2002-05-27 05:00:16 EDT
I agree with you that this comment is mostly related to the cu. However in F1, 
you can never see this comment when in 'source of selected element only'. I 
thought that selecting the package declaration in the outline would show me 
this comment, but it showed only the package declaration statement which is the 
same information as in the outline. So maybe associating the comment to the 
package declaration would give additional value to the package declaration.
Comment 4 Olivier Thomann CLA 2002-05-27 09:54:15 EDT
I still believe we should not display this comment when you select only the package declaration. 
The comment preceeding the package declaration should only be displayed when nothing is 
selected in the outliner.
I really don't like to associate a comment related to the compilation 
unit with the package fragment. Even worse the comment might simply be a copyright notice and then 
it is certainly not related to the package declaration.
When we added an association between 
non-javadoc comments and the following declaration (method, field or class), I was against this 
decision, because these comments are not part of the method, field or type declaration. Now we 
want to add comments preceeding the package declaration inside the package declaration. That 
means that if I remove the package declaration this comment will also be removed. If you have a 
copyright notice, you will certainly want to keep it even if you move your CU from one package to 
another package, won't you? If you answer yes, then we should not change anything.
Comment 5 Jerome Lanneluc CLA 2002-05-27 11:36:19 EDT
Agreed. Please close.
Comment 6 Olivier Thomann CLA 2002-05-27 12:11:23 EDT
I double checked. If I include the preceeding comment inside the package declaration, I lose it 
when I move a CU to another package. This operation involves the JDOM API, which doesn't handle 
this case. So I think we should either not fix this problem or fix it after 2.0.
Comment 7 Olivier Thomann CLA 2002-05-27 12:57:36 EDT
Closed.
Comment 8 Philipe Mulet CLA 2002-06-03 07:25:56 EDT
Current behavior is fine.
Comment 9 Philipe Mulet CLA 2002-06-03 07:26:07 EDT
Verified