Browse Source

Remove the CurrentType from IconMargin.

pull/191/merge
Eusebiu Marcu 16 years ago
parent
commit
50c11083c4
  1. 25
      Debugger/ILSpy.Debugger/AvalonEdit/IconBarMargin.cs
  2. 33
      Debugger/ILSpy.Debugger/DebuggedType.cs
  3. 1
      Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
  4. 4
      ILSpy/TextView/DecompilerTextView.cs
  5. 3
      ILSpy/TreeNodes/TypeTreeNode.cs

25
Debugger/ILSpy.Debugger/AvalonEdit/IconBarMargin.cs

@ -19,13 +19,6 @@ namespace ILSpy.Debugger.AvalonEdit @@ -19,13 +19,6 @@ namespace ILSpy.Debugger.AvalonEdit
{
public class IconBarMargin : AbstractMargin, IDisposable
{
static TypeDefinition currentTypeName;
public static TypeDefinition CurrentType {
get { return currentTypeName; }
set { currentTypeName = value; }
}
public IconBarMargin()
{
BookmarkManager.Added += delegate { InvalidateVisual(); };
@ -64,7 +57,7 @@ namespace ILSpy.Debugger.AvalonEdit @@ -64,7 +57,7 @@ namespace ILSpy.Debugger.AvalonEdit
// create a dictionary line number => first bookmark
Dictionary<int, BookmarkBase> bookmarkDict = new Dictionary<int, BookmarkBase>();
foreach (var bm in BookmarkManager.Bookmarks) {
if (CurrentType == null || bm.TypeName != CurrentType.FullName)
if (DebuggedType.CurrentType == null || bm.TypeName != DebuggedType.CurrentType.FullName)
continue;
if (bm is BreakpointBookmark &&
((BreakpointBookmark)bm).Language != DebuggerService.CurrentDebugger.Language)
@ -126,8 +119,8 @@ namespace ILSpy.Debugger.AvalonEdit @@ -126,8 +119,8 @@ namespace ILSpy.Debugger.AvalonEdit
BookmarkBase result = null;
foreach (BookmarkBase bm in BookmarkManager.Bookmarks) {
if (bm.LineNumber == line &&
CurrentType != null &&
bm.TypeName == CurrentType.FullName) {
DebuggedType.CurrentType != null &&
bm.TypeName == DebuggedType.CurrentType.FullName) {
if (result == null || bm.ZOrder > result.ZOrder)
result = bm;
}
@ -196,11 +189,11 @@ namespace ILSpy.Debugger.AvalonEdit @@ -196,11 +189,11 @@ namespace ILSpy.Debugger.AvalonEdit
InvalidateVisual();
}
if (CurrentType == null)
if (DebuggedType.CurrentType == null)
return;
BreakpointBookmark bm = BookmarkManager.Bookmarks.Find(
b => b.TypeName == CurrentType.FullName &&
b => b.TypeName == DebuggedType.CurrentType.FullName &&
b.LineNumber == GetLineFromMousePosition(e)
&& b is BreakpointBookmark) as BreakpointBookmark;
@ -233,22 +226,22 @@ namespace ILSpy.Debugger.AvalonEdit @@ -233,22 +226,22 @@ namespace ILSpy.Debugger.AvalonEdit
return;
}
if (e.ChangedButton == MouseButton.Left) {
if (CurrentType != null) {
if (DebuggedType.CurrentType != null) {
// check if the codemappings exists for this line
var storage = CodeMappings.GetStorage(DebuggerService.CurrentDebugger.Language);
uint token;
var instruction = storage.GetInstructionByTypeAndLine(CurrentType.FullName, line, out token);
var instruction = storage.GetInstructionByTypeAndLine(DebuggedType.CurrentType.FullName, line, out token);
if (instruction == null || instruction.ILInstructionOffset.From == 0) {
MessageBox.Show(string.Format("Missing code mappings for {0} at line {1}", CurrentType.FullName, line),
MessageBox.Show(string.Format("Missing code mappings for {0} at line {1}", DebuggedType.CurrentType.FullName, line),
"Code mappings", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// no bookmark on the line: create a new breakpoint
DebuggerService.ToggleBreakpointAt(
CurrentType.FullName,
DebuggedType.CurrentType.FullName,
line,
DebuggerService.CurrentDebugger.Language);
}

33
Debugger/ILSpy.Debugger/DebuggedType.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using Mono.Cecil;
namespace ILSpy.Debugger
{
public static class DebuggedType
{
static TypeDefinition currentTypeName;
public static TypeDefinition CurrentType {
get { return currentTypeName; }
set { currentTypeName = value; }
}
}
}

1
Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj

@ -65,6 +65,7 @@ @@ -65,6 +65,7 @@
<Compile Include="Bookmarks\CurrentLineBookmark.cs" />
<Compile Include="Bookmarks\IBookmark.cs" />
<Compile Include="Bookmarks\MarkerBookmark.cs" />
<Compile Include="DebuggedType.cs" />
<Compile Include="Models\TreeModel\ArrayRangeNode.cs" />
<Compile Include="Models\TreeModel\ChildNodesOfObject.cs" />
<Compile Include="Models\TreeModel\ExpressionNode.cs" />

4
ILSpy/TextView/DecompilerTextView.cs

@ -40,10 +40,10 @@ using ICSharpCode.AvalonEdit.Highlighting.Xshd; @@ -40,10 +40,10 @@ using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.NRefactory.Documentation;
using ILSpy.Debugger;
using ILSpy.Debugger.AvalonEdit;
using ILSpy.Debugger.ToolTips;
using Microsoft.Win32;
using TextEditorWeakEventManager = ILSpy.Debugger.AvalonEdit.TextEditorWeakEventManager;
namespace ICSharpCode.ILSpy.TextView
@ -329,7 +329,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -329,7 +329,7 @@ namespace ICSharpCode.ILSpy.TextView
/// </summary>
public void Decompile(ILSpy.Language language, IEnumerable<ILSpyTreeNode> treeNodes, DecompilationOptions options)
{
IconBarMargin.CurrentType = null;
DebuggedType.CurrentType = null;
// Some actions like loading an assembly list cause several selection changes in the tree view,
// and each of those will start a decompilation action.
bool isDecompilationScheduled = this.nextDecompilationRun != null;

3
ILSpy/TreeNodes/TypeTreeNode.cs

@ -22,6 +22,7 @@ using System.Linq; @@ -22,6 +22,7 @@ using System.Linq;
using System.Windows.Media;
using ICSharpCode.Decompiler;
using ILSpy.Debugger;
using ILSpy.Debugger.AvalonEdit;
using Mono.Cecil;
@ -128,7 +129,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -128,7 +129,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
IconBarMargin.CurrentType = type;
DebuggedType.CurrentType = type;
language.DecompileType(type, output, options);
}

Loading…
Cancel
Save