Community
Participate
Working Groups
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.
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.
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?
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.
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.
Agreed. Please close.
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.
Closed.
Current behavior is fine.
Verified