Package com.github.javaparser.utils
Class PositionUtils
- java.lang.Object
-
- com.github.javaparser.utils.PositionUtils
-
public final class PositionUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description private
PositionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areInOrder(Node a, Node b)
static boolean
areInOrder(Node a, Node b, boolean ignoringAnnotations)
private static int
beginColumnWithoutConsideringAnnotation(Node node)
private static int
beginLineWithoutConsideringAnnotation(Node node)
private static int
compare(Node a, Node b, boolean ignoringAnnotations)
private static Node
firstNonAnnotationNode(Node node)
static AnnotationExpr
getLastAnnotation(Node node)
static boolean
nodeContains(Node container, Node other, boolean ignoringAnnotations)
Compare the position of two nodes.static <T extends Node>
voidsortByBeginPosition(NodeList<T> nodes)
static <T extends Node>
voidsortByBeginPosition(java.util.List<T> nodes)
static <T extends Node>
voidsortByBeginPosition(java.util.List<T> nodes, boolean ignoringAnnotations)
-
-
-
Method Detail
-
sortByBeginPosition
public static <T extends Node> void sortByBeginPosition(java.util.List<T> nodes)
-
sortByBeginPosition
public static <T extends Node> void sortByBeginPosition(java.util.List<T> nodes, boolean ignoringAnnotations)
-
getLastAnnotation
public static AnnotationExpr getLastAnnotation(Node node)
-
beginLineWithoutConsideringAnnotation
private static int beginLineWithoutConsideringAnnotation(Node node)
-
beginColumnWithoutConsideringAnnotation
private static int beginColumnWithoutConsideringAnnotation(Node node)
-
nodeContains
public static boolean nodeContains(Node container, Node other, boolean ignoringAnnotations)
Compare the position of two nodes. Optionally include annotations within the range checks. This method takes into account whether the nodes are within the same compilation unit.Note that this performs a "strict contains", where the container must extend beyond the other node in both directions (otherwise it would count as an overlap, rather than "contain").
If `ignoringAnnotations` is false, annotations on the container are ignored. For this reason, where `container == other`, the raw `other` may extend beyond the sans-annotations `container` thus return false.
-
-