Skip to content

Commit

Permalink
Rename field to reflect that is may be either a segment or a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeEdgar committed Jun 13, 2020
1 parent f207129 commit 838f530
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class Validator {
private UsageNode element;

private boolean implSegmentSelected;
private UsageNode implSegment;
private UsageNode implNode;
private UsageNode implComposite;
private UsageNode implElement;
private List<UsageNode> implSegmentCandidates = new ArrayList<>();
Expand Down Expand Up @@ -138,10 +138,10 @@ public Validator(Schema schema, boolean validateCodeValues, Schema containerSche

if (schema.getImplementation() != null) {
implRoot = buildTree(null, 0, schema.getImplementation(), -1);
implSegment = implRoot.getFirstChild();
implNode = implRoot.getFirstChild();
} else {
implRoot = null;
implSegment = null;
implNode = null;
}
}

Expand All @@ -155,7 +155,7 @@ public void reset() {

if (implRoot != null) {
implRoot.reset();
implSegment = implRoot.getFirstChild();
implNode = implRoot.getFirstChild();
}

cursor.reset(root, implRoot);
Expand All @@ -181,7 +181,7 @@ public boolean isPendingDiscrimination() {

public String getSegmentReferenceCode() {
if (implSegmentSelected) {
return implSegment.getCode();
return implNode.getCode();
}
return segment.getCode();
}
Expand Down Expand Up @@ -324,7 +324,7 @@ private void completeLoops(ValidationEventHandler handler, int workingDepth) {
workingDepth--;

if (loop.isImplementation()) {
implSegment = loop;
implNode = loop;
}
}
}
Expand All @@ -337,7 +337,7 @@ public void validateSegment(ValidationEventHandler handler, CharSequence tag) {
final int startDepth = this.depth;

cursor.standard = correctSegment;
cursor.impl = implSegment;
cursor.impl = implNode;

useErrors.clear();
boolean handled = false;
Expand Down Expand Up @@ -445,7 +445,7 @@ boolean handleSegment(CharSequence tag, UsageNode current, UsageNode currentImpl
handleMissingMandatory(handler);
handler.segmentError(current.getId(), IMPLEMENTATION_UNUSED_SEGMENT_PRESENT);
// Save the currentImpl so that the search is resumed from the correct location
implSegment = currentImpl;
implNode = currentImpl;
} else if (implSegmentCandidates.size() == 1) {
currentImpl.incrementUsage();
currentImpl.resetChildren();
Expand All @@ -454,7 +454,7 @@ boolean handleSegment(CharSequence tag, UsageNode current, UsageNode currentImpl
handler.segmentError(currentImpl.getId(), SEGMENT_EXCEEDS_MAXIMUM_USE);
}

implSegment = currentImpl;
implNode = currentImpl;
implSegmentCandidates.clear();
implSegmentSelected = true;
}
Expand Down Expand Up @@ -528,7 +528,7 @@ boolean handleLoop(CharSequence tag, UsageNode current, UsageNode currentImpl, i
handleMissingMandatory(handler);
handler.segmentError(segment.getId(), IMPLEMENTATION_UNUSED_SEGMENT_PRESENT);
// Save the currentImpl so that the search is resumed from the correct location
implSegment = currentImpl;
implNode = currentImpl;
}
}

Expand Down Expand Up @@ -647,13 +647,13 @@ public boolean selectImplementation(StreamEvent[] events, int index, int count,
if (isMatch(implType, currentEvent)) {
handleImplementationSelected(candidate, implSeg, handler);

if (implSegment.isFirstChild()) {
if (implNode.isFirstChild()) {
//start of loop
setLoopReferenceCode(events, index, count - 1, implType);

// Replace the standard loop with the implementation on the stack
loopStack.pop();
loopStack.push(implSegment.getParent());
loopStack.push(implNode.getParent());
}

return true;
Expand All @@ -664,9 +664,9 @@ public boolean selectImplementation(StreamEvent[] events, int index, int count,
}

void handleImplementationSelected(UsageNode candidate, UsageNode implSeg, ValidationEventHandler handler) {
checkMinimumImplUsage(implSegment, candidate, handler);
checkMinimumImplUsage(implNode, candidate, handler);
implSegmentCandidates.clear();
implSegment = implSeg;
implNode = implSeg;
implSegmentSelected = true;

if (candidate.isNodeType(Type.LOOP)) {
Expand Down Expand Up @@ -757,7 +757,7 @@ public List<UsageError> getElementErrors() {

UsageNode getImplElement(int index) {
if (implSegmentSelected) {
return this.implSegment.getChild(index);
return this.implNode.getChild(index);
}

return null;
Expand Down Expand Up @@ -982,7 +982,7 @@ public void validateSyntax(ElementDataHandler handler, ValidationEventHandler va
}

if (!isComposite && implSegmentSelected && index == children.size()) {
UsageNode previousImpl = implSegment.getChild(elementPosition);
UsageNode previousImpl = implNode.getChild(elementPosition);

if (tooFewRepetitions(previousImpl)) {
validationHandler.elementError(IMPLEMENTATION_TOO_FEW_REPETITIONS.getCategory(),
Expand Down

0 comments on commit 838f530

Please sign in to comment.