本文整理汇总了Java中org.eclipse.jdt.core.dom.Comment.accept方法的典型用法代码示例。如果您正苦于以下问题:Java Comment.accept方法的具体用法?Java Comment.accept怎么用?Java Comment.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Comment
的用法示例。
在下文中一共展示了Comment.accept方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
public void run() {
parser.parse(new TagVisitor());
CommentVisitor commentVisitor = new CommentVisitor();
for (Comment comment : (List<Comment>) cunit.getCommentList())
comment.accept(commentVisitor);
Collections.sort(variables);
}
示例2: modifyCompilationUnit
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
@Override
public void modifyCompilationUnit(CompilationUnit astRoot,
IProgressMonitor monitor) throws JavaModelException, CoreException,
BadLocationException {
final ICompilationUnit adapter = (ICompilationUnit) astRoot
.getJavaElement().getAdapter(IOpenable.class);
modifiedDocument = false;
if (adapter != null) {
document = new Document(adapter.getSource());
List<Comment> commentList = astRoot.getCommentList();
offset = 0;
for (Comment comment : commentList) {
comment.accept(new ASTVisitor() {
@Override
public boolean visit(BlockComment node) {
int startPosition = node.getStartPosition();
int endPosition = startPosition + node.getLength();
try {
int lineOfOffset = document
.getLineOfOffset(startPosition - offset);
startPosition = document
.getLineOffset(lineOfOffset);
int replaceLength = endPosition - startPosition
+ LINE_DELIMITER_LENGTH - offset;
if (startPosition > -1
&& document
.get()
.substring(
startPosition,
startPosition
+ replaceLength)
.contains(NON_JAVADOC_COMMENT)) {
int replaceStart = startPosition
- LINE_DELIMITER_LENGTH;
document.replace(replaceStart, replaceLength,
EMPTY_STRING);
offset = endPosition - startPosition
+ LINE_DELIMITER_LENGTH;
modifiedDocument = true;
}
} catch (BadLocationException e) {
e.printStackTrace();
}
return super.visit(node);
}
});
}
if (modifiedDocument) {
adapter.getBuffer().setContents(document.get());
adapter.save(monitor, true);
}
}
}