Browse Source

Variables in Local Variables pad are expandable again.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@755 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
b11865c0d2
  1. 25
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  2. 54
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs
  3. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  4. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  5. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

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

@ -90,28 +90,29 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
debuggerCore = debugger.DebuggerCore; debuggerCore = debugger.DebuggerCore;
debuggerCore.LocalVariables.VariableAdded += delegate(object sender, VariableEventArgs e) { localVarList.BeginUpdate();
AddVariable(e.Variable); AddVariableCollectionToTree(debuggerCore.LocalVariables, localVarList.Items);
localVarList.EndUpdate();
}
public static void AddVariableCollectionToTree(VariableCollection varCollection, TreeListViewItemCollection tree)
{
varCollection.VariableAdded += delegate(object sender, VariableEventArgs e) {
AddVariableToTree(e.Variable, tree);
}; };
localVarList.BeginUpdate(); foreach(Variable variable in varCollection) {
foreach(Variable v in debuggerCore.LocalVariables) { AddVariableToTree(variable, tree);
AddVariable(v);
} }
localVarList.EndUpdate();
} }
void AddVariable(Variable variableToAdd) public static void AddVariableToTree(Variable variableToAdd, TreeListViewItemCollection tree)
{ {
if (variableToAdd.Name.StartsWith("CS$")) return; if (variableToAdd.Name.StartsWith("CS$")) return;
TreeListViewDebuggerItem newItem = new TreeListViewDebuggerItem(variableToAdd); TreeListViewDebuggerItem newItem = new TreeListViewDebuggerItem(variableToAdd);
debuggerCore.LocalVariables.VariableRemoved += delegate(object sender, VariableEventArgs removedArgs) { tree.Add(newItem);
if (variableToAdd == removedArgs.Variable) newItem.Remove();
};
localVarList.Items.Add(newItem);
} }
public override void RedrawContent() public override void RedrawContent()

