private void finalizeMods() { if (replacedSequence == null) { replacedSequence = SegmentedSequence.of(replacedSegments); } }
@Override public BasedSequence getContentChars() { return SegmentedSequence.of(lineSegments); }
public BasedSequence toBasedSequence() { return SegmentedSequence.of(segments); }
public static BasedSequence of(BasedSequence... segments) { return of(Arrays.asList(segments)); } }
/** * Get the char sequence from segments making up the node's characters. * <p> * Used to get segments after the some of the node's elements were modified * * @return concatenated string of all segments */ public BasedSequence getCharsFromSegments() { return SegmentedSequence.of(Arrays.asList(getSegmentsForChars())); }
public BasedSequence getContents(int startLine, int endLine) { if (lines.size() == 0) return BasedSequence.NULL; if (startLine < 0) { throw new IndexOutOfBoundsException("startLine must be at least 0"); } if (endLine < 0) { throw new IndexOutOfBoundsException("endLine must be at least 0"); } if (endLine < startLine) { throw new IndexOutOfBoundsException("endLine must not be less than startLine"); } if (endLine > lines.size()) { throw new IndexOutOfBoundsException("endLine must not be greater than line cardinality"); } return SegmentedSequence.of(lines.subList(startLine, endLine)); }
@Override public BasedSequence getContentChars(int startLine, int endLine) { return SegmentedSequence.of(getContentLines(startLine, endLine)); }
@Override public boolean flushTextNode() { if (currentText != null) { block.appendChild(new Text(SegmentedSequence.of(currentText))); currentText = null; return true; } return false; }
public static BasedSequence stripIndent(BasedSequence input, CharSequence sourceIndent) { BasedSequence result = input; if (sourceIndent.length() != 0) { // strip out indent to test how segmented input parses ArrayList<BasedSequence> segments = new ArrayList<>(); int lastPos = 0; int length = input.length(); while (lastPos < length) { int pos = input.indexOf(sourceIndent, lastPos); int end = pos == -1 ? length : pos; if (lastPos < end && (pos <= 0 || input.charAt(pos - 1) == '\n')) { segments.add(input.subSequence(lastPos, end)); } lastPos = end + sourceIndent.length(); } result = SegmentedSequence.of(segments); } return result; }
@Override public void mergeIfNeeded(Text first, Text last) { if (first != null && last != null && first != last) { ArrayList<BasedSequence> sb = new ArrayList<BasedSequence>(); sb.add(first.getChars()); Node node = first.getNext(); Node stop = last.getNext(); while (node != stop) { sb.add(node.getChars()); Node unlink = node; node = node.getNext(); unlink.unlink(); } BasedSequence literal = SegmentedSequence.of(sb); first.setChars(literal); } }
if (matcher.matches()) { if (currentValues.size() == 1) { BasedSequence combined = SegmentedSequence.of(currentValues.get(0), PrefixedSubSequence.of("\n", line.subSequence(matcher.start(1), matcher.end(1)).trim())); currentValues.set(0, combined); } else {
block.appendChild(codeBlock); } else { Text codeBlock = new Text(SegmentedSequence.of(segments)); block.appendChild(codeBlock);
return segments.size() == 1 ? segments.get(0) : SegmentedSequence.of(segments); } else { return firstChild.getChars().baseSubSequence(firstChild.getStartOffset(), lastChild.getEndOffset());
private void finalizeMods() { if (replacedSequence == null) { replacedSequence = SegmentedSequence.of(replacedSegments); } }
@Override public BasedSequence getContentChars() { return SegmentedSequence.of(lineSegments); }
public static BasedSequence of(BasedSequence... segments) { return of(Arrays.asList(segments)); } }
BasedSequence prevText = SegmentedSequence.of(currentText); currentText = null;
@Override public BasedSequence getContentChars(int startLine, int endLine) { return SegmentedSequence.of(getContentLines(startLine, endLine)); }
original = SegmentedSequence.of(combinedSequences);
@Override public boolean flushTextNode() { if (currentText != null) { block.appendChild(new Text(SegmentedSequence.of(currentText))); currentText = null; return true; } return false; }