本文整理汇总了Java中org.eclipse.jdt.core.dom.Comment.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Comment.getLength方法的具体用法?Java Comment.getLength怎么用?Java Comment.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Comment
的用法示例。
在下文中一共展示了Comment.getLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doComments
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
private void doComments(ASTNode node, boolean post) {
Comment c = comments.peek();
while (c != null && c.getStartPosition() > endOfLastNode) {
int startOfNextNode = post ? siblingOrParentPosition(node)
: node.getStartPosition();
if (c.getStartPosition() + c.getLength() < startOfNextNode) {
comments.remove().accept(this);
c = comments.peek();
} else {
break;
}
}
endOfLastNode = node.getStartPosition() + node.getLength();
}
示例2: getNewUnitSource
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
/**
* Gets compilation unit's source
*
* @param unit
* affected compilation unit
* @param comment
* comment to be replaced; set null if comment is not present
* @return new compilation unit's source
*/
private String getNewUnitSource(final ICompilationUnit unit, final Comment comment) {
String source = null;
try {
source = unit.getSource();
if (comment != null) {
final int endOfComment = comment.getLength() + comment.getStartPosition();
source = source.replace(source.substring(0, endOfComment), getCopyrightText());
}
} catch (final JavaModelException e) {
ConsoleUtils.printError(e.getMessage());
}
return source;
}
示例3: extractCommentItem
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
private final CommentItem extractCommentItem(final int index) {
if (commentsVisited[index]) {
return null;
} else {
final Comment comment = (Comment) comments.get(index);
if (comment.isDocComment()) {
/* Interpret DocComment as Line or Block */
comment.delete();
}
final int start = comment.getStartPosition();
final int end = start + comment.getLength();
final String value = this.src.substring(start, end);
return new CommentItem(comment, value);
}
}
示例4: getNodeFirstLeadingCommentIndex
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
private final int getNodeFirstLeadingCommentIndex(final ASTNode node) {
if (node instanceof PackageDeclaration) {
if (commentsVisited.length > 0) {
final Comment comment = (Comment) comments.get(0);
if (comment.getStartPosition() + comment.getLength() <= ((PackageDeclaration) node).getName()
.getStartPosition()) {
return 0;
}
}
return -1;
} else {
return cu.firstLeadingCommentIndex(node);
}
}
示例5: getCommentContent
import org.eclipse.jdt.core.dom.Comment; //导入方法依赖的package包/类
/** Extract comment content from source. */
private String getCommentContent(Comment comment) {
int start = comment.getStartPosition();
int end = start + comment.getLength();
String content = routeSource.substring(start, end);
if (content.startsWith("//")) {
content = content.substring(2).trim();
}
return content;
}