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 157760 - No way to add package annotations via TreeMaker
Summary: No way to add package annotations via TreeMaker
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Jan Lahoda
: 172324 (view as bug list)
Depends on: 119887
Blocks: 179543
  Show dependency tree
Reported: 2009-02-02 11:11 UTC by Jan Lahoda
Modified: 2010-09-29 03:11 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Patch for review. (25.64 KB, patch)
2010-09-16 14:55 UTC, Jan Lahoda
Details | Diff
Updated patch (added apichanges). (27.12 KB, patch)
2010-09-16 15:15 UTC, Jan Lahoda
Details | Diff
Demonstration that the API works (6.82 KB, patch)
2010-09-17 16:29 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2009-02-02 11:11:31 UTC
There is no way to add package annotations to the CompilationUnitTree (of via the o.n.a.j.s.TreeMaker.
Comment 1 Rastislav Komara 2009-02-03 10:54:30 UTC
Comment 2 Rastislav Komara 2009-02-16 09:48:52 UTC
Comment 3 Jan Lahoda 2009-08-20 09:59:10 UTC
Reassigning all moonko's java/source bugs to myself.
Comment 4 Jan Lahoda 2009-09-15 22:31:36 UTC
*** Issue 172324 has been marked as a duplicate of this issue. ***
Comment 5 Jesse Glick 2009-09-16 00:15:57 UTC
Not sure how common this request is. If there is no existing it would be a reasonable workaround to
just create it with complete contents as raw text, but this would not help if you need to add annotations to an existing
file, or modify or remove existing annotations, as my code might need to do:

By the way, is there a recommended way to create a new source file using I can't find anything in or Javadoc. Or are you just intended to use the Filesystems API to create
a file with minimal legal contents (e.g. "package $p; class $c {}") and then parse & modify it separately?
Comment 6 Jesse Glick 2010-02-01 16:17:33 UTC
Do you plan to fix this?
Comment 7 Jan Lahoda 2010-09-16 14:55:14 UTC
Created attachment 102048 [details]
Patch for review.
Comment 8 Jan Lahoda 2010-09-16 14:58:35 UTC
Attached patch for review. To create new file call WorkingCopy.rewrite(null, new-compilation-unit-tree), but also note bug #119887.
Comment 9 Jan Lahoda 2010-09-16 15:15:19 UTC
Created attachment 102049 [details]
Updated patch (added apichanges).
Comment 10 Jesse Glick 2010-09-17 16:23:27 UTC
Bug #119887 is indeed a minor irritation here.

Note that annotations in a newly created are placed above the initial license comment, which is against normal style.
Comment 11 Jesse Glick 2010-09-17 16:29:15 UTC
Created attachment 102062 [details]
Demonstration that the API works

I will commit this once the review has concluded. Tested both with no initial; and with preexisting incl. license header, Javadoc comment, and @Deprecated annotation.

(Note that this annotation has no multiple form, i.e. only one Options panel may be registered per package. The wizard does not currently let you pick the package to register in, nor does it try to stop you from readding a panel to the same module/package. However it seems very unlikely that any module would add >1 top-level container panel to the Options dialog.)
Comment 13 Quality Engineering 2010-09-29 03:11:45 UTC
Integrated into 'main-golden', will be available in build *201009290000* on (upload may still be in progress)
User: Jesse Glick <>
Log: #179543 revisited: use proper API from #157760 to create/modify