Browse Source

Worked on Debugger.VariableCollection. Started redesign of local variables pad.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@753 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
7939a3daa5
  1. 7
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 101
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 114
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs
  4. 49
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs
  5. 22
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/PlaceHolderItem.cs
  6. 100
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs
  7. 76
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableListItem.cs
  8. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  9. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  10. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  11. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  12. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  13. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  14. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  15. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  16. 41
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs
  17. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollectionEventArgs.cs

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

@ -55,12 +55,9 @@ @@ -55,12 +55,9 @@
<EmbeddedResource Include="Src\Service\ExceptionForm.resx">
<DependentUpon>ExceptionForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Src\Pads\VariableListItems\BaseClassItem.cs" />
<Compile Include="Src\Pads\VariableListItems\PlaceHolderItem.cs" />
<Compile Include="Src\Pads\VariableListItems\VariableItem.cs" />
<Compile Include="Src\Pads\VariableListItems\VariableListItem.cs" />
<Compile Include="Src\Service\DynamicTreeDebuggerRow.cs" />
<Compile Include="Src\Service\SetCurrentStatementCommand.cs" />
<Compile Include="Src\Pads\TreeListViewDebuggerItem.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
@ -90,4 +87,4 @@ @@ -90,4 +87,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>
</Project>

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

