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. 119
      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 @@ -178,9 +178,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
DateTime start = Debugger.Util.HighPrecisionTimer.Now;
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 {
TreeViewNode.OverwriteNodes(localVarList, localVarList.Root.Children, null);
TreeViewNode.SetContentRecursive(localVarList, localVarList.Root.Children, null);
}
DateTime end = Debugger.Util.HighPrecisionTimer.Now;
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 @@ -250,11 +250,12 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
public Expression GetExpressionFromName(string variableName)
{
if (debuggedProcess == null || debuggedProcess.IsRunning) {
return null;
} else {
return new Expression(variableName);
}
return null;
// if (debuggedProcess == null || debuggedProcess.IsRunning) {
// return null;
// } else {
// return new Expression(variableName);
// }
}

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

@ -18,68 +18,98 @@ namespace Debugger.AddIn.TreeModel @@ -18,68 +18,98 @@ namespace Debugger.AddIn.TreeModel
{
public partial class TreeViewNode: TreeNodeAdv
{
static Dictionary<string, bool> expandedNodes = new Dictionary<string, bool>();
AbstractNode content;
bool populated = false;
bool loadChildsWhenExpanding;
public AbstractNode 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())
{
this.content = content;
this.IsLeaf = content.ChildNodes == null;
SetContentRecursive(content);
}
public void OnExpanding()
public void SetContentRecursive(AbstractNode content)
{
if (!populated) {
foreach(AbstractNode childNode in this.Content.ChildNodes) {
Children.Add(new TreeViewNode(Tree, childNode));
}
populated = true;
this.IsExpandedOnce = true;
this.Tree.UpdateSelection();
this.Tree.FullUpdate();
this.content = content;
this.IsLeaf = (content.ChildNodes == null);
this.IsExpanded = (content.ChildNodes != null && expandedNodes.ContainsKey(this.FullName) && expandedNodes[this.FullName]);
if (this.IsExpanded) {
loadChildsWhenExpanding = false;
SetContentRecursive(this.Tree, this.Children, this.Content.ChildNodes);
} else {
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;
foreach(AbstractNode modelNode in modelNodes) {
foreach(AbstractNode content in contentEnum) {
// Add or overwrite existing items
if (index < treeNodes.Count) {
if (index < childNodes.Count) {
// Overwrite
((TreeViewNode)treeNodes[index]).Content = modelNode;
((TreeViewNode)childNodes[index]).SetContentRecursive(content);
} else {
// Add
treeNodes.Add(new TreeViewNode(tree, modelNode));
childNodes.Add(new TreeViewNode(tree, content));
}
DoEvents();
index++;
}
int count = index;
// Delete other nodes
while(treeNodes.Count > count) {
treeNodes.RemoveAt(count);
while(childNodes.Count > count) {
childNodes.RemoveAt(count);
}
tree.FullUpdate();
}
#region DoApplicationEvents()
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;
}
public void OnCollapsed()
{
expandedNodes[FullName] = false;
}
static DateTime nextDoEventsTime = Debugger.Util.HighPrecisionTimer.Now;
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
void DoApplicationEvents()
static void DoEvents()
{
if (Debugger.Util.HighPrecisionTimer.Now > nextDoEventsTime) {
DateTime start = Debugger.Util.HighPrecisionTimer.Now;
@ -94,40 +124,5 @@ namespace Debugger.AddIn.TreeModel @@ -94,40 +124,5 @@ namespace Debugger.AddIn.TreeModel
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 @@ -19,8 +19,11 @@ namespace Debugger
{
public Value Evaluate(StackFrame context)
{
context.Process.TraceMessage("Evaluating " + this.Code);
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