Class PositionUtils


  • public final class PositionUtils
    extends java.lang.Object
    • Constructor Detail

      • PositionUtils

        private PositionUtils()
    • Method Detail

      • sortByBeginPosition

        public static <T extends Node> void sortByBeginPosition​(java.util.List<T> nodes)
      • sortByBeginPosition

        public static <T extends Node> void sortByBeginPosition​(NodeList<T> nodes)
      • sortByBeginPosition

        public static <T extends Node> void sortByBeginPosition​(java.util.List<T> nodes,
                                                                boolean ignoringAnnotations)
      • areInOrder

        public static boolean areInOrder​(Node a,
                                         Node b)
      • areInOrder

        public static boolean areInOrder​(Node a,
                                         Node b,
                                         boolean ignoringAnnotations)
      • compare

        private static int compare​(Node a,
                                   Node b,
                                   boolean ignoringAnnotations)
      • beginLineWithoutConsideringAnnotation

        private static int beginLineWithoutConsideringAnnotation​(Node node)
      • beginColumnWithoutConsideringAnnotation

        private static int beginColumnWithoutConsideringAnnotation​(Node node)
      • firstNonAnnotationNode

        private static Node firstNonAnnotationNode​(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.