本文整理匯總了Java中org.eclipse.jdt.core.dom.CompilationUnit.getCommentList方法的典型用法代碼示例。如果您正苦於以下問題:Java CompilationUnit.getCommentList方法的具體用法?Java CompilationUnit.getCommentList怎麽用?Java CompilationUnit.getCommentList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.CompilationUnit
的用法示例。
在下文中一共展示了CompilationUnit.getCommentList方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import org.eclipse.jdt.core.dom.CompilationUnit; //導入方法依賴的package包/類
/**
* @see ASTVisitor#visit(CompilationUnit)
*/
@SuppressWarnings("unchecked")
@Override
public boolean visit(CompilationUnit unit) {
List<Comment> commentList = unit.getCommentList();
for (Comment comment : commentList) {
comment.delete();
}
this.numberOfLinesOfCode = (double) unit.toString().split("\n").length;
return false;
}
示例2: serializeAll
import org.eclipse.jdt.core.dom.CompilationUnit; //導入方法依賴的package包/類
private void serializeAll(CompilationUnit cu, ASTNode node, JsonGenerator jG, SerializerProvider provider) throws IOException {
List<StructuralPropertyDescriptor> descriptorList = node.structuralPropertiesForType();
jG.writeStartObject();
final int Ntype = node.getNodeType();
String ClassName = node.nodeClassForType(Ntype).getName().substring(25);
jG.writeFieldName("internalClass");
jG.writeString(ClassName);
for (StructuralPropertyDescriptor descriptor : descriptorList) {
Object child = node.getStructuralProperty(descriptor);
if (child instanceof List) {
serializeChildList(cu, (List<ASTNode>) child, jG, descriptor, provider);
} else if (child instanceof ASTNode) {
serializeChild(cu, (ASTNode) child, jG, descriptor, provider);
} else if (child != null) {
jG.writeFieldName(descriptor.getId());
jG.writeString(child.toString());
serializePosition(cu, node, jG);
}
}
if (node == cu) {
List<Comment> cl = cu.getCommentList();
if (!cl.isEmpty()) {
jG.writeFieldName("comments");
jG.writeStartArray();
for (Comment c: (List<Comment>) cu.getCommentList()) {
if (c.getParent() != null) continue;
jG.writeStartObject();
final int type = c.getNodeType();
String name = c.nodeClassForType(type).getName().substring(25);
jG.writeFieldName("internalClass");
jG.writeString(name);
serializePosition(cu, (ASTNode)c, jG);
jG.writeEndObject();
}
jG.writeEndArray();
}
}
jG.writeEndObject();
}
示例3: getCommentList
import org.eclipse.jdt.core.dom.CompilationUnit; //導入方法依賴的package包/類
/**
* Returns list of {@link Comment}
*
* @param compilationUnit
* compilation unit to be analyzed
* @return lists of comments
*/
@SuppressWarnings("unchecked")
private List<Comment> getCommentList(final CompilationUnit compilationUnit) {
return compilationUnit.getCommentList();
}