Browse Source

Refactored much of TreeViewNode. There is now a more sensible publicly accessible SetContentRecursive member and tow private static methods for dealing with internal cases.

Added some documentation to TreeViewNode.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3047 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Justin Dearing 17 years ago
parent
commit
53306817a1
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 71
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs
  4. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Exception.cs

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

@ -57,7 +57,7 @@
</Compile> </Compile>
<Compile Include="Src\Service\ExceptionForm.Designer.cs"> <Compile Include="Src\Service\ExceptionForm.Designer.cs">
<DependentUpon>ExceptionForm.cs</DependentUpon> <DependentUpon>ExceptionForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Src\Service\RemotingConfigurationHelpper.cs" /> <Compile Include="Src\Service\RemotingConfigurationHelpper.cs" />
<Compile Include="Src\Service\WindowsDebugger.cs" /> <Compile Include="Src\Service\WindowsDebugger.cs" />
<EmbeddedResource Include="Src\Service\ExceptionForm.resx"> <EmbeddedResource Include="Src\Service\ExceptionForm.resx">
@ -151,4 +151,4 @@
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<Import Project="PostBuildEvent.proj" /> <Import Project="PostBuildEvent.proj" />
</Project> </Project>

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

@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
try { try {
localVarList.BeginUpdate(); localVarList.BeginUpdate();
Utils.DoEvents(debuggedProcess.DebuggeeState); Utils.DoEvents(debuggedProcess.DebuggeeState);
TreeViewNode.SetContentRecursive(this, localVarList.Root.Children, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes); TreeViewNode.SetContentRecursive(debuggedProcess, LocalVarList, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes);
} catch(AbortedBecauseDebuggeeResumedException) { } catch(AbortedBecauseDebuggeeResumedException) {
} finally { } finally {
localVarList.EndUpdate(); localVarList.EndUpdate();

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

@ -23,7 +23,8 @@ namespace Debugger.AddIn.TreeModel
{ {
static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>(); static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
LocalVarPad localVarPad; TreeViewAdv localVarList;
Debugger.Process process;
AbstractNode content; AbstractNode content;
bool childsLoaded; bool childsLoaded;
@ -47,16 +48,32 @@ namespace Debugger.AddIn.TreeModel
} }
} }
public TreeViewNode(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()) public TreeViewNode(LocalVarPad localVarPad, AbstractNode content): base(localVarPad.LocalVarList, new object())
{ {
this.localVarPad = localVarPad; this.process = localVarPad.Process;
this.localVarList = localVarPad.LocalVarList;
SetContentRecursive(content); SetContentRecursive(content);
} }
static TimeSpan workTime = TimeSpan.FromMilliseconds(40); static TimeSpan workTime = TimeSpan.FromMilliseconds(40);
static DateTime nextRepaintTime = DateTime.MinValue; static DateTime nextRepaintTime = DateTime.MinValue;
public void SetContentRecursive(AbstractNode content)
/// <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,
/// 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>
private void SetContentRecursive(AbstractNode content)
{ {
this.textChanged = this.textChanged =
this.content != null && this.content != null &&
@ -65,22 +82,22 @@ namespace Debugger.AddIn.TreeModel
this.content = content; this.content = content;
this.IsLeaf = (content.ChildNodes == null); this.IsLeaf = (content.ChildNodes == null);
childsLoaded = false; childsLoaded = false;
this.IsExpandedOnce = false; this.IsExpandedOnce = false;
if (!IsLeaf && expandedNodes.ContainsKey(this.FullName) && expandedNodes[this.FullName]) { if (!IsLeaf && expandedNodes.ContainsKey(this.FullName) && expandedNodes[this.FullName]) {
LoadChilds(); LoadChildren();
this.Expand(); this.Expand();
} else { } else {
this.Children.Clear(); this.Children.Clear();
this.Collapse(); this.Collapse();
} }
// Process user commands // Process user commands
Utils.DoEvents(localVarPad.Process.DebuggeeState); Utils.DoEvents(process.DebuggeeState);
// Repaint // Repaint
if (HighPrecisionTimer.Now > nextRepaintTime) { if (HighPrecisionTimer.Now > nextRepaintTime) {
using(new PrintTime("Repainting Local Variables Pad")) { using(new PrintTime("Repainting Local Variables Pad")) {
try { try {
this.Tree.EndUpdate(); // Enable painting this.Tree.EndUpdate(); // Enable painting
Utils.DoEvents(localVarPad.Process.DebuggeeState); // Paint Utils.DoEvents(process.DebuggeeState); // Paint
} finally { } finally {
this.Tree.BeginUpdate(); // Disable painting this.Tree.BeginUpdate(); // Disable painting
nextRepaintTime = HighPrecisionTimer.Now + workTime; nextRepaintTime = HighPrecisionTimer.Now + workTime;
@ -89,7 +106,27 @@ namespace Debugger.AddIn.TreeModel
} }
} }
public static void SetContentRecursive(LocalVarPad localVarPad, IList<TreeNodeAdv> childNodes, IEnumerable<AbstractNode> contentEnum) /// <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.
/// </summary>
/// <param name="process"></param>
/// <param name="localVarList"></param>
/// <param name="childNodes"></param>
/// <param name="contentEnum"></param>
private static void SetContentRecursive(Debugger.Process process, TreeViewAdv localVarList, IList<TreeNodeAdv> childNodes, IEnumerable<AbstractNode> contentEnum)
{ {
contentEnum = contentEnum ?? new AbstractNode[0]; contentEnum = contentEnum ?? new AbstractNode[0];
@ -101,7 +138,7 @@ namespace Debugger.AddIn.TreeModel
((TreeViewNode)childNodes[index]).SetContentRecursive(content); ((TreeViewNode)childNodes[index]).SetContentRecursive(content);
} else { } else {
// Add // Add
childNodes.Add(new TreeViewNode(localVarPad, content)); childNodes.Add(new TreeViewNode(process, localVarList, content));
} }
index++; index++;
} }
@ -117,20 +154,28 @@ namespace Debugger.AddIn.TreeModel
base.OnExpanding(); base.OnExpanding();
} }
void LoadChilds()
/// <summary>
/// This displays all the immediate children of a TreeViewNode in its containing TreeViewAdv.
/// </summary>
void LoadChildren()
{ {
if (!childsLoaded) { if (!childsLoaded) {
childsLoaded = true; childsLoaded = true;
this.IsExpandedOnce = true; this.IsExpandedOnce = true;
SetContentRecursive(localVarPad, this.Children, this.Content.ChildNodes); SetContentRecursive(process, this.localVarList, this.Children, this.Content.ChildNodes);
} }
} }
/// <summary>
/// Expands the current treenode and displays all its immediate children.
/// </summary>
protected override void OnExpanded() protected override void OnExpanded()
{ {
base.OnExpanded(); base.OnExpanded();
expandedNodes[FullName] = true; expandedNodes[FullName] = true;
if (localVarPad.Process.IsRunning) { if (process.IsRunning) {
MessageService.ShowMessage( MessageService.ShowMessage(
"${res:MainWindow.Windows.Debug.LocalVariables.CannotExploreVariablesWhileRunning}", "${res:MainWindow.Windows.Debug.LocalVariables.CannotExploreVariablesWhileRunning}",
"${res:MainWindow.Windows.Debug.LocalVariables}" "${res:MainWindow.Windows.Debug.LocalVariables}"
@ -139,7 +184,7 @@ namespace Debugger.AddIn.TreeModel
} }
try { try {
this.Tree.BeginUpdate(); this.Tree.BeginUpdate();
LoadChilds(); LoadChildren();
} catch (AbortedBecauseDebuggeeResumedException) { } catch (AbortedBecauseDebuggeeResumedException) {
} finally { } finally {
this.Tree.EndUpdate(); this.Tree.EndUpdate();

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

@ -61,17 +61,6 @@ namespace Debugger
} }
} }
/// <summary>
/// The <c>InnerException</c> property of the exception.
/// </summary>
/// <seealso cref="System.Exception" />
public DebuggerInnerException InnerException {
get {
Debugger.Value exVal = this.RuntimeValue.GetMemberValue("_innerException");
return (exVal.IsNull) ? null : new DebuggerInnerException(exVal);
}
}
/// <summary> /// <summary>
/// The <c>Message</c> property of the exception. /// The <c>Message</c> property of the exception.
/// </summary> /// </summary>
@ -104,6 +93,11 @@ namespace Debugger
} }
} }
/// <summary>
/// This is the call stack as represented by the <c>Debugger.ThreadObject</c>.
/// </summary>
/// <seealso cref="System.Execption.StackTrace" />
/// <see cref="Debugger.Exception.StackTrace" />
public string Callstack { public string Callstack {
get { get {
StringBuilder callstack = new StringBuilder(); StringBuilder callstack = new StringBuilder();

Loading…
Cancel
Save