Browse Source

Unified DebuggerException and DebugeeInnerException with interface IDebugeeException.

Re-added Debugger.Exception.InnerException.
Began adding TreeViewExceptionNode.cs
Documented code.
Renamed TreeViewNode to TreeViewVarNode.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3052 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Justin Dearing 17 years ago
parent
commit
a65f6d1fb1
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 26
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 50
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewExceptionNode.cs
  4. 48
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs
  5. 46
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExceptionNode.cs
  6. 22
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
  7. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  8. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs
  9. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/IDebugeeException.cs
  10. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -73,9 +73,11 @@ @@ -73,9 +73,11 @@
<Compile Include="Src\Pads\RunningThreadsPad.Menu.cs" />
<Compile Include="Src\TreeModel\AbstractNode.cs" />
<Compile Include="Src\TreeModel\Adapters\DynamicTreeDebuggerRow.cs" />
<Compile Include="Src\TreeModel\Adapters\TreeViewExceptionNode.cs" />
<Compile Include="Src\TreeModel\Adapters\TreeViewNode.cs" />
<Compile Include="Src\TreeModel\ArrayRangeNode.cs" />
<Compile Include="Src\TreeModel\ErrorNode.cs" />
<Compile Include="Src\TreeModel\ExceptionNode.cs" />
<Compile Include="Src\TreeModel\Extensions\IList.cs" />
<Compile Include="Src\TreeModel\ValueNode.cs" />
<Compile Include="Src\TreeModel\IContextMenu.cs" />

