This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 59567 - generation of annotations is not very readable
Summary: generation of annotations is not very readable
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Pavel Flaska
URL:
Keywords:
: 57286 60287 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-02 23:29 UTC by Jeri Lockhart
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
current formatting of annotations (890 bytes, text/plain)
2005-06-02 23:30 UTC, Jeri Lockhart
Details
preferred formatting (863 bytes, text/plain)
2005-06-02 23:31 UTC, Jeri Lockhart
Details
Patch for placing new annotation on its separate line - tests updated and added (33.63 KB, patch)
2005-06-16 12:27 UTC, Pavel Flaska
Details | Diff
Patch for placing new annotation on its separate line - tests updated and added (33.63 KB, patch)
2005-06-16 12:39 UTC, Pavel Flaska
Details | Diff
contains method annotation that is not indented properly (1.06 KB, text/plain)
2005-06-17 00:01 UTC, Jeri Lockhart
Details
template used for initial creation of file (793 bytes, text/plain)
2005-06-17 00:05 UTC, Jeri Lockhart
Details
code using JMI to generate annotations (see createMethod()) (16.02 KB, text/plain)
2005-06-17 00:07 UTC, Jeri Lockhart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeri Lockhart 2005-06-02 23:29:22 UTC
JMI generates annotation for classes, methods, and local variables on the same
line as the class or method statement, which can make the code hard to read,
especially when there are more than one annotation for an element, or when the
annotation is longer than a single word.

The code would be more readable if the annotation were on its own line with the
subsequent code indented properly.
Comment 1 Jeri Lockhart 2005-06-02 23:30:37 UTC
Created attachment 22463 [details]
current formatting of annotations
Comment 2 Jeri Lockhart 2005-06-02 23:31:19 UTC
Created attachment 22464 [details]
preferred formatting
Comment 3 Martin Matula 2005-06-03 09:26:21 UTC
mdr->java/javacore
Comment 4 Tomas Hurka 2005-06-14 19:10:48 UTC
Pavel will fix it.
Comment 5 Pavel Flaska 2005-06-15 16:40:07 UTC
Hi Jeri, I'm working on it, there are more problems to solve. Maybe I will not
be able to fix all the cases, so I want to try to focus on your usecase. Can you
tell me: Do you add annotations to existing elements (classes, methods) or do
you generate them together with element?
Comment 6 Jeri Lockhart 2005-06-15 19:59:19 UTC
We generate the annotations together with the element for classes and methods,
but for loc variables, we must add them later.

These are the use cases:
1.  Pass annotation into the create for methods or classes.
2.  For local variables we add annotations using these steps in succession:
  a. create loc var
  b. create loc var declaration
  c. add annotation to loc var
(this is a workaround that Martin told us to use)

After the annotation and its element are generated, we sometimes modify an
existing annotation, for example, change the attribute values of a loc var
annotation.  The changes we make would not require re-formatting.  (This may be
a future requirement, however)

Comment 7 Martin Matula 2005-06-15 20:11:33 UTC
But all annotations are added (even if later) in the same MDR transaction as the
elements (e.g. local variables) are created, right?
By saying that doing changes that involve refomatting may be a future
requirement, do you mean requirement for JavaOne demo, or post-JavaOne?
Comment 8 Jeri Lockhart 2005-06-15 20:17:48 UTC
yes, all annotations are added (even if later) in the same MDR transaction as the
elements.

reformatting would be a Post J1 issue.
Comment 9 Pavel Flaska 2005-06-16 12:27:07 UTC
Created attachment 22744 [details]
Patch for placing new annotation on its separate line - tests updated and added
Comment 10 Pavel Flaska 2005-06-16 12:39:09 UTC
Created attachment 22745 [details]
Patch for placing new annotation on its separate line - tests updated and added
Comment 11 Pavel Flaska 2005-06-16 12:40:35 UTC
I accidently added exactly the same patch two times.
Comment 12 Pavel Flaska 2005-06-16 12:51:11 UTC
Fixed in trunk.

Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/AnnotationImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/AnnotationImpl.java,v
 <--  AnnotationImpl.java
