Class LexicalPreservingPrinter.Observer

    • Constructor Detail

      • Observer

        private Observer()
    • Method Detail

      • isCompleteLine

        private boolean isCompleteLine​(java.util.List<TextElement> elements,
                                       int index)
      • removeAllExtraCharacters

        private void removeAllExtraCharacters​(java.util.List<TextElement> elements,
                                              int index)
      • removeAllExtraCharactersBeforePosition

        private void removeAllExtraCharactersBeforePosition​(java.util.ListIterator<TextElement> iterator)
      • removeAllExtraCharactersStartingFrom

        private void removeAllExtraCharactersStartingFrom​(java.util.ListIterator<TextElement> iterator)
      • convertMarkdownCommentContentToTokens

        private java.util.List<TokenTextElement> convertMarkdownCommentContentToTokens​(MarkdownComment comment)
        Comments must be converted to TokenTextElements that the LPP can work with. For the other comments this is simple since there is a TokenType corresponding to them. A TokenTextElement can just be created from the header, footer, and content of the comment. This is not the case for MarkdownComments, however, since a MarkdownComment is made up of a sequence of whitespace and line comment tokens. This sequence is therefore manually reconstructed from the comment content.
      • getIndexAndCountOfCommentTokens

        private Pair<java.lang.Integer,​java.lang.Integer> getIndexAndCountOfCommentTokens​(Comment oldValue,
                                                                                                NodeText nodeText)
      • isSameComment

        private boolean isSameComment​(Comment childValue,
                                      Comment oldValue)
      • fixIndentOfAddedNode

        private void fixIndentOfAddedNode​(NodeText nodeText,
                                          int index)
        This method inserts new space tokens at the given index. If a new comment is added to the token list at the position following index, the new comment and the node will have the same indent.
        Parameters:
        nodeText - The text of the node
        index - The position at which the analysis should start