@Override public CharSequence getCode(Object impl) { SourceSection section = (SourceSection) impl; return section.getCharacters(); }
@Override public CharSequence getCode(Object impl) { SourceSection section = (SourceSection) impl; return section.getCharacters(); }
/** * @since 0.8 or earlier * @deprecated use {@link #getCharacters()} instead */ @Deprecated public String getCode() { return getCharacters().toString(); }
private static String displaySourceAttribution(Node node) { final SourceSection section = node.getSourceSection(); if (section == null) { return ""; } if (section.getSource() == null) { // TODO we can remove this block if SourceSection#createUnavailable was removed, because // then source cannot become null anymore. return "source: <unknown>"; } final String srcText = section.getCharacters().toString(); final StringBuilder sb = new StringBuilder(); sb.append("source:"); sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); sb.append(" line=" + section.getStartLine()); sb.append(" len=" + srcText.length()); sb.append(" text=\"" + srcText + "\""); return sb.toString(); }
private static String displaySourceAttribution(Node node) { final SourceSection section = node.getSourceSection(); if (section == null) { return ""; } if (section.getSource() == null) { // TODO we can remove this block if SourceSection#createUnavailable was removed, because // then source cannot become null anymore. return "source: <unknown>"; } final String srcText = section.getCharacters().toString(); final StringBuilder sb = new StringBuilder(); sb.append("source:"); sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); sb.append(" line=" + section.getStartLine()); sb.append(" len=" + srcText.length()); sb.append(" text=\"" + srcText + "\""); return sb.toString(); }
/** * Returns an implementation-defined string representation of this source section to be used for * debugging purposes only. * * @see #getCharacters() * @since 0.8 or earlier */ @Override public String toString() { StringBuilder b = new StringBuilder(); b.append("SourceSection(source=").append(getSource().getName()); if (isAvailable()) { b.append(", index=").append(getCharIndex()); b.append(", length=").append(getCharLength()); if (isValid()) { b.append(", characters=").append(getCharacters().toString().replaceAll("\\n", "\\\\n")); } else { b.append(", valid=false"); } } else { b.append(" available=false"); } b.append(")"); return b.toString(); }
b.append(", characters=").append(getCharacters().toString().replaceAll("\\n", "\\\\n")); } else { b.append(", characters not known");