@ -68,10 +68,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -68,10 +68,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
localVarList.SizeChanged += new EventHandler(localVarList_SizeChanged);
localVarList.BeforeExpand += new TreeListViewCancelEventHandler(localVarList_BeforeExpand);
debugger.DebugStopped += OnDebugStopped;
RedrawContent();
if (debugger.ServiceInitialized) {
InitializeDebugger();
} else {
@ -80,97 +79,59 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -80,97 +79,59 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
};
}
}
public void InitializeDebugger()
{
debuggerCore = debugger.DebuggerCore;
debuggerCore.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(debuggerService_OnDebuggingPaused);
RefreshList();
}
// This is a walkarond for a visual issue
void localVarList_SizeChanged(object sender, EventArgs e)
{
localVarList.Visible = true;
}
public override void RedrawContent()
public void InitializeDebugger()
{
name.Text = "Name";
val.Text = "Value";
type.Text = "Type";
debuggerCore = debugger.DebuggerCore;
debuggerCore.LocalVariables.VariableAdded += OnLocalVariableAdded;
localVarList.BeginUpdate();
foreach(Variable v in debuggerCore.LocalVariables) {
AddVariable(v);
}
localVarList.EndUpdate();
}
void OnDebugStopped(object sender, EventArgs e)
void OnLocalVariableAdded(object sender, VariableEventArgs e)
{
localVarList.Items.Clear();
if (e.Variable.Name.StartsWith("CS$")) return;
AddVariable(e.Variable);
}
private void debuggerService_OnDebuggingPaused(object sender, DebuggingPausedEventArgs e)
void AddVariable(Variable variableToAdd)
{
RefreshList();
TreeListViewDebuggerItem newItem = new TreeListViewDebuggerItem(variableToAdd);
debuggerCore.LocalVariables.VariableRemoved += delegate(object sender, VariableEventArgs removedArgs) {
if (variableToAdd == removedArgs.Variable) newItem.Remove();
};
localVarList.Items.Add(newItem);
}
void RefreshList()
public override void RedrawContent()
{
UpdateVariables(localVarList.Items, debuggerCore.LocalVariables);
name.Text = "Name";
val.Text = "Value";
type.Text = "Type";
}
private void localVarList_BeforeExpand(object sender, TreeListViewCancelEventArgs e)
{
if (debuggerCore.IsPaused) {
((VariableListItem)e.Item).PrepareForExpansion();
((TreeListViewDebuggerItem)e.Item).BeforeExpand();
} else {
MessageBox.Show("You can not explore variables while the debuggee is running.");
e.Cancel = true;
}
}
static VariableItem FindVariableItem(TreeListViewItemCollection items, Variable variable)
{
foreach (VariableListItem item in items) {
VariableItem variableItem = item as VariableItem;
if (variableItem != null && variableItem.Variable.Name == variable.Name) {
return variableItem;
}
}
return null;
}
public static void UpdateVariables(TreeListViewItemCollection items, VariableCollection variables)
{
// Add new variables and refresh existing ones
foreach (Variable variable in variables) {
VariableItem item = FindVariableItem(items, variable);
if (item != null) {
item.Variable = variable;
item.Refresh();
} else {
item = new VariableItem(variable);
if (item.IsValid) {
items.Add(item);
}
}
}
// Delete invalid or removed variables
List<VariableListItem> toBeRemoved = new List<VariableListItem>();
foreach (VariableListItem item in items) {
if (!item.IsValid) {
toBeRemoved.Add(item);
continue;
}
VariableItem variableItem = item as VariableItem;
if (variableItem != null && !(item is BaseClassItem) && !variables.Contains(variableItem.Variable.Name)) {
toBeRemoved.Add(item);
}
}
foreach (VariableListItem item in toBeRemoved) {
item.Remove();
}
}
}
}

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

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using Debugger;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
public class TreeListViewDebuggerItem: TreeListViewItem
{
Variable variable;
bool created;
public Variable Variable {
get {
return variable;
}
}
public bool Highlight {
set {
if (value) {
if (SubItems[1].ForeColor != Color.Blue) { // smart update
SubItems[1].ForeColor = Color.Blue;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Bold);
}
} else {
if (SubItems[1].ForeColor != Color.Black) { // smart update
SubItems[1].ForeColor = Color.Black;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Regular);
}
}
}
}
public TreeListViewDebuggerItem(Variable variable)
{
this.variable = variable;
variable.ValueChanged += delegate { Update(); };
SubItems.Add("");
SubItems.Add("");
Update();
created = true; // Used to prevent highlighting of new variables
}
public void Update()
{
Highlight = (Variable.Value.AsString != SubItems[1].Text && created);
this.SubItems[0].Text = Variable.Name;
this.SubItems[1].Text = Variable.Value.AsString;
this.SubItems[2].Text = Variable.Value.Type;
if (variable.Value is ObjectValue) {
this.ImageIndex = 0; // Class
} else if (variable is PropertyVariable){
this.ImageIndex = 2; // Property
} else {
this.ImageIndex = 1; // Field
}
// if (IsExpanded) {
// UpdateSubVariables();
// } else {
// if (variable.Value.MayHaveSubVariables) {
// Items.Add(new PlaceHolderItem()); // Show plus icon
// }
// }
}
public void BeforeExpand()
{
}
// public GetBaseClass()
// {
// ObjectValue objectValue = uncastedVariable.Value as ObjectValue;
// if (objectValue != null && objectValue.HasBaseClass && objectValue.BaseClass.Type != "System.Object") {
// this.Variable = VariableFactory.CreateVariable(objectValue.BaseClass, uncastedVariable.Name);
// }
// }
//
// protected void UpdateSubVariables() {
// if (!baseClassItemAdded) {
// VariableListItem baseClassItem = new BaseClassItem(variable);
// if (baseClassItem.IsValid) {
// this.Items.Add(baseClassItem);
// }
// baseClassItemAdded = true;
// }
//
// // Do not sort names of array items
// if (Variable.Value is ArrayValue) {
// this.Items.SortOrder = SortOrder.None;
// } else {
// this.Items.SortOrder = SortOrder.Ascending;
// }
//
// LocalVarPad.UpdateVariables(this.Items, Variable.Value.SubVariables);
// }
}
}

49
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs

@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using Debugger;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class BaseClassItem: VariableItem
{
public BaseClassItem(Variable uncastedVariable)
{
ObjectValue objectValue = uncastedVariable.Value as ObjectValue;
if (objectValue != null && objectValue.HasBaseClass && objectValue.BaseClass.Type != "System.Object") {
this.Variable = VariableFactory.CreateVariable(objectValue.BaseClass, uncastedVariable.Name);
} else {
this.Variable = null;
}
Refresh();
}
public override void Refresh()
{
if (!IsValid) {
return;
}
SetTexts("<Base class>",
Variable.Value.AsString.ToString(),
Variable.Value.Type);
ImageIndex = 0; // Class
if (IsExpanded) {
UpdateSubVariables();
} else {
if (Variable.Value.MayHaveSubVariables) { // Always true
Items.Add(new PlaceHolderItem()); // Show plus icon
}
}
}
}
}

