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 111292 - Use code completion hints supplied by annotation processors
Summary: Use code completion hints supplied by annotation processors
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 111065
  Show dependency tree
 
Reported: 2007-07-28 08:55 UTC by brucechapman
Modified: 2010-03-03 22:14 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Patch adding getCompletions implementation to the ServiceProviderProcessor. (3.45 KB, patch)
2009-07-28 18:15 UTC, Jan Lahoda
Details | Diff
Proposed patch (5.37 KB, patch)
2010-02-24 09:27 UTC, Dusan Balek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description brucechapman 2007-07-28 08:55:34 UTC
JSR-269 annotation processors can supply code completion hints for values of members of annotations.

See
http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html#getCompletions(javax.lang.model.element.Element,%20javax.lang.model.element.AnnotationMirror,%20javax.lang.model.element.ExecutableElement,%20java.lang.String)

The java editor should query any discoverable (see class docs in above link) processors which "support" (see
http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html#getSupportedAnnotationTypes() ) an
annotation when code completion is being performed on an annotation's element's value (or values when it is an array
element).
Comment 1 Jan Lahoda 2009-07-28 18:13:54 UTC
FYI: I have added a very rudimentary support for annotation processors (completions and messages) to the Extended Java
Editor module here:
http://kenai.com/projects/pelmel
more about the annotation processors support is here:
http://kenai.com/projects/pelmel/pages/AnnotationProcessors

I am also attaching a patch for the NetBeans' ServiceProviderProcessor, that proposes types for the "service" attribute.
Jesse, would you mind if I would apply the patch? Thanks.
Comment 2 Jan Lahoda 2009-07-28 18:15:31 UTC
Created attachment 85368 [details]
Patch adding getCompletions implementation to the ServiceProviderProcessor.
Comment 3 Jesse Glick 2009-07-28 18:39:49 UTC
Go ahead but


[JG01] What is the purpose of the first two if-clauses? Seems to me that if these are ever true, there is a bug in the
269 container.


[JG02] Shouldn't TypeCompletion.getValue return fqn + ".class"?
Comment 4 Jan Lahoda 2009-07-28 19:09:20 UTC
[JG01] Some of the conditions in the first two ifs may be validly true, according to the API - "annotated" (element) may
be null (is "userText" is non-null), "annotation" may be validly null too (if "annotated" is not null). Some of the
conditions are to make the method robust - they might be true if the user changes his/hers code enough (e.g. changing
the @Target of the annotation to METHOD). processingEnv == null would probably mean a container bug.

[JG02] Pelmel is currently not able to handle fqn + ".class" properly, but I am going to fix that so we can return fqn +
".class" if preferred (Pelmel should do the correct thing in both cases after the fix).
Comment 5 Dusan Balek 2010-02-24 09:27:00 UTC
Recently, an initial support for running annotation processors inside Java editor has been implemented for j2se projects. (see changeset: http://hg.netbeans.org/main/rev/d59a1df3507f).
In order to use the code completion hints supplied by annotation processors in JavaCompletionProvider, I would like to propose a small extension to the java.source API (diff is attached).
Comment 6 Dusan Balek 2010-02-24 09:27:52 UTC
Created attachment 94490 [details]
Proposed patch
Comment 7 Jesse Glick 2010-02-24 13:27:45 UTC
[JG03] Catch RuntimeException from processor.getCompletions and log with processor impl class name but continue.
Comment 8 Dusan Balek 2010-03-02 03:59:24 UTC
OK. Thanks for review.
Comment 9 Dusan Balek 2010-03-02 04:00:57 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/497bc30d2c8f
Comment 10 Quality Engineering 2010-03-03 22:14:58 UTC
Integrated into 'main-golden', will be available in build *201003040200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/497bc30d2c8f
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #111292: Use code completion hints supplied by annotation processors - fixed.