public void WriteTo(IDecompilerOutput output) { #if DEBUG for (int i = 1; i < references.Count; i++) { if (references[i - 1].Span.End > references[i].Span.Start) { throw new InvalidOperationException(); } } #endif int outputStart = output.Length; int pos = 0; var textLocal = text; foreach (var info in references) { if (info.Span.Length == 0) { continue; } if (pos < info.Span.Start) { output.Write(textLocal, pos, info.Span.Start - pos, BoxedTextColor.Text); } var flags = DecompilerReferenceFlags.Local; if (info.IsDefinition) { flags |= DecompilerReferenceFlags.Definition; } output.Write(textLocal, info.Span.Start, info.Span.Length, info.Reference, flags, BoxedTextColor.Text); pos = info.Span.End; } if (pos < textLocal.Length) { output.Write(textLocal, pos, textLocal.Length - pos, BoxedTextColor.Text); } Debug.Assert(output.Length - outputStart == textLocal.Length); // Don't add a line separator after the last tag int end = lineSeparators.Count - 1; for (int i = 0; i < end; i++) { output.AddLineSeparator(lineSeparators[i]); } foreach (var info in bracesInfo) { output.AddCodeBracesRange(info); } }
public void WriteTo(IDecompilerOutput output) { references.Sort(ReferenceInfoSorter.Instance); int outputStart = output.Length; int pos = 0; foreach (var info in references) { if (info.Span.Length == 0) { continue; } if (pos < info.Span.Start) { output.Write(text, pos, info.Span.Start - pos, BoxedTextColor.Text); } var refText = text.Substring(info.Span.Start, info.Span.Length); var flags = DecompilerReferenceFlags.Local; if (info.IsDefinition) { flags |= DecompilerReferenceFlags.Definition; } output.Write(refText, info.Reference, flags, BoxedTextColor.Text); pos = info.Span.End; } if (pos < text.Length) { output.Write(text, pos, text.Length - pos, BoxedTextColor.Text); } Debug.Assert(output.Length - outputStart == text.Length); foreach (var info in bracesInfo) { output.AddCodeBracesRange(info); } }