Browse Source

create a new TextOutputLocation class for storing the location in the output text instead of Tuple<int, int> + fix build

pull/258/head
Eusebiu Marcu 14 years ago
parent
commit
5a892c30df
  1. 5
      ILSpy/Bookmarks/MemberBookmark.cs
  2. 2
      ILSpy/Languages/Language.cs
  3. 23
      ILSpy/TextView/AvalonEditTextOutput.cs

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,

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;
}
}
} }
} }

Loading…
Cancel
Save