Browse Source

Updated TreeViewNode adapter to the new model.

The pad is progressively updated using the same method as before - Application.DoEvents() is called periodically so that repaint events are invoked.  I still need to put is checks so that press of Stepping command terminates the update. 

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2792 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
4dfa334656
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  2. 11
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  3. 117
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Adapters/TreeViewNode.cs
  4. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs

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

@ -178,9 +178,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
DateTime start = Debugger.Util.HighPrecisionTimer.Now; DateTime start = Debugger.Util.HighPrecisionTimer.Now;
if (debuggedProcess != null && debuggedProcess.SelectedStackFrame != null) { if (debuggedProcess != null && debuggedProcess.SelectedStackFrame != null) {
TreeViewNode.OverwriteNodes(localVarList, localVarList.Root.Children, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes); TreeViewNode.SetContentRecursive(localVarList, localVarList.Root.Children, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes);
} else { } else {
TreeViewNode.OverwriteNodes(localVarList, localVarList.Root.Children, null); TreeViewNode.SetContentRecursive(localVarList, localVarList.Root.Children, null);
} }
DateTime end = Debugger.Util.HighPrecisionTimer.Now; DateTime end = Debugger.Util.HighPrecisionTimer.Now;
LoggingService.InfoFormatted("Local Variables pad refreshed ({0} ms)", (end - start).TotalMilliseconds); LoggingService.InfoFormatted("Local Variables pad refreshed ({0} ms)", (end - start).TotalMilliseconds);

11
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -250,11 +250,12 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary> /// </summary>
public Expression GetExpressionFromName(string variableName) public Expression GetExpressionFromName(string variableName)
{ {
if (debuggedProcess == null || debuggedProcess.IsRunning) { return null;
return null; // if (debuggedProcess == null || debuggedProcess.IsRunning) {
} else { // return null;
return new Expression(variableName); // } else {
} // return new Expression(variableName);
// }
} }

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

