Associating and using javadoc comments with java elements.

Discussion in 'Java' started by sude, Feb 15, 2006.

  1. sude

    sude Guest

    Hi!,
    I need a way to associate a javadoc comment with the corresponding
    Java Element. And access that programmatically in Java.
    e.g. For the code below
    /**
    * This is my Class
    */
    public class X {
    …
    }

    I need something like
    <sometype> myJavaElement = <something which gives class X>
    myJavaElement.getComment();


    One way which I was thinking of was using the AntLR and modifying the
    lexer code generated by the AntLR. But was wondering that this problem
    might (should ïŠ) have been faced by other people and if there exists
    an open source tool which can be used for this purpose.
    I looked at qdox but that I guess will not be able to handle package
    level comments which is a basic requirement for me.

    Any help is highly appreciated and highly awaited.

    Thanks a lot,
    Sudhanshu
     
    sude, Feb 15, 2006
    #1
    1. Advertising

  2. sude

    Roedy Green Guest

    On 14 Feb 2006 16:59:20 -0800, "sude" <>
    wrote, quoted or indirectly quoted someone who said :

    >One way which I was thinking of was using the AntLR and modifying the
    >lexer code generated by the AntLR. But was wondering that this problem
    >might (should =EF=81=8A) have been faced by other people and if there exists
    >an open source tool which can be used for this purpose.
    >I looked at qdox but that I guess will not be able to handle package
    >level comments which is a basic requirement for me.


    I don't follow why you are doing this or what precisely you are
    tracking. However, there are two techniques in general for tackling
    this sort of problem.

    1. annotations:

    2. custom Javadoc comments you handle with a custom Doclet to generate
    the HTML or other summaries.

    See http://mindprod.com/jgloss/annotations.html
    http://mindprod.com/jgloss/javadoc.html

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 15, 2006
    #2
    1. Advertising

  3. On Tue, 14 Feb 2006 16:59:20 -0800, sude wrote:

    > Hi!,
    > I need a way to associate a javadoc comment with the corresponding
    > Java Element. And access that programmatically in Java.


    Comments (including "javadoc comments") are not retained by the compiler.
    End of story. If you need some descriptive information about a class at
    runtime, either store it in an annotation with runtime retention or create
    a lookup table mapping symbols (class names, packages, class member names,
    et cetera) to the information you need and access that.
     
    Owen Jacobson, Feb 15, 2006
    #3
  4. sude wrote:
    > I need a way to associate a javadoc comment with the corresponding
    > Java Element. And access that programmatically in Java.


    Use a custom doclet, write <method,comment> pairs to some output file.
    Read them back as required,

    Richard
     
    Richard Wheeldon, Feb 15, 2006
    #4
  5. sude

    sude Guest

    Well this requires an assumption on my part that the comments that are
    provided in the java code are given through a java doc tag. Right? But
    I do not want to impose any such restriction to the user. In my opinion
    JDT would need to solve this problem to show the javadoc comment
    associated with any element.
    Am not sure if they have any lean/minimal component to solve this.
    Anybody has any idea?

    sudhanshu
     
    sude, Feb 25, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. News
    Replies:
    4
    Views:
    414
    Eliyahu Goldin
    Jul 20, 2004
  2. =?Utf-8?B?Tm92aWNl?=
    Replies:
    1
    Views:
    475
    John Saunders
    Sep 23, 2004
  3. Replies:
    0
    Views:
    531
  4. Roedy Green
    Replies:
    2
    Views:
    490
    Roedy Green
    May 5, 2009
  5. Pekka Karjalainen

    [Beginner] Associating event handlers with elements

    Pekka Karjalainen, Aug 9, 2005, in forum: Javascript
    Replies:
    3
    Views:
    117
    Pekka Karjalainen
    Aug 10, 2005
Loading...

Share This Page