本文整理汇总了Java中com.github.javaparser.ast.Node.hasComment方法的典型用法代码示例。如果您正苦于以下问题:Java Node.hasComment方法的具体用法?Java Node.hasComment怎么用?Java Node.hasComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.Node
的用法示例。
在下文中一共展示了Node.hasComment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attributeLineCommentToNodeOrChild
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private boolean attributeLineCommentToNodeOrChild(Node node, LineComment lineComment) {
// The node start and end at the same line as the comment,
// let's give to it the comment
if (node.getBegin().line == lineComment.getBegin().line
&& !node.hasComment()) {
if(!(node instanceof Comment)) {
node.setComment(lineComment);
}
return true;
} else {
// try with all the children, sorted by reverse position (so the
// first one is the nearest to the comment
List<Node> children = new LinkedList<Node>();
children.addAll(node.getChildrenNodes());
PositionUtils.sortByBeginPosition(children);
Collections.reverse(children);
for (Node child : children) {
if (attributeLineCommentToNodeOrChild(child, lineComment)) {
return true;
}
}
return false;
}
}
示例2: attributeLineCommentToNodeOrChild
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private static boolean attributeLineCommentToNodeOrChild(Node node, LineComment lineComment)
{
// The node start and end at the same line as the comment,
// let's give to it the comment
if (node.getBeginLine()==lineComment.getBeginLine() && !node.hasComment())
{
node.setComment(lineComment);
return true;
} else {
// try with all the children, sorted by reverse position (so the
// first one is the nearest to the comment
List<Node> children = new LinkedList<Node>();
children.addAll(node.getChildrenNodes());
PositionUtils.sortByBeginPosition(children);
Collections.reverse(children);
for (Node child : children)
{
if (attributeLineCommentToNodeOrChild(child, lineComment))
{
return true;
}
}
return false;
}
}