Class PmdCoordinatesSystem


  • public final class PmdCoordinatesSystem
    extends java.lang.Object
    Maps PMD's (line, column) coordinate system to and from the code area's one-dimensional (absolute offset-based) system.
    Since:
    6.13.0
    Author:
    Clément Fournier
    • Method Detail

      • getRtfxParIndexFromPmdLine

        public static int getRtfxParIndexFromPmdLine​(int line)
      • getPmdLineFromRtfxParIndex

        public static int getPmdLineFromRtfxParIndex​(int line)
      • getOffsetFromPmdPosition

        public static int getOffsetFromPmdPosition​(org.fxmisc.richtext.CodeArea codeArea,
                                                   int line,
                                                   int column)
        Returns the absolute offset of the given pair (line, column) as computed by a PMD parser in the code area. CodeArea counts a tab as 1 column width but displays it as 8 columns width. PMD counts it correctly as 8 columns, so the position must be offset. Also, PMD lines start at 1 but paragraph nums start at 0 in the code area, same for columns.
      • findNodeAt

        public static java.util.Optional<net.sourceforge.pmd.lang.ast.Node> findNodeAt​(net.sourceforge.pmd.lang.ast.Node root,
                                                                                       PmdCoordinatesSystem.TextPos2D target)
        Locates the innermost node in the given [root] that contains the position at [textOffset] in the [codeArea].
      • findNodeCovering

        public static java.util.Optional<net.sourceforge.pmd.lang.ast.Node> findNodeCovering​(net.sourceforge.pmd.lang.ast.Node root,
                                                                                             PmdCoordinatesSystem.TextRange range,
                                                                                             boolean exact)
        Returns the innermost node that covers the entire given text range in the given tree.
        Parameters:
        root - Root of the tree
        range - Range to find
        exact - If true, will return the *outermost* node whose range is *exactly* the given text range, otherwise it may be larger.
      • contains

        public static boolean contains​(net.sourceforge.pmd.lang.ast.Node node,
                                       PmdCoordinatesSystem.TextPos2D pos)
        Returns true if the given node contains the position.