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.
Summary: | No way to add package annotations via TreeMaker | ||
---|---|---|---|
Product: | java | Reporter: | Jan Lahoda <jlahoda> |
Component: | Source | Assignee: | Jan Lahoda <jlahoda> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | jglick, jlahoda, tronicek |
Priority: | P3 | Keywords: | API, API_REVIEW_FAST |
Version: | 5.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 119887 | ||
Bug Blocks: | 179543 | ||
Attachments: |
Patch for review.
Updated patch (added apichanges). Demonstration that the API works |
Description
Jan Lahoda
2009-02-02 11:11:31 UTC
Overtake. . Reassigning all moonko's java/source bugs to myself. *** Issue 172324 has been marked as a duplicate of this issue. *** Not sure how common this request is. If there is no existing package-info.java 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: http://hg.netbeans.org/core-main/diff/6c08609a8a8b/apisupport.project/src/org/netbeans/modules/apisupport/project/CreatedModifiedFilesFactory.java By the way, is there a recommended way to create a new source file using api.java.source? I can't find anything in http://wiki.netbeans.org/Java_DevelopersGuide 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? Do you plan to fix this? Created attachment 102048 [details]
Patch for review.
Attached patch for review. To create new file call WorkingCopy.rewrite(null, new-compilation-unit-tree), but also note bug #119887. Created attachment 102049 [details]
Updated patch (added apichanges).
Bug #119887 is indeed a minor irritation here. Note that annotations in a newly created package-info.java are placed above the initial license comment, which is against normal style. Created attachment 102062 [details]
Demonstration that the API works
I will commit this once the review has concluded. Tested both with no initial package-info.java; and with preexisting package-info.java 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.)
Thanks for the review: http://hg.netbeans.org/jet-main/rev/907e1a6bea12 http://hg.netbeans.org/jet-main/rev/ac0c33019f9a http://hg.netbeans.org/jet-main/rev/b31e53aec33e Integrated into 'main-golden', will be available in build *201009290000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/28bf1d99d434 User: Jesse Glick <jglick@netbeans.org> Log: #179543 revisited: use proper API from #157760 to create/modify package-info.java. |