List of usage examples for org.eclipse.jdt.core IMethod getAttachedJavadoc
String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException;
Returns the Javadoc as HTML source if this element has attached Javadoc, null otherwise.
This should be used only for binary elements.
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
/** * Finds the first available attached Javadoc in the hierarchy of the given method. * * @param method the method//from w w w .j a v a 2 s . c o m * @return the inherited Javadoc from the Javadoc attachment, or <code>null</code> if none * @throws JavaModelException unexpected problem */ private static String findAttachedDocInHierarchy(final IMethod method) throws JavaModelException { IType type = method.getDeclaringType(); ITypeHierarchy hierarchy = SuperTypeHierarchyCache.getTypeHierarchy(type); final MethodOverrideTester tester = SuperTypeHierarchyCache.getMethodOverrideTester(type); return (String) new InheritDocVisitor() { @Override public Object visit(IType currType) throws JavaModelException { IMethod overridden = tester.findOverriddenMethodInType(currType, method); if (overridden == null) return InheritDocVisitor.CONTINUE; if (overridden.getOpenable().getBuffer() == null) { // only if no source available String attachedJavadoc = overridden.getAttachedJavadoc(null); if (attachedJavadoc != null) { // BaseURL for the original method can be wrong for attached Javadoc from overridden // (e.g. when overridden is from rt.jar). // Fix is to store the baseURL inside the doc content and later fetch it with #extractBaseURL(String). String baseURL = JavaDocLocations.getBaseURL(overridden, overridden.isBinary()); if (baseURL != null) { attachedJavadoc = BASE_URL_COMMENT_INTRO + baseURL + "\"--> " + attachedJavadoc; //$NON-NLS-1$ } return attachedJavadoc; } } return CONTINUE; } }.visitInheritDoc(type, hierarchy); }
From source file:org.eclipse.che.jdt.javadoc.JavadocContentAccess2.java
License:Open Source License
/** * Finds the first available attached Javadoc in the hierarchy of the given method. * * @param method/* w w w . ja v a 2s .c o m*/ * the method * @return the inherited Javadoc from the Javadoc attachment, or <code>null</code> if none * @throws org.eclipse.jdt.core.JavaModelException * unexpected problem */ private static String findAttachedDocInHierarchy(final IMethod method) throws JavaModelException { IType type = method.getDeclaringType(); ITypeHierarchy hierarchy = SuperTypeHierarchyCache.getTypeHierarchy(type); final MethodOverrideTester tester = SuperTypeHierarchyCache.getMethodOverrideTester(type); return (String) new InheritDocVisitor() { @Override public Object visit(IType currType) throws JavaModelException { IMethod overridden = tester.findOverriddenMethodInType(currType, method); if (overridden == null) return InheritDocVisitor.CONTINUE; if (overridden.getOpenable().getBuffer() == null) { // only if no source available //TODO: BaseURL for method can be wrong for attached Javadoc from overridden // (e.g. when overridden is from rt.jar). Fix would be to add baseURL here. String attachedJavadoc = overridden.getAttachedJavadoc(null); if (attachedJavadoc != null) return attachedJavadoc; } return CONTINUE; } }.visitInheritDoc(type, hierarchy); }