54
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public class TreeListViewDebuggerItem: TreeListViewItem public class TreeListViewDebuggerItem: TreeListViewItem
{ {
Variable variable; Variable variable;
bool baseClassItemAdded; bool populated = false;
public Variable Variable { public Variable Variable {
get { get {
@ -49,6 +49,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
Update(); Update();
}; };
variable.ValueRemovedFromCollection += delegate { this.Remove(); };
SubItems.Add(""); SubItems.Add("");
SubItems.Add(""); SubItems.Add("");
@ -57,9 +59,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public void Update() public void Update()
{ {
this.SubItems[0].Text = Variable.Name; if (this.SubItems[0].Text != Variable.Name)
this.SubItems[1].Text = Variable.Value.AsString; this.SubItems[0].Text = Variable.Name;
this.SubItems[2].Text = Variable.Value.Type; if (this.SubItems[1].Text != Variable.Value.AsString)
this.SubItems[1].Text = Variable.Value.AsString;
if (this.SubItems[2].Text != Variable.Value.Type)
this.SubItems[2].Text = Variable.Value.Type;
if (variable.Value is ObjectValue) { if (variable.Value is ObjectValue) {
this.ImageIndex = 0; // Class this.ImageIndex = 0; // Class
@ -69,37 +74,40 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
this.ImageIndex = 1; // Field this.ImageIndex = 1; // Field
} }
if (!baseClassItemAdded) { if (IsExpanded) {
TryToAddBaseClassItem(); variable.SubVariables.Update();
baseClassItemAdded = true; } else {
// Show plus sign
if (variable.Value.MayHaveSubVariables && Items.Count == 0) {
TreeListViewItem dummy = new TreeListViewItem();
this.AfterExpand += delegate { dummy.Remove(); };
Items.Add(dummy);
}
} }
// if (IsExpanded) {
// UpdateSubVariables();
// } else {
// if (variable.Value.MayHaveSubVariables) {
// Items.Add(new PlaceHolderItem()); // Show plus icon
// }
// }
} }
public void BeforeExpand() public void BeforeExpand()
{ {
if (populated) {
variable.SubVariables.Update();
} else {
Populate();
populated = true;
}
}
public void Populate()
{
Items.Clear();
// Do not sort names of array items // Do not sort names of array items
if (variable.Value is ArrayValue) { if (variable.Value is ArrayValue) {
this.Items.SortOrder = SortOrder.None; this.Items.SortOrder = SortOrder.None;
} else { } else {
this.Items.SortOrder = SortOrder.Ascending; this.Items.SortOrder = SortOrder.Ascending;
} }
}
void TryToAddBaseClassItem() LocalVarPad.AddVariableCollectionToTree(variable.SubVariables, this.Items);
{
ObjectValue objectValue = variable.Value as ObjectValue;
if (objectValue != null && objectValue.HasBaseClass && objectValue.BaseClass.Type != "System.Object") {
Variable baseClassVar = VariableFactory.CreateVariable(objectValue.BaseClass, "<Base class>");
Items.Add(new TreeListViewDebuggerItem(baseClassVar));
}
} }
} }

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

@ -71,6 +71,10 @@ namespace Debugger
public override IEnumerable<Variable> SubVariables { public override IEnumerable<Variable> SubVariables {
get { get {
if (HasBaseClass) {
yield return BaseClassVariable;
}
// Current frame is necessary to resolve context specific static values (eg. ThreadStatic) // Current frame is necessary to resolve context specific static values (eg. ThreadStatic)
ICorDebugFrame curFrame; ICorDebugFrame curFrame;
if (debugger.CurrentThread == null || debugger.CurrentThread.LastFunction == null || debugger.CurrentThread.LastFunction.CorILFrame == null) { if (debugger.CurrentThread == null || debugger.CurrentThread.LastFunction == null || debugger.CurrentThread.LastFunction.CorILFrame == null) {
@ -102,6 +106,16 @@ namespace Debugger
} }
} }
public Variable BaseClassVariable {
get {
if (HasBaseClass) {
return VariableFactory.CreateVariable(this.BaseClass, "<Base class>");
} else {
return null;
}
}
}
public unsafe ObjectValue BaseClass { public unsafe ObjectValue BaseClass {
get { get {
if (baseClass == null) baseClass = GetBaseClass(); if (baseClass == null) baseClass = GetBaseClass();

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -18,6 +18,7 @@ namespace Debugger
VariableCollection subVariables; VariableCollection subVariables;
public event EventHandler<VariableEventArgs> ValueChanged; public event EventHandler<VariableEventArgs> ValueChanged;
public event EventHandler<VariableCollectionEventArgs> ValueRemovedFromCollection;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -52,6 +53,12 @@ namespace Debugger
} }
} }
public bool MayHaveSubVariables {
get {
return val.MayHaveSubVariables;
}
}
protected virtual void OnValueChanged() protected virtual void OnValueChanged()
{ {
if (ValueChanged != null) { if (ValueChanged != null) {
@ -68,6 +75,12 @@ namespace Debugger
subVariables.UpdateTo(newVariables); subVariables.UpdateTo(newVariables);
} }
protected internal virtual void OnValueRemovedFromCollection(VariableCollectionEventArgs e) {
if (ValueRemovedFromCollection != null) {
ValueRemovedFromCollection(this, e);
}
}
public Variable(NDebugger debugger, Value val, string name) public Variable(NDebugger debugger, Value val, string name)
{ {
this.debugger = debugger; this.debugger = debugger;

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

@ -93,6 +93,7 @@ namespace Debugger
if (variable != null) { if (variable != null) {
InnerList.Remove(variable); InnerList.Remove(variable);
OnVariableRemoved(new VariableEventArgs(variable)); OnVariableRemoved(new VariableEventArgs(variable));
variable.OnValueRemovedFromCollection(new VariableCollectionEventArgs(this));
} }
} }

Loading…
Cancel
Save