Browse Source

Merge branch 'master' into bookmarks

pull/263/head
Ronny Klier 14 years ago
parent
commit
4b2c25faaa
  1. 14
      Debugger/Debugger.Core/Breakpoint.cs
  2. 2
      Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
  3. 3
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  4. 8
      ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
  5. 4
      ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
  6. 9
      ICSharpCode.Decompiler/ITextOutput.cs
  7. 21
      ICSharpCode.Decompiler/PlainTextOutput.cs
  8. 5
      ILSpy/Bookmarks/MemberBookmark.cs
  9. 2
      ILSpy/Languages/Language.cs
  10. 2
      ILSpy/SearchPane.cs
  11. 23
      ILSpy/TextView/AvalonEditTextOutput.cs
  12. 2
      ILSpy/TextView/DecompilerTextView.cs
  13. 6
      ILSpy/TreeNodes/TypeTreeNode.cs
  14. 4
      NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

14
Debugger/Debugger.Core/Breakpoint.cs

@ -45,11 +45,6 @@ namespace Debugger
set { line = value; } set { line = value; }
} }
public string TypeName {
get;
set;
}
public int Column { public int Column {
get { return column; } get { return column; }
protected set { column = value; } protected set { column = value; }
@ -75,6 +70,10 @@ namespace Debugger
} }
} }
public string TypeName {
get; protected set;
}
protected virtual void OnHit(BreakpointEventArgs e) protected virtual void OnHit(BreakpointEventArgs e)
{ {
if (Hit != null) { if (Hit != null) {
@ -176,12 +175,11 @@ namespace Debugger
public class ILBreakpoint : Breakpoint public class ILBreakpoint : Breakpoint
{ {
public ILBreakpoint(NDebugger debugger, string typeName, string memberReferenceName, int line, int metadataToken, int offset, bool enabled) public ILBreakpoint(NDebugger debugger, string typeName, int line, int metadataToken, int offset, bool enabled)
{ {
this.Debugger = debugger; this.Debugger = debugger;
this.Line = line; this.Line = line;
this.TypeName = typeName; this.TypeName = typeName;
this.MemberReferenceName = memberReferenceName;
this.MetadataToken = metadataToken; this.MetadataToken = metadataToken;
this.ILOffset = offset; this.ILOffset = offset;
this.Enabled = enabled; this.Enabled = enabled;
@ -191,8 +189,6 @@ namespace Debugger
public int ILOffset { get; private set; } public int ILOffset { get; private set; }
public string MemberReferenceName { get; private set; }
public override bool SetBreakpoint(Module module) public override bool SetBreakpoint(Module module)
{ {
SourcecodeSegment segment = SourcecodeSegment.CreateForIL(module, this.Line, (int)MetadataToken, ILOffset); SourcecodeSegment segment = SourcecodeSegment.CreateForIL(module, this.Line, (int)MetadataToken, ILOffset);

2
Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
DebugInformation.LoadedAssemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Select(a => a.AssemblyDefinition);
} }
protected static IDebugger CurrentDebugger { protected static IDebugger CurrentDebugger {

3
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -549,7 +549,6 @@ namespace ICSharpCode.ILSpy.Debugger.Services
breakpoint = new ILBreakpoint( breakpoint = new ILBreakpoint(
debugger, debugger,
bookmark.MemberReference.DeclaringType.FullName, bookmark.MemberReference.DeclaringType.FullName,
bookmark.MemberReference.FullName,
bookmark.LineNumber, bookmark.LineNumber,
bookmark.MemberReference.MetadataToken.ToInt32(), bookmark.MemberReference.MetadataToken.ToInt32(),
bookmark.ILRange.From, bookmark.ILRange.From,
@ -817,6 +816,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services
int ilOffset = frame.IP; int ilOffset = frame.IP;
string fullName = debugType.FullNameWithoutGenericArguments; string fullName = debugType.FullNameWithoutGenericArguments;
DebugInformation.LoadedAssemblies = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().Select(a => a.AssemblyDefinition);
if (DebugInformation.LoadedAssemblies == null) if (DebugInformation.LoadedAssemblies == null)
throw new NullReferenceException("No DebugData assemblies!"); throw new NullReferenceException("No DebugData assemblies!");
else { else {

8
ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs

@ -163,7 +163,7 @@ namespace ICSharpCode.Decompiler.Ast
foreach (var range in ranges) { foreach (var range in ranges) {
mapping.MemberCodeMappings.Add(new SourceCodeMapping { mapping.MemberCodeMappings.Add(new SourceCodeMapping {
ILInstructionOffset = range, ILInstructionOffset = range,
SourceCodeLine = output.CurrentLine, SourceCodeLine = output.Location.Line,
MemberMapping = mapping MemberMapping = mapping
}); });
} }
@ -176,10 +176,10 @@ namespace ICSharpCode.Decompiler.Ast
if (predicate(node)) { if (predicate(node)) {
var n = node as AttributedNode; var n = node as AttributedNode;
int c = 0; int attributesCount = 0;
if (n != null) if (n != null)
c = n.Attributes.Count; attributesCount = n.Attributes.Count;
node.AddAnnotation(Tuple.Create(output.CurrentLine + c, output.CurrentColumn)); node.AddAnnotation(new TextOutputLocation { Line = output.Location.Line + attributesCount, Column = output.Location.Column});
} }
nodeStack.Push(node); nodeStack.Push(node);

4
ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs

@ -91,7 +91,7 @@ namespace ICSharpCode.Decompiler.Disassembler
// add IL code mappings - used in debugger // add IL code mappings - used in debugger
methodMapping.MemberCodeMappings.Add( methodMapping.MemberCodeMappings.Add(
new SourceCodeMapping() { new SourceCodeMapping() {
SourceCodeLine = output.CurrentLine, SourceCodeLine = output.Location.Line,
ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? method.Body.CodeSize : inst.Next.Offset }, ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? method.Body.CodeSize : inst.Next.Offset },
MemberMapping = methodMapping MemberMapping = methodMapping
}); });
@ -194,7 +194,7 @@ namespace ICSharpCode.Decompiler.Disassembler
if (currentMethodMapping != null) { if (currentMethodMapping != null) {
currentMethodMapping.MemberCodeMappings.Add( currentMethodMapping.MemberCodeMappings.Add(
new SourceCodeMapping() { new SourceCodeMapping() {
SourceCodeLine = output.CurrentLine, SourceCodeLine = output.Location.Line,
ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? codeSize : inst.Next.Offset }, ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? codeSize : inst.Next.Offset },
MemberMapping = currentMethodMapping MemberMapping = currentMethodMapping
}); });

9
ICSharpCode.Decompiler/ITextOutput.cs

@ -23,8 +23,7 @@ namespace ICSharpCode.Decompiler
{ {
public interface ITextOutput public interface ITextOutput
{ {
int CurrentLine { get; } TextOutputLocation Location { get; }
int CurrentColumn { get; }
void Indent(); void Indent();
void Unindent(); void Unindent();
@ -38,6 +37,12 @@ namespace ICSharpCode.Decompiler
void MarkFoldEnd(); void MarkFoldEnd();
} }
public sealed class TextOutputLocation
{
public int Line { get; set; }
public int Column { get; set; }
}
public static class TextOutputExtensions public static class TextOutputExtensions
{ {
public static void Write(this ITextOutput output, string format, params object[] args) public static void Write(this ITextOutput output, string format, params object[] args)

21
ICSharpCode.Decompiler/PlainTextOutput.cs

@ -28,8 +28,7 @@ namespace ICSharpCode.Decompiler
readonly TextWriter writer; readonly TextWriter writer;
int indent; int indent;
bool needsIndent; bool needsIndent;
int lineNumber = 1; TextOutputLocation location = new TextOutputLocation { Line = 1, Column = 1};
int columnNumber = 1;
public PlainTextOutput(TextWriter writer) public PlainTextOutput(TextWriter writer)
{ {
@ -43,12 +42,8 @@ namespace ICSharpCode.Decompiler
this.writer = new StringWriter(); this.writer = new StringWriter();
} }
public int CurrentLine { public TextOutputLocation Location {
get { return lineNumber; } get { return location; }
}
public int CurrentColumn {
get { return columnNumber; }
} }
public override string ToString() public override string ToString()
@ -72,7 +67,7 @@ namespace ICSharpCode.Decompiler
needsIndent = false; needsIndent = false;
for (int i = 0; i < indent; i++) { for (int i = 0; i < indent; i++) {
writer.Write('\t'); writer.Write('\t');
columnNumber += TAB_SIZE - 1; location.Column += TAB_SIZE - 1;
} }
} }
} }
@ -81,22 +76,22 @@ namespace ICSharpCode.Decompiler
{ {
WriteIndent(); WriteIndent();
writer.Write(ch); writer.Write(ch);
columnNumber++; location.Column++;
} }
public void Write(string text) public void Write(string text)
{ {
WriteIndent(); WriteIndent();
writer.Write(text); writer.Write(text);
columnNumber += text.Length; location.Column += text.Length;
} }
public void WriteLine() public void WriteLine()
{ {
lineNumber++; location.Line++;
writer.WriteLine(); writer.WriteLine();
needsIndent = true; needsIndent = true;
columnNumber = TAB_SIZE * indent; location.Column = TAB_SIZE * indent;
} }
public void WriteDefinition(string text, object definition) public void WriteDefinition(string text, object definition)

5
ILSpy/Bookmarks/MemberBookmark.cs

@ -21,6 +21,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Decompiler;
using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using Mono.Cecil; using Mono.Cecil;
@ -91,9 +92,9 @@ namespace ICSharpCode.ILSpy.Bookmarks
public int LineNumber { public int LineNumber {
get { get {
var t = node.Annotation<Tuple<int, int>>(); var t = node.Annotation<TextOutputLocation>();
if (t != null) if (t != null)
return t.Item1; return t.Line;
return 0; return 0;
} }
} }

2
ILSpy/Languages/Language.cs

@ -207,7 +207,7 @@ namespace ICSharpCode.ILSpy
var nodes = TreeTraversal var nodes = TreeTraversal
.PreOrder((AstNode)builder.CompilationUnit, n => n.Children) .PreOrder((AstNode)builder.CompilationUnit, n => n.Children)
.Where(n => n is AttributedNode && n.Annotation<Tuple<int, int>>() != null); .Where(n => n is AttributedNode && n.Annotation<TextOutputLocation>() != null);
OnDecompilationFinished(new DecompileEventArgs { OnDecompilationFinished(new DecompileEventArgs {
CodeMappings = builder.CodeMappings, CodeMappings = builder.CodeMappings,

2
ILSpy/SearchPane.cs

@ -398,7 +398,7 @@ namespace ICSharpCode.ILSpy
case TypeCode.Int64: case TypeCode.Int64:
TypeCode tc = Type.GetTypeCode(val.GetType()); TypeCode tc = Type.GetTypeCode(val.GetType());
if (tc >= TypeCode.SByte && tc <= TypeCode.UInt64) if (tc >= TypeCode.SByte && tc <= TypeCode.UInt64)
return Convert.ToInt64(val) == (long)searchTermLiteralValue; return CSharpPrimitiveCast.Cast(TypeCode.Int64, val, false).Equals(searchTermLiteralValue);
else else
return false; return false;
case TypeCode.Single: case TypeCode.Single:

23
ILSpy/TextView/AvalonEditTextOutput.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.TextView
/// </summary> /// </summary>
public sealed class AvalonEditTextOutput : ISmartTextOutput public sealed class AvalonEditTextOutput : ISmartTextOutput
{ {
int lineNumber = 1; TextOutputLocation location = new TextOutputLocation { Line = 1, Column = 1 };
int lastLineStart = 0; int lastLineStart = 0;
readonly StringBuilder b = new StringBuilder(); readonly StringBuilder b = new StringBuilder();
@ -117,6 +117,13 @@ namespace ICSharpCode.ILSpy.TextView
get { return b.Length; } get { return b.Length; }
} }
public TextOutputLocation Location {
get {
location.Column = b.Length - lastLineStart + 1;
return location;
}
}
#region Text Document #region Text Document
TextDocument textDocument; TextDocument textDocument;
@ -188,7 +195,7 @@ namespace ICSharpCode.ILSpy.TextView
b.AppendLine(); b.AppendLine();
needsIndent = true; needsIndent = true;
lastLineStart = b.Length; lastLineStart = b.Length;
lineNumber++; location.Line++;
if (this.TextLength > LengthLimit) { if (this.TextLength > LengthLimit) {
throw new OutputLengthExceededException(); throw new OutputLengthExceededException();
} }
@ -236,17 +243,5 @@ namespace ICSharpCode.ILSpy.TextView
this.UIElements.Add(new KeyValuePair<int, Lazy<UIElement>>(this.TextLength, new Lazy<UIElement>(element))); this.UIElements.Add(new KeyValuePair<int, Lazy<UIElement>>(this.TextLength, new Lazy<UIElement>(element)));
} }
} }
public int CurrentLine {
get {
return lineNumber;
}
}
public int CurrentColumn {
get {
return b.Length - lastLineStart + 1;
}
}
} }
} }

2
ILSpy/TextView/DecompilerTextView.cs

@ -456,7 +456,7 @@ namespace ICSharpCode.ILSpy.TextView
int ilOffset = DebugInformation.DebugStepInformation.Item2; int ilOffset = DebugInformation.DebugStepInformation.Item2;
int line; int line;
MemberReference member; MemberReference member;
if (!DebugInformation.CodeMappings.ContainsKey(token)) if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token))
return; return;
DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out member, out line); DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out member, out line);

6
ILSpy/TreeNodes/TypeTreeNode.cs

@ -81,10 +81,10 @@ namespace ICSharpCode.ILSpy.TreeNodes
if (!settings.ShowInternalApi && !IsPublicAPI) if (!settings.ShowInternalApi && !IsPublicAPI)
return FilterResult.Hidden; return FilterResult.Hidden;
if (settings.SearchTermMatches(type.Name)) { if (settings.SearchTermMatches(type.Name)) {
if (type.IsNested && !settings.Language.ShowMember(type)) if (settings.Language.ShowMember(type))
return FilterResult.Hidden;
else
return FilterResult.Match; return FilterResult.Match;
else
return FilterResult.Hidden;
} else { } else {
return FilterResult.Recurse; return FilterResult.Recurse;
} }

4
NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

@ -2145,8 +2145,10 @@ namespace ICSharpCode.NRefactory.VB
WriteKeyword("Case"); WriteKeyword("Case");
if (caseStatement.Clauses.Count == 1 && caseStatement.Clauses.First().Expression.IsNull) if (caseStatement.Clauses.Count == 1 && caseStatement.Clauses.First().Expression.IsNull)
WriteKeyword("Else"); WriteKeyword("Else");
else else {
Space();
WriteCommaSeparatedList(caseStatement.Clauses); WriteCommaSeparatedList(caseStatement.Clauses);
}
NewLine(); NewLine();
Indent(); Indent();
caseStatement.Body.AcceptVisitor(this, data); caseStatement.Body.AcceptVisitor(this, data);

Loading…
Cancel
Save