org.eclipse.jdt.core.dom.AbstractTypeDeclaration#getJavadoc ( )源码实例Demo

下面列出了org.eclipse.jdt.core.dom.AbstractTypeDeclaration#getJavadoc ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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;
}
 
源代码2 项目: eclipse.jdt.ls   文件: JavadocContentAccess2.java
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();
}
 
源代码3 项目: KodeBeagle   文件: MethodInvocationResolver.java
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>()));
}
 
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();
}
 
源代码5 项目: apidiff   文件: UtilTools.java
public static Boolean containsJavadoc(final AbstractTypeDeclaration node){
	return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? true : false;
}
 
源代码6 项目: apidiff   文件: UtilTools.java
public static String getSufixJavadoc(final AbstractTypeDeclaration node){
	return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? "" : " WITHOUT JAVADOC";
}