26
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -57,7 +57,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
class ItemIcon: NodeIcon {
protected override System.Drawing.Image GetIcon(TreeNodeAdv node)
{
return ((TreeViewNode)node).Content.Image;
return ((TreeViewVarNode)node).Content.Image;
}
}
@ -68,8 +68,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -68,8 +68,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
public override object GetValue(TreeNodeAdv node)
{
if (node is TreeViewNode) {
return ((TreeViewNode)node).Content.Name;
if (node is TreeViewVarNode) {
return ((TreeViewVarNode)node).Content.Name;
} else {
// Happens during incremental search
return base.GetValue(node);
@ -85,13 +85,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -85,13 +85,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
protected override bool CanEdit(TreeNodeAdv node)
{
AbstractNode content = ((TreeViewNode)node).Content;
AbstractNode content = ((TreeViewVarNode)node).Content;
return (content is ISetText) && ((ISetText)content).CanSetText;
}
public override object GetValue(TreeNodeAdv node)
{
if (node is TreeViewNode) {
return ((TreeViewNode)node).Content.Text;
if (node is TreeViewVarNode) {
return ((TreeViewVarNode)node).Content.Text;
} else {
// Happens during incremental search
return base.GetValue(node);
@ -99,24 +99,24 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -99,24 +99,24 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
public override void SetValue(TreeNodeAdv node, object value)
{
ISetText content = (ISetText)((TreeViewNode)node).Content;
ISetText content = (ISetText)((TreeViewVarNode)node).Content;
if (content.CanSetText) {
content.SetText(value.ToString());
}
}
protected override void OnDrawText(DrawEventArgs args)
{
AbstractNode content = ((TreeViewNode)args.Node).Content;
AbstractNode content = ((TreeViewVarNode)args.Node).Content;
if (content is ErrorNode) {
args.TextColor = Color.Red;
} else if (((TreeViewNode)args.Node).TextChanged) {
} else if (((TreeViewVarNode)args.Node).TextChanged) {
args.TextColor = Color.Blue;
}
base.OnDrawText(args);
}
public override void MouseDown(TreeNodeAdvMouseEventArgs args)
{
AbstractNode content = ((TreeViewNode)args.Node).Content;
AbstractNode content = ((TreeViewVarNode)args.Node).Content;
if (content is IContextMenu && args.Button == MouseButtons.Right) {
ContextMenuStrip menu = ((IContextMenu)content).GetContextMenu();
if (menu != null) {
@ -135,8 +135,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -135,8 +135,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
public override object GetValue(TreeNodeAdv node)
{
if (node is TreeViewNode) {
return ((TreeViewNode)node).Content.Type;
if (node is TreeViewVarNode) {
return ((TreeViewVarNode)node).Content.Type;
} else {
// Happens during incremental search
return base.GetValue(node);
@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
try {
localVarList.BeginUpdate();
Utils.DoEvents(debuggedProcess.DebuggeeState);
TreeViewNode.SetContentRecursive(debuggedProcess, LocalVarList, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes);
TreeViewVarNode.SetContentRecursive(debuggedProcess, LocalVarList, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes);
} catch(AbortedBecauseDebuggeeResumedException) {
} finally {
localVarList.EndUpdate();

50
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewExceptionNode.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright license="BSD-new" see="prj:///COPYING"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision: 3047 $</version>
// </file>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Windows.Forms;
using Aga.Controls.Tree;
using Debugger.Util;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.Pads;
namespace Debugger.AddIn.TreeModel
{
// This TreeNodeAdv displays exception data.
public class TreeViewExceptionNode: TreeNodeAdv
{
private static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
private TreeViewAdv localVarList;
/// <summary>
/// The content of the exception
/// </summary>
private AbstractNode content;
// TODO: I don't know if I need localVarList
private TreeViewExceptionNode(TreeViewAdv localVarList, ExceptionNode exception): base(localVarList, new object()) {
this.localVarList = localVarList;
SetContentRecursive(exception);
}
/// <summary>
/// A simple form of SetContentRecursive that changes the current ChildViewNode to
/// display the exception parameter passed to it. If the node had any children and is expanded,
/// it will recureively set those as well.
/// </summary>
/// <param name="exception">Contains the exception that will be stored in this particular TreeViewNode.</param>
public static void SetContentRecursive(ExceptionNode exception) {
throw new NotImplementedException();
}
}
}

48
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs

@ -19,7 +19,7 @@ using ICSharpCode.SharpDevelop.Gui.Pads; @@ -19,7 +19,7 @@ using ICSharpCode.SharpDevelop.Gui.Pads;
namespace Debugger.AddIn.TreeModel
{
public partial class TreeViewNode: TreeNodeAdv
public partial class TreeViewVarNode: TreeNodeAdv
{
static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
@ -40,36 +40,29 @@ namespace Debugger.AddIn.TreeModel @@ -40,36 +40,29 @@ namespace Debugger.AddIn.TreeModel
string FullName {
get {
if (this.Parent != null && this.Parent is TreeViewNode) {
return ((TreeViewNode)this.Parent).FullName + "." + Content.Name;
if (this.Parent != null && this.Parent is TreeViewVarNode) {
return ((TreeViewVarNode)this.Parent).FullName + "." + Content.Name;
} else {
return Content.Name;
}
}
}
public TreeViewNode(Debugger.Process process, TreeViewAdv localVarList, AbstractNode content): base(localVarList, new object())
private TreeViewVarNode(Debugger.Process process, TreeViewAdv localVarList, AbstractNode content): base(localVarList, new object())
{
this.process = process;
this.localVarList = localVarList;
SetContentRecursive(content);
}
//TODO: Eliminate the need to associate with a LocalVarPad
public TreeViewNode(LocalVarPad localVarPad, AbstractNode content): base(localVarPad.LocalVarList, new object())
{
this.process = localVarPad.Process;
this.localVarList = localVarPad.LocalVarList;
SetContentRecursive(content);
}
static TimeSpan workTime = TimeSpan.FromMilliseconds(40);
static DateTime nextRepaintTime = DateTime.MinValue;
#region SetContentRecursive
/// <summary>
/// A simple form of SetContentRecursive that changes the current ChildViewNode to
/// display the data proviced by <c>content</c>. If the node had any children and is expanded,
/// display the data provided by <c>content</c>. If the node had any children and is expanded,
/// it will recureively set those as well.
/// </summary>
/// <param name="content">Contains the name value and type of the variable stored in this particular TreeViewNode.</param>
@ -106,18 +99,6 @@ namespace Debugger.AddIn.TreeModel @@ -106,18 +99,6 @@ namespace Debugger.AddIn.TreeModel
}
}
/// <summary>
/// Function for setting the root treenode of a TreeViewAdv ment to display debugger variables.
/// </summary>
/// <param name="process">The process that contains the stackframe with the given variables.</param>
/// <param name="localVarList">A list of local variables.</param>
/// <param name="contentEnum">A list of local variables.</param>
public static void SetContentRecursive(Debugger.Process process, TreeViewAdv localVarList, IEnumerable<AbstractNode> contentEnum) {
IList<TreeNodeAdv> childNodes = localVarList.Root.Children;
SetContentRecursive(process, localVarList, childNodes, contentEnum);
}
/// <summary>
/// Private form of SetContentRecursive. This form contains an extra parameter used by LoadChildren.
/// This adds the childNodes parameter, which can be set to the children of a particular child element.
@ -135,10 +116,10 @@ namespace Debugger.AddIn.TreeModel @@ -135,10 +116,10 @@ namespace Debugger.AddIn.TreeModel
// Add or overwrite existing items
if (index < childNodes.Count) {
// Overwrite
((TreeViewNode)childNodes[index]).SetContentRecursive(content);
((TreeViewVarNode)childNodes[index]).SetContentRecursive(content);
} else {
// Add
childNodes.Add(new TreeViewNode(process, localVarList, content));
childNodes.Add(new TreeViewVarNode(process, localVarList, content));
}
index++;
}
@ -149,6 +130,19 @@ namespace Debugger.AddIn.TreeModel @@ -149,6 +130,19 @@ namespace Debugger.AddIn.TreeModel
}
}
/// <summary>
/// Function for setting the root treenode of a TreeViewAdv ment to display debugger variables.
/// </summary>
/// <param name="process">The process that contains the stackframe with the given variables.</param>
/// <param name="localVarList">A list of local variables.</param>
/// <param name="contentEnum">A list of local variables.</param>
public static void SetContentRecursive(Debugger.Process process, TreeViewAdv localVarList, IEnumerable<AbstractNode> contentEnum) {
IList<TreeNodeAdv> childNodes = localVarList.Root.Children;
SetContentRecursive(process, localVarList, childNodes, contentEnum);
}
#endregion SetContentRecursive
protected override void OnExpanding()
{
base.OnExpanding();

46
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExceptionNode.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// <file>
// <copyright license="BSD-new" see="prj:///COPYING"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision: 2813 $</version>
// </file>
using System;
namespace Debugger.AddIn.TreeModel
{
/// <summary>
/// Represents a row in a TreeViewAdv that contains an IDebugeeException
/// </summary>
public class ExceptionNode : AbstractNode
{
private IDebugeeException exception;
private ExceptionNode innerException = null;
public static ExceptionNode Create(Debugger.Exception exception) {
try {
return new ExceptionNode(exception);
} catch (GetValueException e) {
// TODO: Fix this
throw;
//return new ErrorNode(expression, e);
}
}
private ExceptionNode(IDebugeeException exception){
this.exception = exception;
this.Image = DebuggerIcons.ImageList.Images[0]; // Class
this.Name = "Unhandled Exception";
this.Type = exception.Type;
this.Text = exception.Message;
if (exception.InnerException != null) {
innerException = new ExceptionNode(exception.InnerException);
}
}
ExceptionNode InnerException {
get { return innerException; }
}
}
}

22
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs

@ -19,6 +19,9 @@ using Debugger.Expressions; @@ -19,6 +19,9 @@ using Debugger.Expressions;
namespace Debugger.AddIn.TreeModel
{
/// <summary>
/// Represents the data in a row in a TreeViewNode.
/// </summary>
public class ValueNode: AbstractNode, ISetText, IContextMenu
{
Expression expression;
@ -28,6 +31,15 @@ namespace Debugger.AddIn.TreeModel @@ -28,6 +31,15 @@ namespace Debugger.AddIn.TreeModel
get { return expression; }
}
/// <summary>
/// Factory method to create an instance.
/// </summary>
/// <param name="expression">The expression containing the value you wish to display.</param>
/// <returns>
/// Returns a ValueNode if it can successfully evaluate expression or
/// ErrorNode if it fails to do so.
/// </returns>
/// <see cref=ErrorNode""/>
public static AbstractNode Create(Expression expression)
{
try {
@ -38,8 +50,14 @@ namespace Debugger.AddIn.TreeModel @@ -38,8 +50,14 @@ namespace Debugger.AddIn.TreeModel
}
}
// NB: This can also throw GetValueException on InvokeToString()
ValueNode(Value val)
/// <summary>
/// Private constructor used by the factory method Create()
/// </summary>
/// <param name="val"></param>
/// <exception cref="System.Management.Automation.GetValueException">
/// Can be thrown by InvokeToString()
/// </exception>
private ValueNode(Value val)
{
this.expression = val.Expression;

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
<Compile Include="Src\Debugger\DebuggerObject.cs" />
<Compile Include="Src\Debugger\Exception.cs" />
<Compile Include="Src\Debugger\ExceptionType.cs" />
<Compile Include="Src\Debugger\IDebugeeException.cs" />
<Compile Include="Src\Debugger\IExpirable.cs" />
<Compile Include="Src\Debugger\InnerException.cs" />
<Compile Include="Src\Debugger\PausedReason.cs" />

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs

@ -20,7 +20,7 @@ namespace Debugger @@ -20,7 +20,7 @@ namespace Debugger
/// neccessary.
/// </summary>
/// <seealso cref="System.Exception" />
public class Exception: DebuggerObject
public class Exception: DebuggerObject, IDebugeeException
{
Thread thread;
ExceptionType exceptionType;
@ -61,6 +61,18 @@ namespace Debugger @@ -61,6 +61,18 @@ namespace Debugger
}
}
/// <summary>
/// The <c>InnerException</c> property of the exception.
/// </summary>
/// <seealso cref="System.Exception" />
public DebugeeInnerException InnerException {
get {
Debugger.Value exVal = this.RuntimeValue.GetMemberValue("_innerException");
return (exVal.IsNull) ? null : new DebugeeInnerException(exVal);
}
}
/// <summary>
/// The <c>Message</c> property of the exception.
/// </summary>

21
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/IDebugeeException.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision: 3047 $</version>
// </file>
using System;
namespace Debugger
{
/// <summary>
/// Interface shared by Debugger.Exception and Debugger.DebugeeInnerException.
/// </summary>
public interface IDebugeeException
{
DebugeeInnerException InnerException { get; }
string Message { get; }
string Type { get; }
}
}

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/InnerException.cs

@ -15,11 +15,11 @@ namespace Debugger @@ -15,11 +15,11 @@ namespace Debugger
/// </summary>
/// <see cref="Debugger.Exception" />
/// <seealso cref="System.Exception" />
public class DebuggerInnerException
public class DebugeeInnerException : IDebugeeException
{
Debugger.Value exceptionValue;
internal DebuggerInnerException (Debugger.Value exception) {
internal DebugeeInnerException (Debugger.Value exception) {
this.exceptionValue = exception;
}
@ -27,10 +27,10 @@ namespace Debugger @@ -27,10 +27,10 @@ namespace Debugger
/// The <c>InnerException</c> property of the exception.
/// </summary>
/// <seealso cref="System.Exception" />
public DebuggerInnerException InnerException {
public DebugeeInnerException InnerException {
get {
Debugger.Value exVal = this.exceptionValue.GetMemberValue("_innerException");
return (exVal.IsNull) ? null : new DebuggerInnerException(exVal);
return (exVal.IsNull) ? null : new DebugeeInnerException(exVal);
}
}

Loading…
Cancel
Save