resolveFor method
Each PathSegmentCalling calls resolveFor for its children. resolveFor return subsegments that need to be called.
Implementation
CallingPathSegment resolveFor(Iterable<PathSegment> segments) {
CallingPathSegment? result;
if (notProcessedValues.isEmpty) {
result =
CallingPathSegment(segment: PathSegment("*root"), value: "*root");
} else {
next = notProcessedValues.first;
if (segments.contains(PathSegment(next))) {
var seg = segments.firstWhere((element) => element.name == next);
result = NamedCallingSegment(segment: seg as NamedSegment);
} else {
var argSeg = segments.firstWhere(
(element) => element.runtimeType == ArgumentSegment, orElse: () {
return PathSegment("*unknown");
});
if (argSeg.isUnknown) {
result = NamedCallingSegment(segment: NamedSegment("*unknown"));
} else {
result = ArgumentCallingSegment(
value: next, segment: argSeg as ArgumentSegment);
arguments[argSeg.name] = next;
next = "{${argSeg.name}}";
}
}
processed.add(result);
notProcessedValues.removeAt(0);
}
return result;
}