22
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/PlaceHolderItem.cs

@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class PlaceHolderItem: VariableListItem
{
public override bool IsValid {
get {
return false;
}
}
}
}

100
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs

@ -1,100 +0,0 @@ @@ -1,100 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Debugger;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class VariableItem: VariableListItem
{
Variable variable;
bool baseClassItemAdded = false;
public Variable Variable {
get {
return variable;
}
set {
variable = value;
}
}
public override bool IsValid {
get {
return variable != null &&
!variable.Name.StartsWith("CS$");
}
}
protected VariableItem()
{
}
public VariableItem(Variable variable): base()
{
this.variable = variable;
Refresh();
}
public override void PrepareForExpansion()
{
UpdateSubVariables();
}
public override void Refresh()
{
if (!IsValid) {
return;
}
SetTexts(variable.Name,
variable.Value.AsString,
variable.Value.Type);
if (variable.Value is ObjectValue) {
ImageIndex = 0; // Class
} else if (variable is PropertyVariable){
ImageIndex = 2; // Property
} else {
ImageIndex = 1; // Field
}
if (IsExpanded) {
UpdateSubVariables();
} else {
if (variable.Value.MayHaveSubVariables) {
Items.Add(new PlaceHolderItem()); // Show plus icon
}
}
}
protected void UpdateSubVariables() {
if (!baseClassItemAdded) {
VariableListItem baseClassItem = new BaseClassItem(variable);
if (baseClassItem.IsValid) {
this.Items.Add(baseClassItem);
}
baseClassItemAdded = true;
}
// Do not sort names of array items
if (Variable.Value is ArrayValue) {
this.Items.SortOrder = SortOrder.None;
} else {
this.Items.SortOrder = SortOrder.Ascending;
}
LocalVarPad.UpdateVariables(this.Items, Variable.Value.SubVariables);
}
}
}

76
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableListItem.cs

@ -1,76 +0,0 @@ @@ -1,76 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
abstract class VariableListItem: TreeListViewItem
{
bool textsInitialized;
public abstract bool IsValid {
get;
}
public VariableListItem()
{
Reset();
}
public virtual void PrepareForExpansion()
{
}
public virtual void Reset()
{
SubItems.Clear();
Text = "";
SubItems.Add("");
SubItems.Add("");
}
public virtual void Refresh()
{
}
protected void SetTexts(string name, string value, string type)
{
if (value == SubItems[1].Text || !textsInitialized) {
// Value has not changed since last setting
if (SubItems[1].ForeColor != Color.Black) {
SubItems[1].ForeColor = Color.Black;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Regular);
}
} else {
// Value has changed since last setting
if (SubItems[1].ForeColor != Color.Blue) {
SubItems[1].ForeColor = Color.Blue;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Bold);
}
}
if (SubItems[0].Text != name) {
SubItems[0].Text = name;
}
if (SubItems[1].Text != value) {
SubItems[1].Text = value;
}
if (SubItems[2].Text != type) {
SubItems[2].Text = type;
}
textsInitialized = true;
}
}
}

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

@ -208,6 +208,7 @@ @@ -208,6 +208,7 @@
<Compile Include="Src\Variables\Variable.cs" />
<Compile Include="Src\Variables\VariableEventArgs.cs" />
<Compile Include="Src\Variables\VariableFactory.cs" />
<Compile Include="Src\Variables\VariableCollectionEventArgs.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs

