[Eclipse plug-in development] Javadoc acquisition

I don't think anyone is interested, but I had a little trouble finding it, so I'll write it down as a reminder.

ʻOrg.eclipse.jdt.ui.JavadocContentAcces # getContentReader` is used.

import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.ui.JavadocContentAccess;
//・ ・ ・

	public static String getJavadoc(IMember member) {
		try {
			Reader reader = JavadocContentAccess.getContentReader(member, false);
			if (reader == null) {
				return null;
			}
			try {
				StringBuilder buf = new StringBuilder();
				int ch;
				while ((ch = reader.read()) != -1) {
					buf.append((char) ch);
				}
				return buf.toString();
			} finally {
				reader.close();
			}
		} catch (IOException | JavaModelException e) {
			return null;
		}
	}

ʻOrg.eclipse.jdt.ui.JavadocContentAccess is ** ʻorg.eclipse.jdt.ui**, ʻOrg.eclipse.jdt.core.IMember is ** ʻorg.eclipse.jdt.core ** Can be used by putting in a dependency.

ʻI Member` is the parent interface for Field, Method, Class, Constructor (IInitializer), etc.

To find out how to access to ʻI Member, go to ʻI Java Project and ʻI Type`. Hishidama and the bible for personal Eclipse plug-in development, [Eclipse / TIPS collection of plug-in development](http://www.masatom.in/pukiwiki/Eclipse/%A5%D7%A5%E9%A5%B0%A5%A4%A5%F3%B3%AB%C8%AF % A4% CETIPS% BD% B8 /) I think it will come out if you lick it. (I will write an article if I feel like it)

Recommended Posts

[Eclipse plug-in development] Javadoc acquisition
Convenient plugin for Eclipse JAVA development: Decompiler
astah * plugin development snippet
Plugin development with ImageJ
THETA plugin development (about theta-plugin-sdk)
Install the plugin in Eclipse
Personal memo Eclipse plug-in installation
Java development environment (Mac, Eclipse)
First Java development in Eclipse
Eclipse 4.8 introduction memo (Plugin edition)
Install tomcat plugin in eclipse
[Eclipse Java] Development environment setting memo
Team development using Git (eclipse edition)
Use the Findbugs plugin in Eclipse
Build jooby development environment with Eclipse