Bug 72139 - [hovering] Display @value in javadoc of static fields
Summary: [hovering] Display @value in javadoc of static fields
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P4 minor with 3 votes (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 152029 172459 (view as bug list)
Depends on: 236850
Blocks:
  Show dependency tree
 
Reported: 2004-08-17 18:43 EDT by Nick Chalko CLA
Modified: 2010-04-28 13:07 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Chalko CLA 2004-08-17 18:43:18 EDT
Javadoc UI elements should support {@value} for Static fields.
This is a javadoc 1.4 feature. see
http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/whatsnew-1.4.html#{@value}

    /**
     * Comment for <code>CDICE_DOCUMENTS</code>= {@value}
     */
    public static final String CDICE_DOCUMENTS = "cims_doc";

currently displays as 


Comment for CDICE_DOCUMENTS= {
Comment 1 Dani Megert CLA 2004-08-18 04:37:22 EDT
Javadoc view is also affected.
Comment 2 Dani Megert CLA 2006-08-01 07:33:20 EDT
see also bug 152029
Comment 3 Markus Keller CLA 2008-09-30 05:33:53 EDT
Note that the Javadoc tool (1.5 and 1.6) fails to resolve @value inline tags with a reference to another type, see
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6750224 .
Comment 4 Markus Keller CLA 2008-09-30 05:34:49 EDT
*** Bug 172459 has been marked as a duplicate of this bug. ***
Comment 5 Markus Keller CLA 2008-09-30 05:47:21 EDT
*** Bug 152029 has been marked as a duplicate of this bug. ***
Comment 6 Mauro Molinari CLA 2008-11-18 08:50:25 EST
Couldn't this be targeted for 3.5 just like bug #24227? This would give the Javadoc hover a "full" (at least I hope) implementation for 3.5...

Mauro.
Comment 7 Markus Keller CLA 2008-11-18 09:39:38 EST
(In reply to comment #6)
Tentatively targetting 3.5. Some of the prerequisites for this (need a resolved AST is some cases) is already done in the work for bug 236850.

(In reply to comment #3)
> Note that the Javadoc tool (1.5 and 1.6) fails to resolve @value inline tags
> with a reference to another type, see
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6750224 .

Actually, javadoc.exe does work if the type reference is *fully* qualified.
Comment 8 Markus Keller CLA 2009-04-30 13:10:28 EDT
Sorry, I ran out of time for 3.5. The fix needs to create more ASTs than normal Javadoc hovers, and I don't want to risk breaking or delaying the hovers at this stage.
Comment 9 Markus Keller CLA 2010-04-25 05:55:08 EDT
Fixed in JavadocContentAccess2. I've only implemented {@value} and {@value #FIELD_FROM_SAME_TYPE} for now, since the rest would have been more expensive and since the Javadoc tool is also not reliable in those cases.
Comment 10 Deepak Azad CLA 2010-04-27 06:24:36 EDT
Things work for the declaration and references in the same file (even references from secondary class).

However when the static field is referred from another file then the javadoc is 'Comment for CDICE_DOCUMENTS= {@value}'. This behavior is same for source and binary with attached source.
Comment 11 Deepak Azad CLA 2010-04-27 06:34:12 EDT
(In reply to comment #10)
> Things work for the declaration and references in the same file (even
> references from secondary class).
> 
> However when the static field is referred from another file then the javadoc is
> 'Comment for CDICE_DOCUMENTS= {@value}'. This behavior is same for source and
> binary with attached source.
Build ID - I20100426-0852
Comment 12 Raksha Vasisht CLA 2010-04-27 14:40:31 EDT
(In reply to comment #11)
> (In reply to comment #10)
> > Things work for the declaration and references in the same file (even
> > references from secondary class).
> > 
> > However when the static field is referred from another file then the javadoc is
> > 'Comment for CDICE_DOCUMENTS= {@value}'. This behavior is same for source and
> > binary with attached source.
> Build ID - I20100426-0852

It seems to be working for me with I20100426-0852.
Do you mean this? :

public class test {
	public static final String MAIN_INDIRECT = "Main.3"; //$NON-NLS-1$
}

public class Main {    
    /**
     * Comment for <code>MAIN_INDIRECT</code>= {@value}
     */	
    private final static String MAIN_INDIRECT = test.MAIN_INDIRECT;
}

Hover shows me the value 'Comment for MAIN_INDIRECT= "Main.3"' correctly also in Javadoc view for source and binary with attached source.
Comment 13 Deepak Azad CLA 2010-04-27 14:51:41 EDT
(In reply to comment #12)
> It seems to be working for me with I20100426-0852.
> Do you mean this? :
> 
> public class test {
>     public static final String MAIN_INDIRECT = "Main.3"; //$NON-NLS-1$
> }
> 
> public class Main {    
>     /**
>      * Comment for <code>MAIN_INDIRECT</code>= {@value}
>      */    
>     private final static String MAIN_INDIRECT = test.MAIN_INDIRECT;
> }
> 
> Hover shows me the value 'Comment for MAIN_INDIRECT= "Main.3"' correctly also
> in Javadoc view for source and binary with attached source.

No, I meant

//Main.java
public class Main {    
	 /**
     * Comment for <code>CDICE_DOCUMENTS</code>= {@value}
     */
    public static final String CDICE_DOCUMENTS = "cims_doc";


}

//A.java
public class A {

	public void foo(){
		String cdiceDocuments = Main.CDICE_DOCUMENTS;
	}
}


Now, hover over Main.CDICE_DOCUMENTS in A.java (or select it and open JavaDoc view), the value is not available it just shows the annotation. Now the class Main can be available as source or as a binary with source attachment the result is the same.
Comment 14 Raksha Vasisht CLA 2010-04-27 15:01:38 EDT
(In reply to comment #13)

Ah I see what you mean. Sorry I marked the bug Verified by mistake due to clash of comments. Pls reopen as necessary.
Comment 15 Deepak Azad CLA 2010-04-27 15:20:38 EDT
Reopening.
Comment 16 Markus Keller CLA 2010-04-28 13:07:45 EDT
Fixed the case from comment 10 in JavadocContentAccess2.

That's the best I can do for 3.6. It works for simple constants like String literals or chars. Anything more would require a full AST of the target, and that's too expensive without more infrastructure.

Please open a new bug if you want to request more features.