Java Code Examples for org.eclipse.jdt.core.dom.AbstractTypeDeclaration#getJavadoc()

The following examples show how to use org.eclipse.jdt.core.dom.AbstractTypeDeclaration#getJavadoc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XbaseHoverDocumentationProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public Javadoc getJavaDoc() {
	if (context == null || context.eResource() == null || context.eResource().getResourceSet() == null)
		return null;
	Object classpathURIContext = ((XtextResourceSet) context.eResource().getResourceSet()).getClasspathURIContext();
	if (classpathURIContext instanceof IJavaProject) {
		IJavaProject javaProject = (IJavaProject) classpathURIContext;
		@SuppressWarnings("all")
		ASTParser parser = ASTParser.newParser(AST.JLS3);
		parser.setProject(javaProject);
		Map<String, String> options = javaProject.getOptions(true);
		options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207
		parser.setCompilerOptions(options);
		String source = rawJavaDoc + "class C{}"; //$NON-NLS-1$
		parser.setSource(source.toCharArray());
		CompilationUnit root = (CompilationUnit) parser.createAST(null);
		if (root == null)
			return null;
		List<AbstractTypeDeclaration> types = root.types();
		if (types.size() != 1)
			return null;
		AbstractTypeDeclaration type = types.get(0);
		return type.getJavadoc();
	}
	return null;
}
 
Example 2
Source File: JavadocContentAccess2.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static Javadoc getJavadocNode(IJavaElement element, String rawJavadoc) {
	//FIXME: take from SharedASTProvider if available
	//Caveat: Javadoc nodes are not available when Javadoc processing has been disabled!
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207

	String source = rawJavadoc + "class C{}"; //$NON-NLS-1$
	CompilationUnit root = createAST(element, source);
	if (root == null) {
		return null;
	}
	List<AbstractTypeDeclaration> types = root.types();
	if (types.size() != 1) {
		return null;
	}
	AbstractTypeDeclaration type = types.get(0);
	return type.getJavadoc();
}
 
Example 3
Source File: MethodInvocationResolver.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
private void addTypeDoc(AbstractTypeDeclaration ed, String typeFullyQualifiedName) {
    String fullTypeName = currentPackage + "." + typeFullyQualifiedName;
    String docComment = "";
    if (ed.getJavadoc() != null) {
        docComment = ed.getJavadoc().toString();
    }
    typeJavadocs.put(fullTypeName, new TypeJavadoc(fullTypeName, docComment, new HashSet<MethodJavadoc>()));
}
 
Example 4
Source File: JavadocContentAccess2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Javadoc getJavadocNode(IJavaElement element, String rawJavadoc) {
	//FIXME: take from SharedASTProvider if available
	//Caveat: Javadoc nodes are not available when Javadoc processing has been disabled!
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207

	String source= rawJavadoc + "class C{}"; //$NON-NLS-1$
	CompilationUnit root= createAST(element, source);
	if (root == null)
		return null;
	List<AbstractTypeDeclaration> types= root.types();
	if (types.size() != 1)
		return null;
	AbstractTypeDeclaration type= types.get(0);
	return type.getJavadoc();
}
 
Example 5
Source File: UtilTools.java    From apidiff with MIT License 4 votes vote down vote up
public static Boolean containsJavadoc(final AbstractTypeDeclaration node){
	return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? true : false;
}
 
Example 6
Source File: UtilTools.java    From apidiff with MIT License 4 votes vote down vote up
public static String getSufixJavadoc(final AbstractTypeDeclaration node){
	return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? "" : " WITHOUT JAVADOC";
}