下面列出了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;
}
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();
}
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();
}
public static Boolean containsJavadoc(final AbstractTypeDeclaration node){
return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? true : false;
}
public static String getSufixJavadoc(final AbstractTypeDeclaration node){
return ((node != null) && (node.getJavadoc() != null) && (!node.getJavadoc().equals("")))? "" : " WITHOUT JAVADOC";
}