private HighlightedTextWriter end(HighlightType expectedType) { if (hilight) { Highlighting h = hilightStack.pop(); h.len = sb.length() - newLineCount - h.startPos; if (!expectedType.equals(h.type)) { throw new Error("Hilighting mismatch."); } switch (h.type) { case CLASS: classHilights.add(h); break; case METHOD: methodHilights.add(h); break; case TRAIT: traitHilights.add(h); break; case SPECIAL: specialHilights.add(h); break; case OFFSET: instructionHilights.add(h); break; } } return this; }
@Override public HighlightedTextWriter appendWithData(String str, HighlightData data) { Highlighting h = null; if (!offsets.empty()) { GraphSourceItemPosition itemPos = offsets.peek(); GraphSourceItem src = itemPos.graphSourceItem; int pos = itemPos.position; if (src != null && hilight) { HighlightData ndata = new HighlightData(); ndata.merge(itemPos.data); ndata.merge(data); ndata.offset = src.getAddress() + pos; ndata.fileOffset = src.getFileOffset(); if (itemPos.startLineItem != null) { ndata.firstLineOffset = itemPos.startLineItem.getLineOffset(); } h = new Highlighting(sb.length() - newLineCount, ndata, HighlightType.OFFSET, str); instructionHilights.add(h); } } appendToSb(str); if (h != null) { h.len = sb.length() - newLineCount - h.startPos; } return this; }
@Override public HighlightedTextWriter append(String str, long offset, long fileOffset) { Highlighting h = null; if (hilight) { HighlightData data = new HighlightData(); data.offset = offset; data.fileOffset = fileOffset; h = new Highlighting(sb.length() - newLineCount, data, HighlightType.OFFSET, str); instructionHilights.add(h); } appendToSb(str); if (h != null) { h.len = sb.length() - newLineCount - h.startPos; } return this; }