Skip to content

Commit

Permalink
Removed getElements method
Browse files Browse the repository at this point in the history
  • Loading branch information
ThLeu committed May 19, 2018
1 parent b9976c5 commit 04f28d4
Showing 1 changed file with 8 additions and 13 deletions.
Expand Up @@ -21,12 +21,12 @@ public class Difference {

private static final int STANDARD_INDENTATION_SIZE = 4;

private final List<DifferenceElementCalculator.DifferenceElement> elements;
private final List<DifferenceElementCalculator.DifferenceElement> diffElements;
private final NodeText nodeText;
private final Node node;

Difference(List<DifferenceElementCalculator.DifferenceElement> elements, NodeText nodeText, Node node) {
this.elements = elements;
Difference(List<DifferenceElementCalculator.DifferenceElement> diffElements, NodeText nodeText, Node node) {
this.diffElements = diffElements;
this.nodeText = nodeText;
this.node = node;
}
Expand Down Expand Up @@ -107,16 +107,15 @@ private int considerEnforcingIndentation(NodeText nodeText, int nodeTextIndex) {
* to the difference (adding and removing the elements provided).
*/
void apply() {
if (this.nodeText == null) {
if (nodeText == null) {
throw new NullPointerException();
}
boolean addedIndentation = false;
List<TokenTextElement> indentation = LexicalPreservingPrinter.findIndentation(this.node);
List<TokenTextElement> indentation = LexicalPreservingPrinter.findIndentation(node);

List<TextElement> originalElements = nodeText.getElements();
int originalIndex = 0;

List<DifferenceElementCalculator.DifferenceElement> diffElements = getElements();
int diffIndex = 0;
do {
if (diffIndex < diffElements.size() && originalIndex >= originalElements.size()) {
Expand Down Expand Up @@ -281,7 +280,7 @@ void apply() {
if (originalIndex < originalElements.size() && originalElements.get(originalIndex).isNewline()) {
originalIndex = considerCleaningTheLine(nodeText, originalIndex);
} else {
if (diffIndex + 1 >= this.getElements().size() || !(this.getElements().get(diffIndex + 1) instanceof DifferenceElementCalculator.Added)) {
if (diffIndex + 1 >= diffElements.size() || !(diffElements.get(diffIndex + 1) instanceof DifferenceElementCalculator.Added)) {
originalIndex = considerEnforcingIndentation(nodeText, originalIndex);
}
// If in front we have one space and before also we had space let's drop one space
Expand Down Expand Up @@ -548,7 +547,7 @@ private int adjustIndentation(List<TokenTextElement> indentation, NodeText nodeT
}

private boolean isAReplacement(int diffIndex) {
return (diffIndex > 0) && getElements().get(diffIndex) instanceof DifferenceElementCalculator.Added && getElements().get(diffIndex - 1) instanceof DifferenceElementCalculator.Removed;
return (diffIndex > 0) && diffElements.get(diffIndex) instanceof DifferenceElementCalculator.Added && diffElements.get(diffIndex - 1) instanceof DifferenceElementCalculator.Removed;
}

private boolean isPrimitiveType(TextElement textElement) {
Expand All @@ -568,10 +567,6 @@ private boolean isPrimitiveType(TextElement textElement) {
}
@Override
public String toString() {
return "Difference{" + elements + '}';
}

List<DifferenceElementCalculator.DifferenceElement> getElements() {
return elements;
return "Difference{" + diffElements + '}';
}
}

0 comments on commit 04f28d4

Please sign in to comment.