Skip to content

Commit 2eb80fd

Browse files
committed
Merge pull request #577 from Neverbirth/debugging_improvements
Support for adding custom expressions in the Watch panel
2 parents 77dc893 + 921c969 commit 2eb80fd

File tree

14 files changed

+381
-135
lines changed

14 files changed

+381
-135
lines changed

External/Plugins/FlashDebugger/Controls/DataTipForm.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Drawing;
33
using System.Windows.Forms;
44
using Aga.Controls.Tree;
5+
using FlashDebugger.Controls.DataTree;
56
using flash.tools.debugger;
67
using PluginCore;
78

@@ -44,7 +45,7 @@ public void SetVariable(Variable variable, String path)
4445
public void SetVariable(Variable variable)
4546
{
4647
DataTree.Nodes.Clear();
47-
DataTree.AddNode(new DataNode(variable));
48+
DataTree.AddNode(new VariableNode(variable));
4849
DoResize();
4950
}
5051

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using Aga.Controls.Tree;
3+
using flash.tools.debugger;
4+
using PluginCore.Utilities;
5+
6+
namespace FlashDebugger.Controls.DataTree
7+
{
8+
public abstract class DataNode : Node
9+
{
10+
11+
public abstract string Value { get; set; }
12+
13+
public DataNode(string text) : base(text)
14+
{
15+
}
16+
17+
}
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace FlashDebugger.Controls.DataTree
7+
{
8+
public class ScalarNode : DataNode
9+
{
10+
11+
private string m_Value;
12+
public override string Value
13+
{
14+
get { return m_Value; }
15+
set { throw new NotSupportedException(); }
16+
}
17+
18+
public ScalarNode(string text, string value)
19+
: base(text)
20+
{
21+
m_Value = value;
22+
}
23+
24+
public override bool IsLeaf
25+
{
26+
get
27+
{
28+
return true;
29+
}
30+
}
31+
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using System;
2-
using Aga.Controls.Tree;
32
using flash.tools.debugger;
4-
using PluginCore.Utilities;
53

6-
namespace FlashDebugger.Controls
4+
namespace FlashDebugger.Controls.DataTree
75
{
8-
public class DataNode : Node, IComparable<DataNode>
6+
public class ValueNode : DataNode
97
{
108
private int m_ChildrenShowLimit = 500;
119
public int ChildrenShowLimit
@@ -14,50 +12,26 @@ public int ChildrenShowLimit
1412
set { m_ChildrenShowLimit = value; }
1513
}
1614

17-
private Variable m_Value;
15+
protected Value m_Value;
1816
private bool m_bEditing = false;
1917

20-
public int CompareTo(DataNode otherNode)
21-
{
22-
String thisName = Text;
23-
String otherName = otherNode.Text;
24-
if (thisName == otherName)
25-
{
26-
return 0;
27-
}
28-
if (thisName.Length>0 && thisName[0] == '_')
29-
{
30-
thisName = thisName.Substring(1);
31-
}
32-
if (otherName.Length>0 && otherName[0] == '_')
33-
{
34-
otherName = otherName.Substring(1);
35-
}
36-
int result = LogicalComparer.Compare(thisName, otherName);
37-
if (result != 0)
38-
{
39-
return result;
40-
}
41-
return m_Value.getName().length()>0 && m_Value.getName().startsWith("_") ? 1 : -1;
42-
}
43-
44-
public string Value
18+
public override string Value
4519
{
4620
get
4721
{
4822
if (m_Value == null)
4923
{
5024
return string.Empty;
5125
}
52-
int type = m_Value.getValue().getType();
26+
int type = m_Value.getType();
5327
string temp = null;
5428
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
5529
{
56-
return m_Value.getValue().getTypeName();
30+
return m_Value.getTypeName();
5731
}
5832
else if (type == VariableType_.NUMBER)
5933
{
60-
double number = ((java.lang.Double)m_Value.getValue().getValueAsObject()).doubleValue();
34+
double number = ((java.lang.Double)m_Value.getValueAsObject()).doubleValue();
6135
if (!Double.IsNaN(number) && (double)(long)number == number)
6236
{
6337
if (!m_bEditing)
@@ -76,11 +50,11 @@ public string Value
7650
}
7751
else if (type == VariableType_.BOOLEAN)
7852
{
79-
return m_Value.getValue().getValueAsString().toLowerCase();
53+
return m_Value.getValueAsString().toLowerCase();
8054
}
8155
else if (type == VariableType_.STRING)
8256
{
83-
if (m_Value.getValue().getValueAsObject() != null)
57+
if (m_Value.getValueAsObject() != null)
8458
{
8559
return "\"" + escape(m_Value.ToString()) + "\"";
8660
}
@@ -89,12 +63,12 @@ public string Value
8963
{
9064
return "null";
9165
}
92-
else if (type == VariableType_.FUNCTION)
66+
/*else if (type == VariableType_.FUNCTION)
9367
{
9468
m_Value.ToString();
9569
//return "<setter>";
96-
}
97-
if (temp == null) temp = m_Value.ToString();
70+
}*/
71+
temp = m_Value.ToString();
9872
if (!m_bEditing)
9973
{
10074
temp = escape(temp);
@@ -103,14 +77,7 @@ public string Value
10377
}
10478
set
10579
{
106-
if (m_Value == null)
107-
return;
108-
109-
var flashInterface = PluginMain.debugManager.FlashInterface;
110-
var b = new flash.tools.debugger.expression.ASTBuilder(false);
111-
var exp = b.parse(new java.io.StringReader(this.GetVariablePath() + "=" + value));
112-
var ctx = new ExpressionContext(flashInterface.Session, flashInterface.GetFrames()[PluginMain.debugManager.CurrentFrame]);
113-
exp.evaluate(ctx);
80+
throw new NotSupportedException();
11481
}
11582
}
11683

@@ -131,7 +98,7 @@ private string escape(string text)
13198
return text;
13299
}
133100

134-
public Variable Variable
101+
public Value PlayerValue
135102
{
136103
get
137104
{
@@ -154,7 +121,7 @@ public override bool IsLeaf
154121
{
155122
return (this.Nodes.Count == 0);
156123
}
157-
return m_Value.getValue().getType() != VariableType_.MOVIECLIP && m_Value.getValue().getType() != VariableType_.OBJECT;
124+
return m_Value.getType() != VariableType_.MOVIECLIP && m_Value.getType() != VariableType_.OBJECT;
158125
}
159126
}
160127

@@ -170,44 +137,17 @@ public bool IsEditing
170137
}
171138
}
172139

173-
public DataNode(Variable value) : base(value.getName())
140+
public ValueNode(string text)
141+
: this(text, null)
174142
{
175-
m_Value = value;
176143
}
177144

178-
public DataNode(string value) : base(value)
145+
public ValueNode(string text, Value value)
146+
: base(text)
179147
{
180-
m_Value = null;
148+
m_Value = value;
181149
}
182150

183151
}
184152

185-
internal static class NodeExtensions
186-
{
187-
public static String GetVariablePath(this Node node)
188-
{
189-
String ret = string.Empty;
190-
if (node.Tag != null && node.Tag is String)
191-
return (String)node.Tag; // fix for: live tip value has no parent
192-
if (node.Parent != null) ret = node.Parent.GetVariablePath();
193-
if (node is DataNode)
194-
{
195-
DataNode datanode = node as DataNode;
196-
if (datanode.Variable != null)
197-
{
198-
if (ret == "") return datanode.Variable.getName();
199-
if ((datanode.Variable.getAttributes() & 0x00020000) == 0x00020000) //VariableAttribute_.IS_DYNAMIC
200-
{
201-
ret += "[\"" + datanode.Variable.getName() + "\"]";
202-
}
203-
else
204-
{
205-
ret += "." + datanode.Variable.getName();
206-
}
207-
}
208-
}
209-
return ret;
210-
}
211-
212-
}
213153
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Aga.Controls.Tree;
6+
using PluginCore.Utilities;
7+
using flash.tools.debugger;
8+
9+
namespace FlashDebugger.Controls.DataTree
10+
{
11+
public class VariableNode : ValueNode, IComparable<VariableNode>
12+
{
13+
14+
public override string Value
15+
{
16+
get
17+
{
18+
return base.Value;
19+
}
20+
set
21+
{
22+
if (m_Variable == null)
23+
return;
24+
25+
var flashInterface = PluginMain.debugManager.FlashInterface;
26+
var b = new flash.tools.debugger.expression.ASTBuilder(false);
27+
var exp = b.parse(new java.io.StringReader(this.GetVariablePath() + "=" + value));
28+
var ctx = new ExpressionContext(flashInterface.Session, flashInterface.GetFrames()[PluginMain.debugManager.CurrentFrame]);
29+
exp.evaluate(ctx);
30+
}
31+
}
32+
33+
private Variable m_Variable;
34+
public Variable Variable
35+
{
36+
get { return m_Variable; }
37+
set
38+
{
39+
if (m_Variable == value) return;
40+
41+
m_Variable = value;
42+
if (m_Variable != null)
43+
{
44+
m_Value = m_Variable.getValue();
45+
Text = m_Variable.getName();
46+
}
47+
else
48+
{
49+
m_Value = null;
50+
Text = "";
51+
}
52+
}
53+
}
54+
55+
public VariableNode(string text)
56+
: base(text)
57+
{
58+
}
59+
60+
public VariableNode(Variable variable)
61+
: base(variable.getName())
62+
{
63+
m_Variable = variable;
64+
m_Value = variable.getValue();
65+
}
66+
67+
public int CompareTo(VariableNode otherNode)
68+
{
69+
string thisName = Text;
70+
string otherName = otherNode.Text;
71+
if (thisName == otherName)
72+
{
73+
return 0;
74+
}
75+
if (thisName.Length > 0 && thisName[0] == '_')
76+
{
77+
thisName = thisName.Substring(1);
78+
}
79+
if (otherName.Length > 0 && otherName[0] == '_')
80+
{
81+
otherName = otherName.Substring(1);
82+
}
83+
int result = LogicalComparer.Compare(thisName, otherName);
84+
if (result != 0)
85+
{
86+
return result;
87+
}
88+
return m_Variable.getName().length() > 0 && m_Variable.getName().startsWith("_") ? 1 : -1;
89+
}
90+
91+
}
92+
93+
internal static class NodeExtensions
94+
{
95+
public static String GetVariablePath(this Node node)
96+
{
97+
String ret = string.Empty;
98+
if (node.Tag != null && node.Tag is String)
99+
return (String)node.Tag; // fix for: live tip value has no parent
100+
if (node.Parent != null) ret = node.Parent.GetVariablePath();
101+
if (node is VariableNode)
102+
{
103+
VariableNode datanode = node as VariableNode;
104+
if (datanode.Variable != null)
105+
{
106+
if (ret == "") return datanode.Variable.getName();
107+
if ((datanode.Variable.getAttributes() & 0x00020000) == 0x00020000) //VariableAttribute_.IS_DYNAMIC
108+
{
109+
ret += "[\"" + datanode.Variable.getName() + "\"]";
110+
}
111+
else
112+
{
113+
ret += "." + datanode.Variable.getName();
114+
}
115+
}
116+
}
117+
return ret;
118+
}
119+
120+
}
121+
}

0 commit comments

Comments
 (0)