|
|
|
@ -6,80 +6,51 @@ using System.Collections.Generic;
@@ -6,80 +6,51 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq; |
|
|
|
|
using ICSharpCode.Core; |
|
|
|
|
using ICSharpCode.Decompiler; |
|
|
|
|
using ICSharpCode.NRefactory.CSharp; |
|
|
|
|
using Mono.Cecil; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.ILSpyAddIn |
|
|
|
|
{ |
|
|
|
|
public sealed class DebuggerTextOutput : ITextOutput |
|
|
|
|
public sealed class DebugInfoTokenWriterDecorator : DecoratingTokenWriter, ILocatable |
|
|
|
|
{ |
|
|
|
|
readonly ITextOutput output; |
|
|
|
|
readonly Stack<MethodDebugSymbols> symbolsStack = new Stack<MethodDebugSymbols>(); |
|
|
|
|
readonly ILocatable locationProvider; |
|
|
|
|
|
|
|
|
|
public readonly Dictionary<string, MethodDebugSymbols> DebugSymbols = new Dictionary<string, MethodDebugSymbols>(); |
|
|
|
|
public readonly Dictionary<string, ICSharpCode.NRefactory.TextLocation> MemberLocations = new Dictionary<string, ICSharpCode.NRefactory.TextLocation>(); |
|
|
|
|
|
|
|
|
|
public DebuggerTextOutput(ITextOutput output) |
|
|
|
|
public DebugInfoTokenWriterDecorator(TokenWriter writer, ILocatable locationProvider) |
|
|
|
|
: base(writer) |
|
|
|
|
{ |
|
|
|
|
this.output = output; |
|
|
|
|
if (locationProvider == null) |
|
|
|
|
throw new ArgumentNullException("locationProvider"); |
|
|
|
|
this.locationProvider = locationProvider; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ICSharpCode.NRefactory.TextLocation Location { |
|
|
|
|
get { return output.Location; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Indent() |
|
|
|
|
{ |
|
|
|
|
output.Indent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Unindent() |
|
|
|
|
{ |
|
|
|
|
output.Unindent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Write(char ch) |
|
|
|
|
{ |
|
|
|
|
output.Write(ch); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Write(string text) |
|
|
|
|
public override void StartNode(AstNode node) |
|
|
|
|
{ |
|
|
|
|
output.Write(text); |
|
|
|
|
base.StartNode(node); |
|
|
|
|
if (node.Annotation<MethodDebugSymbols>() != null) { |
|
|
|
|
symbolsStack.Push(node.Annotation<MethodDebugSymbols>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void WriteLine() |
|
|
|
|
{ |
|
|
|
|
output.WriteLine(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void WriteDefinition(string text, object definition, bool isLocal) |
|
|
|
|
{ |
|
|
|
|
if (definition is MemberReference) { |
|
|
|
|
MemberLocations[XmlDocKeyProvider.GetKey((MemberReference)definition)] = Location; |
|
|
|
|
} |
|
|
|
|
output.WriteDefinition(text, definition, isLocal); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void WriteReference(string text, object reference, bool isLocal) |
|
|
|
|
public override void EndNode(AstNode node) |
|
|
|
|
{ |
|
|
|
|
output.WriteReference(text, reference, isLocal); |
|
|
|
|
base.EndNode(node); |
|
|
|
|
if (node is EntityDeclaration && node.Annotation<MemberReference>() != null) { |
|
|
|
|
MemberLocations[XmlDocKeyProvider.GetKey(node.Annotation<MemberReference>())] = node.StartLocation; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void AddDebugSymbols(MethodDebugSymbols methodDebugSymbols) |
|
|
|
|
{ |
|
|
|
|
var id = XmlDocKeyProvider.GetKey(methodDebugSymbols.CecilMethod); |
|
|
|
|
methodDebugSymbols.SequencePoints = methodDebugSymbols.SequencePoints.OrderBy(s => s.ILOffset).ToList(); |
|
|
|
|
this.DebugSymbols.Add(id, methodDebugSymbols); |
|
|
|
|
output.AddDebugSymbols(methodDebugSymbols); |
|
|
|
|
if (node.Annotation<MethodDebugSymbols>() != null) { |
|
|
|
|
var symbols = symbolsStack.Pop(); |
|
|
|
|
symbols.SequencePoints = symbols.SequencePoints.OrderBy(s => s.ILOffset).ToList(); |
|
|
|
|
symbols.StartLocation = node.StartLocation; |
|
|
|
|
DebugSymbols[XmlDocKeyProvider.GetKey(symbols.CecilMethod)] = symbols; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void MarkFoldStart(string collapsedText, bool defaultCollapsed) |
|
|
|
|
{ |
|
|
|
|
output.MarkFoldStart(collapsedText, defaultCollapsed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void MarkFoldEnd() |
|
|
|
|
{ |
|
|
|
|
output.MarkFoldEnd(); |
|
|
|
|
public ICSharpCode.NRefactory.TextLocation Location { |
|
|
|
|
get { return locationProvider.Location; } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|