@ -18,68 +18,98 @@ namespace Debugger.AddIn.TreeModel
{ {
public partial class TreeViewNode: TreeNodeAdv public partial class TreeViewNode: TreeNodeAdv
{ {
static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
AbstractNode content; AbstractNode content;
bool populated = false; bool loadChildsWhenExpanding;
public AbstractNode Content { public AbstractNode Content {
get { return content; } get { return content; }
set { content = value; } }
string FullName {
get {
if (this.Parent != null && this.Parent is TreeViewNode) {
return ((TreeViewNode)this.Parent).FullName + "." + Content.Name;
} else {
return Content.Name;
}
}
} }
public TreeViewNode(TreeViewAdv tree, AbstractNode content): base(tree, new object()) public TreeViewNode(TreeViewAdv tree, AbstractNode content): base(tree, new object())
{ {
this.content = content; SetContentRecursive(content);
this.IsLeaf = content.ChildNodes == null;
} }
public void OnExpanding() public void SetContentRecursive(AbstractNode content)
{ {
if (!populated) { this.content = content;
foreach(AbstractNode childNode in this.Content.ChildNodes) { this.IsLeaf = (content.ChildNodes == null);
Children.Add(new TreeViewNode(Tree, childNode)); this.IsExpanded = (content.ChildNodes != null && expandedNodes.ContainsKey(this.FullName) && expandedNodes[this.FullName]);
} if (this.IsExpanded) {
populated = true; loadChildsWhenExpanding = false;
this.IsExpandedOnce = true; SetContentRecursive(this.Tree, this.Children, this.Content.ChildNodes);
this.Tree.UpdateSelection(); } else {
this.Tree.FullUpdate(); loadChildsWhenExpanding = true;
this.Children.Clear();
} }
} }
public static void OverwriteNodes(TreeViewAdv tree, Collection<TreeNodeAdv> treeNodes, IEnumerable<AbstractNode> modelNodes) public static void SetContentRecursive(TreeViewAdv tree, Collection<TreeNodeAdv> childNodes, IEnumerable<AbstractNode> contentEnum)
{ {
modelNodes = modelNodes ?? new AbstractNode[0]; contentEnum = contentEnum ?? new AbstractNode[0];
DoEvents();
int index = 0; int index = 0;
foreach(AbstractNode modelNode in modelNodes) { foreach(AbstractNode content in contentEnum) {
// Add or overwrite existing items // Add or overwrite existing items
if (index < treeNodes.Count) { if (index < childNodes.Count) {
// Overwrite // Overwrite
((TreeViewNode)treeNodes[index]).Content = modelNode; ((TreeViewNode)childNodes[index]).SetContentRecursive(content);
} else { } else {
// Add // Add
treeNodes.Add(new TreeViewNode(tree, modelNode)); childNodes.Add(new TreeViewNode(tree, content));
} }
DoEvents();
index++; index++;
} }
int count = index; int count = index;
// Delete other nodes // Delete other nodes
while(treeNodes.Count > count) { while(childNodes.Count > count) {
treeNodes.RemoveAt(count); childNodes.RemoveAt(count);
}
}
public void OnExpanding()
{
if (loadChildsWhenExpanding) {
loadChildsWhenExpanding = false;
SetContentRecursive(this.Tree, this.Children, this.Content.ChildNodes);
this.IsExpandedOnce = true;
this.Tree.UpdateSelection();
this.Tree.FullUpdate();
} }
}
public void OnExpanded()
{
expandedNodes[FullName] = true;
}
tree.FullUpdate(); public void OnCollapsed()
{
expandedNodes[FullName] = false;
} }
#region DoApplicationEvents()
static DateTime nextDoEventsTime = Debugger.Util.HighPrecisionTimer.Now; static DateTime nextDoEventsTime = Debugger.Util.HighPrecisionTimer.Now;
const double workLoad = 0.75; // Fraction of getting variables vs. repainting const double workLoad = 0.75; // Fraction of getting variables vs. repainting
const double maxFPS = 30; // ms this prevents too much drawing on good machine const double maxFPS = 30; // this prevents too much drawing on good machine
const double maxWorkTime = 250; // ms this ensures minimal response on bad machine const double maxWorkTime = 250; // ms this ensures minimal response on bad machine
void DoApplicationEvents() static void DoEvents()
{ {
if (Debugger.Util.HighPrecisionTimer.Now > nextDoEventsTime) { if (Debugger.Util.HighPrecisionTimer.Now > nextDoEventsTime) {
DateTime start = Debugger.Util.HighPrecisionTimer.Now; DateTime start = Debugger.Util.HighPrecisionTimer.Now;
@ -94,40 +124,5 @@ namespace Debugger.AddIn.TreeModel
LoggingService.InfoFormatted("Rendering: {0} ms => work budget: {1} ms ({2:f1} FPS)", doEventsDuration, workTime, fps); LoggingService.InfoFormatted("Rendering: {0} ms => work budget: {1} ms ({2:f1} FPS)", doEventsDuration, workTime, fps);
} }
} }
#endregion
#region Maintain expanded state
static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
string FullName {
get {
if (this.Parent != null && this.Parent is TreeViewNode) {
return ((TreeViewNode)this.Parent).FullName + "." + Content.Name;
} else {
return Content.Name;
}
}
}
public void OnExpanded()
{
expandedNodes[FullName] = true;
// Expand children as well
foreach(TreeViewNode child in Children) {
string name = child.FullName;
if (expandedNodes.ContainsKey(name) && expandedNodes[name]) {
child.IsExpanded = true;
}
}
}
public void OnCollapsed()
{
expandedNodes[FullName] = false;
}
#endregion
} }
} }

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs

@ -19,8 +19,11 @@ namespace Debugger
{ {
public Value Evaluate(StackFrame context) public Value Evaluate(StackFrame context)
{ {
context.Process.TraceMessage("Evaluating " + this.Code);
EvaluateAstVisitor astVisitor = new EvaluateAstVisitor(context); EvaluateAstVisitor astVisitor = new EvaluateAstVisitor(context);
return (Value)this.AbstractSynatxTree.AcceptVisitor(astVisitor, null); Value result = (Value)this.AbstractSynatxTree.AcceptVisitor(astVisitor, null);
context.Process.TraceMessage("Evaluated " + this.Code);
return result;
} }
} }
} }

Loading…
Cancel
Save