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 72956 - Generate elements in annotations with [] on separate lines
Summary: Generate elements in annotations with [] on separate lines
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks: 73269
  Show dependency tree
 
Reported: 2006-02-22 22:51 UTC by Rochelle Raccah
Modified: 2007-09-26 09:14 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch to trunk build (2.73 KB, patch)
2006-05-30 09:42 UTC, Pavel Flaska
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rochelle Raccah 2006-02-22 22:51:57 UTC
See the discussion in issue 72704.  Basically, for EJB3, it is important that
generated annotations in a [] element end up on different lines.  It is quite
unreadable on one long line.
Comment 1 Pavel Buzek 2006-05-25 15:00:17 UTC
Java team, are you planning to fix this issue in 5.5? We have a dependency on it
which would be quite nice to fix. It is just cosmetic issue but it look pretty
ugly if you have extremely long lines in generated code (and they can be REALLY
long...). Thanks.
Comment 2 Pavel Flaska 2006-05-26 10:05:55 UTC
We do not plan to fix this, but if you will mark it as a blocker, we have to
find solution for it. I agree it is ugly. I thought about possible solutions I
found just two:

1) In our generator, this is the "normal" Array initializer, JavaCore does not
solve, if it is inside annotation or not. We can add new line character between
values, but this will affect all newly generation array initializers, i.e. if
somebody will create array initializer with integer values, e.g.

int[] array = { 0, 1, 2 };

this will be presented in roughly

int[] array = { 0,
    1,
    2 };

IMO we can do this fix for release55, as I found just one usage of
ArrayInitializationClass.createArrayInitialization() in our codebase and it is
this one, yours.
Comment 3 Pavel Flaska 2006-05-26 10:15:50 UTC
2) reformat the generated code. This seems to be worse solution because text
will probably "dance" in editor.

To minimize an impact of solution 1), I can check that array initializer is in
attribute value, i.e. refImmediateComposite() is an AttributeValue instance.
Then, the possible problem with other array initializers will be eliminated.

Unfortunately, both ways are hacks. JavaCore does know nothing about the line
length. This should be solved by redesigning some parts of generator and editor
has to provide some additional information. This is not planned in the future.

I will prepare test patch for 1) and will attach it here.
Comment 4 Pavel Flaska 2006-05-30 09:42:47 UTC
Created attachment 30651 [details]
Patch to trunk build
Comment 5 Pavel Flaska 2006-06-13 13:07:25 UTC
Any comments?
Comment 6 Rochelle Raccah 2006-07-24 22:55:23 UTC
Bump - Pavel B., can you respond to whether or not you agree to the patch?
Comment 7 Pavel Buzek 2006-07-27 16:33:14 UTC
Sorry for not responding earlier. I agree with this solution. The patch looks
good to me as far as I can tell from the code. Please apply to 5.5 so we can
test and close 73269. Thanks both to Pavel and Rochelle.
Comment 8 Rochelle Raccah 2006-08-17 00:55:40 UTC
Do we need some keywords here to make sure it gets integrated into 5.5?  Pavel
B. added comments that it should several weeks ago...
Comment 9 Pavel Buzek 2006-08-26 00:39:02 UTC
Dane, please merge this into 5.5. Thanks!
Comment 10 Daniel Prusa 2006-09-04 14:54:52 UTC
Patch applied on trunk, I will merge it into release55 branch tomorrow.

/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/ArrayInitializationImpl.java
new revision: 1.10; previous revision: 1.9
Comment 11 Daniel Prusa 2006-09-05 11:19:17 UTC
Fix merged into release55.

/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/ArrayInitializationImpl.java
new revision: 1.5.26.1.2.4; previous revision: 1.5.26.1.2.3
Comment 12 Quality Engineering 2007-09-20 12:05:13 UTC
Reorganization of java component