new revision: 1.17; previous revision: 1.16
done
Checking in
src/org/netbeans/modules/javacore/jmiimpl/javamodel/CallableFeatureImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/CallableFeatureImpl.java,v
 <--  CallableFeatureImpl.java
new revision: 1.27; previous revision: 1.26
done
Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/FeatureImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/FeatureImpl.java,v
 <--  FeatureImpl.java
new revision: 1.42; previous revision: 1.41
done
Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/FieldImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/FieldImpl.java,v
 <--  FieldImpl.java
new revision: 1.30; previous revision: 1.29
done
Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java,v
 <--  IndentUtil.java
new revision: 1.6; previous revision: 1.5
done
Checking in
src/org/netbeans/modules/javacore/jmiimpl/javamodel/LocalVarDeclarationImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/LocalVarDeclarationImpl.java,v
 <--  LocalVarDeclarationImpl.java
new revision: 1.12; previous revision: 1.11
done
Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/MethodImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/MethodImpl.java,v
 <--  MethodImpl.java
new revision: 1.32; previous revision: 1.31
done
Checking in test/cfg-unit.xml;
/cvs/java/javacore/test/cfg-unit.xml,v  <--  cfg-unit.xml
new revision: 1.36; previous revision: 1.35
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationOnLocVarTest/testAddAnnToLocVar_AnnotationOnLocVarTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationOnLocVarTest/testAddAnnToLocVar_AnnotationOnLocVarTest.pass,v
 <--  testAddAnnToLocVar_AnnotationOnLocVarTest.pass
new revision: 1.2; previous revision: 1.1
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationOnLocVarTest/testAddLocVarWithAnn_AnnotationOnLocVarTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationOnLocVarTest/testAddLocVarWithAnn_AnnotationOnLocVarTest.pass,v
 <--  testAddLocVarWithAnn_AnnotationOnLocVarTest.pass
new revision: 1.2; previous revision: 1.1
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnWithConstr_AnnotationClass.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnWithConstr_AnnotationClass.pass,v
 <--  testAddAnnWithConstr_AnnotationClass.pass
new revision: 1.2; previous revision: 1.1
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnWithField_AnnotationClass.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnWithField_AnnotationClass.pass,v
 <--  testAddAnnWithField_AnnotationClass.pass
new revision: 1.2; previous revision: 1.1
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnotation_AnnotationClass.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/AnnotationTest/testAddAnnotation_AnnotationClass.pass,v
 <--  testAddAnnotation_AnnotationClass.pass
new revision: 1.4; previous revision: 1.3
done
RCS file:
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithClass_AnnIndentTest.pass,v
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithClass_AnnIndentTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithClass_AnnIndentTest.pass,v
 <--  testAddAnnotationWithClass_AnnIndentTest.pass
initial revision: 1.1
done
RCS file:
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithMethod_AnnIndentTest.pass,v
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithMethod_AnnIndentTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationWithMethod_AnnIndentTest.pass,v
 <-- testAddAnnotationWithMethod_AnnIndentTest.pass
initial revision: 1.1
done
RCS file:
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationsToClass_AnnIndentTest.pass,v
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationsToClass_AnnIndentTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotationsToClass_AnnIndentTest.pass,v
 <--  testAddAnnotationsToClass_AnnIndentTest.pass
initial revision: 1.1
done
RCS file:
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotations_AnnIndentTest.pass,v
done
Checking in
test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotations_AnnIndentTest.pass;
/cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest/testAddAnnotations_AnnIndentTest.pass,v
 <--  testAddAnnotations_AnnIndentTest.pass
initial revision: 1.1
done
Checking in
test/unit/data/projects/default/src/org/netbeans/test/codegen/AnnotationClass.java;
/cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/codegen/AnnotationClass.java,v
 <--  AnnotationClass.java