@ -145,8 +145,13 @@ namespace Debugger @@ -145,8 +145,13 @@ namespace Debugger
pausedReason = reason;
OnDebuggingPaused(reason);
waitForPauseHandle.Set();
if (IsPaused) { // OnDebuggingPaused can resume the debugger
localVariables.Update();
waitForPauseHandle.Set();
}
}
internal void FakePause(PausedReason reason, bool keepCurrentFunction)

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -25,7 +25,7 @@ namespace Debugger @@ -25,7 +25,7 @@ namespace Debugger
ApartmentState requiredApartmentState;
VariableCollection localVariables = new VariableCollection();
VariableCollection localVariables;
string debuggeeVersion;
@ -57,7 +57,9 @@ namespace Debugger @@ -57,7 +57,9 @@ namespace Debugger
{
requiredApartmentState = System.Threading.Thread.CurrentThread.GetApartmentState();
this.ModuleLoaded += new EventHandler<ModuleEventArgs>(SetBreakpointsInModule);
this.ModuleLoaded += SetBreakpointsInModule;
localVariables = new VariableCollection(this);
}
/// <summary>
@ -107,11 +109,15 @@ namespace Debugger @@ -107,11 +109,15 @@ namespace Debugger
corDebug.Initialize();
corDebug.SetManagedHandler(managedCallbackProxy);
localVariables.Updating += OnUpdatingLocalVariables;
TraceMessage("ICorDebug initialized, debugee version " + debuggeeVersion);
}
internal void TerminateDebugger()
{
localVariables.Clear();
ClearModules();
ResetBreakpoints();
@ -187,13 +193,17 @@ namespace Debugger @@ -187,13 +193,17 @@ namespace Debugger
public VariableCollection LocalVariables {
get {
if (CurrentFunction == null) {
localVariables.UpdateTo(VariableCollection.Empty);
} else {
localVariables.UpdateTo(CurrentFunction.GetVariables());
}
return localVariables;
}
}
void OnUpdatingLocalVariables(object sender, VariableCollectionEventArgs e)
{
if (CurrentFunction == null) {
e.VariableCollection.UpdateTo(VariableCollection.Empty);
} else {
e.VariableCollection.UpdateTo(CurrentFunction.GetVariables());
}
}
}
}

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -418,7 +418,7 @@ namespace Debugger @@ -418,7 +418,7 @@ namespace Debugger
public VariableCollection GetArgumentVariables()
{
VariableCollection arguments = new VariableCollection();
VariableCollection arguments = new VariableCollection(debugger);
int argCount = ArgumentCount;
@ -431,7 +431,7 @@ namespace Debugger @@ -431,7 +431,7 @@ namespace Debugger
public VariableCollection GetLocalVariables()
{
VariableCollection localVariables = new VariableCollection();
VariableCollection localVariables = new VariableCollection(debugger);
if (symMethod != null) {
ISymbolScope symRootScope = symMethod.RootScope;
AddScopeToVariableCollection(symRootScope, ref localVariables);
@ -441,7 +441,7 @@ namespace Debugger @@ -441,7 +441,7 @@ namespace Debugger
VariableCollection GetPropertyVariables()
{
VariableCollection properties = new VariableCollection();
VariableCollection properties = new VariableCollection(debugger);
foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) {
if (method.Name.StartsWith("get_") && method.HasSpecialName) {

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs

@ -113,7 +113,7 @@ namespace Debugger @@ -113,7 +113,7 @@ namespace Debugger
protected override VariableCollection GetSubVariables()
{
VariableCollection subVariables = new VariableCollection();
VariableCollection subVariables = new VariableCollection(debugger);
uint[] indices = new uint[rank];

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

@ -70,7 +70,7 @@ namespace Debugger @@ -70,7 +70,7 @@ namespace Debugger
protected override unsafe VariableCollection GetSubVariables()
{
VariableCollection subVariables = new VariableCollection();
VariableCollection subVariables = new VariableCollection(debugger);
// Current frame is necessary to resolve context specific static values (eg. ThreadStatic)
ICorDebugFrame curFrame;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs

@ -62,7 +62,7 @@ namespace Debugger @@ -62,7 +62,7 @@ namespace Debugger
protected virtual VariableCollection GetSubVariables()
{
return new VariableCollection();
return new VariableCollection(debugger);
}
internal Value(NDebugger debugger, ICorDebugValue corValue)

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

@ -34,6 +34,10 @@ namespace Debugger @@ -34,6 +34,10 @@ namespace Debugger
get {
return val;
}
internal set {
val = value;
OnValueChanged();
}
}
protected virtual void OnValueChanged()

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

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Debugger.Interop.CorDebug;
@ -15,17 +16,25 @@ namespace Debugger @@ -15,17 +16,25 @@ namespace Debugger
[Serializable]
public class VariableCollection: ReadOnlyCollectionBase
{
NDebugger debugger;
public static VariableCollection Empty;
bool readOnly = false;
public event EventHandler<VariableEventArgs> VariableAdded;
public event EventHandler<VariableEventArgs> VariableRemoved;
internal event EventHandler Updating;
internal event EventHandler<VariableCollectionEventArgs> Updating;
internal VariableCollection()
{
public NDebugger Debugger {
get {
return debugger;
}
}
internal VariableCollection(NDebugger debugger)
{
this.debugger = debugger;
}
/// <summary>
@ -33,7 +42,7 @@ namespace Debugger @@ -33,7 +42,7 @@ namespace Debugger
/// </summary>
/// <param name="updating"></param>
/// <returns></returns>
internal VariableCollection(EventHandler updating)
internal VariableCollection(NDebugger debugger, EventHandler<VariableCollectionEventArgs> updating): this(debugger)
{
this.Updating += updating;
this.Update();
@ -41,7 +50,7 @@ namespace Debugger @@ -41,7 +50,7 @@ namespace Debugger
static VariableCollection()
{
Empty = new VariableCollection();
Empty = new VariableCollection(null);
Empty.readOnly = true;
}
@ -92,9 +101,7 @@ namespace Debugger @@ -92,9 +101,7 @@ namespace Debugger
/// </summary>
internal void Clear()
{
foreach(Variable variable in InnerList) {
Remove(variable);
}
InnerList.Clear();
Updating = null;
}
@ -125,7 +132,7 @@ namespace Debugger @@ -125,7 +132,7 @@ namespace Debugger
public void Update()
{
OnUpdating(EventArgs.Empty);
OnUpdating();
}
/// <summary>
@ -141,8 +148,7 @@ namespace Debugger @@ -141,8 +148,7 @@ namespace Debugger
// Update existing variables
foreach(Variable variable in mergedCollection) {
if (this.Contains(variable.Name)) {
this.Remove(this[variable.Name]);
this.Add(variable);
this[variable.Name].Value = variable.Value;
}
}
@ -154,11 +160,15 @@ namespace Debugger @@ -154,11 +160,15 @@ namespace Debugger
}
// Remove variables that are not in merged collection
List<Variable> toBeRemoved = new List<Variable>(); // We can NOT modify collection which are using!!!
foreach(Variable variable in this) {
if (!mergedCollection.Contains(variable.Name)) {
this.Remove(variable);
toBeRemoved.Add(variable);
}
}
foreach(Variable variable in toBeRemoved) {
this.Remove(variable);
}
}
protected virtual void OnVariableAdded(VariableEventArgs e)
@ -175,10 +185,10 @@ namespace Debugger @@ -175,10 +185,10 @@ namespace Debugger
}
}
protected virtual void OnUpdating(EventArgs e)
protected virtual void OnUpdating()
{
if (Updating != null) {
Updating(this, e);
Updating(this, new VariableCollectionEventArgs(this));
}
}
@ -193,7 +203,8 @@ namespace Debugger @@ -193,7 +203,8 @@ namespace Debugger
public static VariableCollection Merge(params VariableCollection[] collections)
{
VariableCollection newCollection = new VariableCollection();
if (collections.Length == 0) throw new ArgumentException("Can not have lenght of 0", "collections");
VariableCollection newCollection = new VariableCollection(collections[0].Debugger);
newCollection.MergeWith(collections);
return newCollection;
}

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollectionEventArgs.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
[Serializable]
public class VariableCollectionEventArgs: DebuggerEventArgs
{
VariableCollection variableCollection;
public VariableCollection VariableCollection {
get {
return variableCollection;
}
}
public VariableCollectionEventArgs(VariableCollection variableCollection): base(variableCollection.Debugger)
{
this.variableCollection = variableCollection;
}
}
}
Loading…
Cancel
Save