本文整理汇总了Java中com.github.javaparser.ast.Node.getBeginLine方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getBeginLine方法的具体用法?Java Node.getBeginLine怎么用?Java Node.getBeginLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.Node
的用法示例。
在下文中一共展示了Node.getBeginLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeContains
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static boolean nodeContains(Node container, Node contained, boolean ignoringAnnotations){
if (!ignoringAnnotations || PositionUtils.getLastAnnotation(container)==null){
return container.contains(contained);
}
if (!container.contains(contained)){
return false;
}
// if the node is contained, but it comes immediately after the annotations,
// let's not consider it contained
if (container instanceof AnnotableNode){
int bl = beginLineWithoutConsideringAnnotation(container);
int bc = beginColumnWithoutConsideringAnnotation(container);
if (bl>contained.getBeginLine()) return false;
if (bl==contained.getBeginLine() && bc>contained.getBeginColumn()) return false;
if (container.getEndLine()<contained.getEndLine()) return false;
if (container.getEndLine()==contained.getEndLine() && container.getEndColumn()<contained.getEndColumn()) return false;
return true;
}
return true;
}
示例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;
}
}
示例3: thereAreLinesBetween
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private static boolean thereAreLinesBetween(Node a, Node b)
{
if (!PositionUtils.areInOrder(a, b))
{
return thereAreLinesBetween(b, a);
}
int endOfA = a.getEndLine();
return b.getBeginLine()>(a.getEndLine()+1);
}
示例4: beginOf
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static Position beginOf(Node node){
return new Position(node.getBeginLine(),node.getBeginColumn());
}