Bug 79809 - [1.5][dom][javadoc] Need better support for type parameter Javadoc tags
Summary: [1.5][dom][javadoc] Need better support for type parameter Javadoc tags
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 14:29 EST by Martin Aeschlimann CLA
Modified: 2004-12-14 15:36 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2004-11-30 14:29:13 EST
20041130

To document a type parameter, the normal @param tag is used, but with angle
brackets.

/**
 * @param <X>
 */
<X> void foo() {
}

The AST currently just returns a TagElement with a sigle children Name 'X' and
is currently not distinguishable from a normal parameter.

Either text elements '<' and '>' are inserted or we use a SimpleType node
instead of the SimpleName.

The first suggestion would make the accessing of tag names more complicated.
The drawback of the second suggestion is that it does not include the source
ranges for the open and closing angle brackets, but users can use the scanner as
soon as they see the SimpleType instead of the SimpleName.

The deluxe solution would be a new node type that includes the bracket and has a
simple name.
Comment 1 Martin Aeschlimann CLA 2004-12-02 03:55:42 EST
Jin, you also might be interested in that..
Comment 2 Jim des Rivieres CLA 2004-12-02 12:04:51 EST
Thanks Martim :-)

I think your first suggestion, to render it as
{ TextElement("<"), SimpleName("X"), TextElement(">"), TextElement("the 
rest") }, makes the most sense. This exposes the simple type variable for its 
binding, and keeps the "<" and ">" delimiters separate.  The second suggestion 
has the disadvantage of leaving non-whitespace unaccounted for. The deluxe 
solution is possible, but it seems a waste to introduce a new node type for 
that purpose only, especially when there's a workable alternative.
Comment 3 Jim des Rivieres CLA 2004-12-02 12:13:22 EST
I see from http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/whatsnew-
1.5.0.html that there are other 1.5 changes that will affect our parsing of 
Javadoc tags: there are new {@code} and {@literal} tag elements which are 
notable in that the text string is taken literally (i.e., not as HTML); and 
the {@value} tag element can now contain a member reference.
Comment 4 Jim des Rivieres CLA 2004-12-02 14:35:01 EST
Added TagElement.TAG_CODE and TAG_LITERAL constants.
Comment 5 Frederic Fusier CLA 2004-12-05 10:57:39 EST
Jeem,
Solution 2 (ie. use a SimpleType instead of SimpleName) is not currently
possible as SimpleType does not implement IDocElement...
Is it ok to add this interface to SimpleType or finally do we have to create a
new node?
Comment 6 Frederic Fusier CLA 2004-12-05 11:08:22 EST
Another solution would be to use a TypeParameter instead of SimpleType, but we
always have the problem of IDocElement interface...
Comment 7 Frederic Fusier CLA 2004-12-05 11:16:43 EST
Forget previous comment... It seems not to be a good idea...
Comment 8 Frederic Fusier CLA 2004-12-05 15:59:33 EST
Jeem,
About new tags (comment 3):
 - @value: new syntax is scanned correctly by the parser since M2 (bug 70892)
 - @code and @literal do not change anything for compiler and are correctly
   parsed by DocCommentParser

Following test case produce correct dom/ast hierarchy for javadoc nodes
(positions and bindings):
/**
 * New tags for 5.0
 *  - literal: {@literal a<B>c}
 *  - code: {@code abc}
 *  - value: {@value System#out}
 */
public class Test {
}
Comment 9 Frederic Fusier CLA 2004-12-05 16:01:14 EST
hum, also forget my comment 5 (perhaps it's not a good idea to work on
Sunday...) as Jeem and Martin agreed on solution 1...
I'll rewrite the fix to implement it...
Comment 10 Frederic Fusier CLA 2004-12-06 09:10:43 EST
Fixed.

Range now includes closing '>'.

[jdt-core-internal]
Changes done in:
- Javadoc.getNodeStartingAt(int)
- AbstractCommentParser.parseParam().
- JavadocParser.pushParamName(boolean)
- DocCommentParser.pushParamName(boolean)
Test cases added:
- ASTConverterJavadocTests#testBug79809()
- ASTConverterJavadocTests#testBug79809b()
Comment 11 Frederic Fusier CLA 2004-12-06 09:29:11 EST
Copy/Paste error....
You should read:
Fixed.

Now TagElement has required children: { TextElement("<"), SimpleName("X"),
TextElement(">"), TextElement("the rest") }.
SimpleName binding is the binding of the type variable 'E'.

[jdt-core-internal]
...
Comment 12 Olivier Thomann CLA 2004-12-14 15:36:23 EST
Verified in 200412140800