new revision: 1.2; previous revision: 1.1
done
RCS file:
/cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/codegen/indent/AnnIndentClass.java,v
done
Checking in
test/unit/data/projects/default/src/org/netbeans/test/codegen/indent/AnnIndentClass.java;
/cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/codegen/indent/AnnIndentClass.java,v
 <--  AnnIndentClass.java
initial revision: 1.1
done
RCS file:
/cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest.java,v
done
Checking in
test/unit/src/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest.java;
/cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/codegen/indent/AnnIndentTest.java,v
 <--  AnnIndentTest.java
initial revision: 1.1
done
Comment 13 Pavel Flaska 2005-06-16 13:45:30 UTC
Merged also to coke_j1_05_fixes branch.
Comment 14 Jeri Lockhart 2005-06-17 00:00:36 UTC
The annotations in our test looked good and were as expected, except for one
method annotation.  I will attach the generated java file.  The "@WebMethod"
annotation is not indented properly.

I'll also attach the template file which was used to create the file, and the
Java code we used to generate the annotation.
Comment 15 Jeri Lockhart 2005-06-17 00:01:45 UTC
Created attachment 22756 [details]
contains method annotation that is not indented properly
Comment 16 Jeri Lockhart 2005-06-17 00:05:45 UTC
Created attachment 22757 [details]
template used for initial creation of file
Comment 17 Jeri Lockhart 2005-06-17 00:07:26 UTC
Created attachment 22758 [details]
code using JMI to generate annotations (see createMethod())
Comment 18 Pavel Flaska 2005-06-17 14:04:51 UTC
I have similar test, which seems to work correctly.
Can you describe mdr transaction?
- I tried to make class looking in the same manner as your template,
- then I add in my test annotation to this class and in the same mdr transaction
I created a new method with annotation.

Comment 19 Pavel Flaska 2005-06-17 14:48:31 UTC
I found the case when it fails. It is when there is an annotation on element and
you will add new one in new transaction. I will try to fix it immediately.
Comment 20 Tomas Hurka 2005-06-17 15:48:31 UTC
Additional fixes:
Checking in org/netbeans/modules/javacore/jmiimpl/javamodel/CallableFeatureImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/CallableFeatureImpl.java,v  
<--  CallableFeatureImpl.java
new revision: 1.28; previous revision: 1.27
done
Checking in org/netbeans/modules/javacore/jmiimpl/javamodel/FeatureImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/FeatureImpl.java,v  <--  
FeatureImpl.java
new revision: 1.43; previous revision: 1.42
done
Checking in org/netbeans/modules/javacore/jmiimpl/javamodel/FieldImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/FieldImpl.java,v  <--  
FieldImpl.java
new revision: 1.31; previous revision: 1.30
done
Checking in org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java,v  <--  
IndentUtil.java
new revision: 1.7; previous revision: 1.6
done
Checking in org/netbeans/modules/javacore/jmiimpl/javamodel/LocalVarDeclarationImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/
LocalVarDeclarationImpl.java,v  <--  LocalVarDeclarationImpl.java
new revision: 1.13; previous revision: 1.12
done
Comment 21 Pavel Flaska 2005-06-17 15:56:58 UTC
Additional fixes merged to coke_j1_05_fixes too.
Comment 22 Jeri Lockhart 2005-06-17 18:45:46 UTC
Hello Pavel,
That fixed it!  Thank you for your taking care of this so quickly.   It's a big
help to our demo.  We greatly appreciate it!
--Jeri
Comment 23 Martin Grebac 2005-06-21 09:48:52 UTC
*** Issue 60287 has been marked as a duplicate of this issue. ***
Comment 24 Pavel Flaska 2005-06-23 10:05:50 UTC
*** Issue 57286 has been marked as a duplicate of this issue. ***
Comment 25 Quality Engineering 2007-09-20 12:38:38 UTC
Reorganization of java component