Class LexicalPreservingPrinter.Observer

java.lang.Object
com.github.javaparser.ast.observer.PropagatingAstObserver
com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter.Observer
All Implemented Interfaces:
AstObserver
Enclosing class:
LexicalPreservingPrinter

private static class LexicalPreservingPrinter.Observer extends PropagatingAstObserver
  • Constructor Details

    • Observer

      private Observer()
  • Method Details

    • concretePropertyChange

      public void concretePropertyChange(Node observedNode, ObservableProperty property, Object oldValue, Object newValue)
      Overrides:
      concretePropertyChange in class PropagatingAstObserver
    • isCompleteLine

      private boolean isCompleteLine(List<TextElement> elements, int index)
    • removeAllExtraCharacters

      private void removeAllExtraCharacters(List<TextElement> elements, int index)
    • removeAllExtraCharactersBeforePosition

      private void removeAllExtraCharactersBeforePosition(ListIterator<TextElement> iterator)
    • removeAllExtraCharactersStartingFrom

      private void removeAllExtraCharactersStartingFrom(ListIterator<TextElement> iterator)
    • convertMarkdownCommentContentToTokens

      private 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.
    • makeCommentTokens

      private List<TokenTextElement> makeCommentTokens(Comment newComment)
    • getIndexAndCountOfCommentTokens

      private Pair<Integer,Integer> getIndexAndCountOfCommentTokens(Comment oldValue, NodeText nodeText)
    • findChildTextElementForComment

      private List<ChildTextElement> findChildTextElementForComment(Comment oldValue, NodeText nodeText)
    • selectMatchingChildElements

      private List<ChildTextElement> selectMatchingChildElements(Comment oldValue, NodeText nodeText)
    • isSameComment

      private boolean isSameComment(Comment childValue, Comment oldValue)
    • findTokenTextElementForComment

      private List<TokenTextElement> findTokenTextElementForComment(Comment oldValue, NodeText nodeText)
    • 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
    • concreteListChange

      public void concreteListChange(NodeList<?> changedList, AstObserver.ListChangeType type, int index, Node nodeAddedOrRemoved)
      Overrides:
      concreteListChange in class PropagatingAstObserver
    • concreteListReplacement

      public void concreteListReplacement(NodeList<?> changedList, int index, Node oldValue, Node newValue)
      Overrides:
      concreteListReplacement in class PropagatingAstObserver