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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.javaparser.ast.observer.AstObserver
AstObserver.ListChangeType
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Observer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
concreteListChange(NodeList<?> changedList, AstObserver.ListChangeType type, int index, Node nodeAddedOrRemoved)
void
concreteListReplacement(NodeList<?> changedList, int index, Node oldValue, Node newValue)
void
concretePropertyChange(Node observedNode, ObservableProperty property, java.lang.Object oldValue, java.lang.Object newValue)
private java.util.List<ChildTextElement>
findChildTextElementForComment(Comment oldValue, NodeText nodeText)
private java.util.List<TokenTextElement>
findTokenTextElementForComment(Comment oldValue, NodeText nodeText)
private void
fixIndentOfAddedNode(NodeText nodeText, int index)
This method inserts new space tokens at the givenindex
.private int
getIndexOfComment(Comment oldValue, NodeText nodeText)
private boolean
isCompleteLine(java.util.List<TextElement> elements, int index)
private boolean
isEqualRange(java.util.Optional<Range> range1, java.util.Optional<Range> range2)
private boolean
isSameComment(Comment childValue, Comment oldValue)
private TokenTextElement
makeCommentToken(Comment newComment)
private void
removeAllExtraCharacters(java.util.List<TextElement> elements, int index)
private void
removeAllExtraCharactersBeforePosition(java.util.ListIterator<TextElement> iterator)
private void
removeAllExtraCharactersStartingFrom(java.util.ListIterator<TextElement> iterator)
private java.util.List<ChildTextElement>
selectMatchingChildElements(Comment oldValue, NodeText nodeText)
-
Methods inherited from class com.github.javaparser.ast.observer.PropagatingAstObserver
listChange, listReplacement, parentChange, propertyChange, transformInPropagatingObserver
-
-
-
-
Method Detail
-
concretePropertyChange
public void concretePropertyChange(Node observedNode, ObservableProperty property, java.lang.Object oldValue, java.lang.Object newValue)
- Overrides:
concretePropertyChange
in classPropagatingAstObserver
-
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)
-
makeCommentToken
private TokenTextElement makeCommentToken(Comment newComment)
-
findChildTextElementForComment
private java.util.List<ChildTextElement> findChildTextElementForComment(Comment oldValue, NodeText nodeText)
-
selectMatchingChildElements
private java.util.List<ChildTextElement> selectMatchingChildElements(Comment oldValue, NodeText nodeText)
-
findTokenTextElementForComment
private java.util.List<TokenTextElement> findTokenTextElementForComment(Comment oldValue, NodeText nodeText)
-
isEqualRange
private boolean isEqualRange(java.util.Optional<Range> range1, java.util.Optional<Range> range2)
-
fixIndentOfAddedNode
private void fixIndentOfAddedNode(NodeText nodeText, int index)
This method inserts new space tokens at the givenindex
. If a new comment is added to the token list at the position followingindex
, the new comment and the node will have the same indent.- Parameters:
nodeText
- The text of the nodeindex
- The position at which the analysis should start
-
concreteListChange
public void concreteListChange(NodeList<?> changedList, AstObserver.ListChangeType type, int index, Node nodeAddedOrRemoved)
- Overrides:
concreteListChange
in classPropagatingAstObserver
-
concreteListReplacement
public void concreteListReplacement(NodeList<?> changedList, int index, Node oldValue, Node newValue)
- Overrides:
concreteListReplacement
in classPropagatingAstObserver
-
-