Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Retrieve javadoc programmatically

Hello Christian,

If it is only the Javadoc you are interested in, you can get the ICompilationUnit by writing something like this:
   (ICompilationUnit)JavaCore.create(getFile(path))

Once you have the CU, you can work your way through to get the element (method, field etc.) you are interested in and use the following API to get the Javadoc:

    IJavaElement#getAttachedJavadoc()

Only problem with the above is, it works well for Javadoc attached as HTML, but for source, it only returns what's in the source. That's why you are perhaps using the ProposalInfo, which takes help from JavadocContentAccess2 in converting the Javadoc String to nice HTML format.

Perhaps someone from the JDT/UI can comment on your usage. But to me looks like you are using code internal to JDT.

Regards,
Jay

Inactive hide details for Christian Pontesegger ---09/07/2015 04:46:40 PM---Hi, for the EASE project I would like to provide doChristian Pontesegger ---09/07/2015 04:46:40 PM---Hi, for the EASE project I would like to provide documentation for code

From: Christian Pontesegger <christian.pontesegger@xxxxxx>
To: jdt-dev@xxxxxxxxxxx
Date: 09/07/2015 04:46 PM
Subject: [jdt-dev] Retrieve javadoc programmatically
Sent by: jdt-dev-bounces@xxxxxxxxxxx





Hi,

for the EASE project I would like to provide documentation for code
completion proposals. There we allow users to use native java classes
from the JDK and eclipse plugins.
To display javadoc contents I would like to reuse the additional
proposals provided from JDT for classes and methods.
I was able to script my way through JDT and get the help for the
java.io.File in the following - scripted - way:


project = new org.eclipse.jdt.internal.core.JavaProject(getProject("Java
1"), null)

sig = new java.lang.String("Ljava.io.File;").toCharArray();
proposal = org.eclipse.jdt.core.CompletionProposal.create(9, 0)
proposal.setSignature(sig)

info = new
org.eclipse.jdt.internal.ui.text.java.TypeProposalInfo(project, proposal)
info.getInfo(null)


The getinfo() call returns the requested string content. My only problem
here is that I always need an existing Java project in the workspace to
derive that information from.
Is it possible to get rid of the local IProject reference into the
workspace?


thanks
Christian
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-dev


GIF image


Back to the top