Skip to content

Commit 47d162c

Browse files
committed
Support for adding custom expressions to the Watch panel
1 parent add48cf commit 47d162c

File tree

9 files changed

+469
-253
lines changed

9 files changed

+469
-253
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

External/Plugins/FlashDebugger/Controls/DataTree/DataNode.cs

Lines changed: 4 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -3,210 +3,15 @@
33
using flash.tools.debugger;
44
using PluginCore.Utilities;
55

6-
namespace FlashDebugger.Controls
6+
namespace FlashDebugger.Controls.DataTree
77
{
8-
public class DataNode : Node, IComparable<DataNode>
8+
public abstract class DataNode : Node
99
{
10-
private int m_ChildrenShowLimit = 500;
11-
public int ChildrenShowLimit
12-
{
13-
get { return m_ChildrenShowLimit; }
14-
set { m_ChildrenShowLimit = value; }
15-
}
16-
17-
private Variable m_Value;
18-
private bool m_bEditing = false;
19-
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
45-
{
46-
get
47-
{
48-
if (m_Value == null)
49-
{
50-
return string.Empty;
51-
}
52-
int type = m_Value.getValue().getType();
53-
string temp = null;
54-
if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
55-
{
56-
return m_Value.getValue().getTypeName();
57-
}
58-
else if (type == VariableType_.NUMBER)
59-
{
60-
double number = ((java.lang.Double)m_Value.getValue().getValueAsObject()).doubleValue();
61-
if (!Double.IsNaN(number) && (double)(long)number == number)
62-
{
63-
if (!m_bEditing)
64-
{
65-
if (number < 0 && number >= Int32.MinValue)
66-
{
67-
return number.ToString() + " [0x" + ((Int32)number).ToString("x") + "]";
68-
}
69-
else if (number < 0 || number > 9)
70-
{
71-
return number.ToString() + " [0x" + ((Int64)number).ToString("x") + "]";
72-
}
73-
}
74-
else return number.ToString();
75-
}
76-
}
77-
else if (type == VariableType_.BOOLEAN)
78-
{
79-
return m_Value.getValue().getValueAsString().toLowerCase();
80-
}
81-
else if (type == VariableType_.STRING)
82-
{
83-
if (m_Value.getValue().getValueAsObject() != null)
84-
{
85-
return "\"" + escape(m_Value.ToString()) + "\"";
86-
}
87-
}
88-
else if (type == VariableType_.NULL)
89-
{
90-
return "null";
91-
}
92-
else if (type == VariableType_.FUNCTION)
93-
{
94-
m_Value.ToString();
95-
//return "<setter>";
96-
}
97-
if (temp == null) temp = m_Value.ToString();
98-
if (!m_bEditing)
99-
{
100-
temp = escape(temp);
101-
}
102-
return temp;
103-
}
104-
set
105-
{
106-
if (m_Value == null)
107-
return;
10810

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);
114-
}
115-
}
116-
117-
private string escape(string text)
118-
{
119-
text = text.Replace("\\", "\\\\");
120-
text = text.Replace("\"", "\\\"");
121-
text = text.Replace("\0", "\\0");
122-
text = text.Replace("\a", "\\a");
123-
text = text.Replace("\b", "\\b");
124-
text = text.Replace("\f", "\\f");
125-
text = text.Replace("\n", "\\n");
126-
text = text.Replace("\r", "\\r");
127-
text = text.Replace("\t", "\\t");
128-
text = text.Replace("\v", "\\v");
129-
if (text.Length > 65533)
130-
text = text.Substring(0, 65533 - 5) + "[...]";
131-
return text;
132-
}
133-
134-
public Variable Variable
135-
{
136-
get
137-
{
138-
return m_Value;
139-
}
140-
set
141-
{
142-
if (m_Value == value) return;
143-
144-
m_Value = value;
145-
//this.NotifyModel();
146-
}
147-
}
11+
public abstract string Value { get; set; }
14812

149-
public override bool IsLeaf
150-
{
151-
get
152-
{
153-
if (m_Value == null)
154-
{
155-
return (this.Nodes.Count == 0);
156-
}
157-
return m_Value.getValue().getType() != VariableType_.MOVIECLIP && m_Value.getValue().getType() != VariableType_.OBJECT;
158-
}
159-
}
160-
161-
public bool IsEditing
162-
{
163-
get
164-
{
165-
return m_bEditing;
166-
}
167-
set
168-
{
169-
m_bEditing = value;
170-
}
171-
}
172-
173-
public DataNode(Variable value) : base(value.getName())
174-
{
175-
m_Value = value;
176-
}
177-
178-
public DataNode(string value) : base(value)
179-
{
180-
m_Value = null;
181-
}
182-
183-
}
184-
185-
internal static class NodeExtensions
186-
{
187-
public static String GetVariablePath(this Node node)
13+
public DataNode(string text) : base(text)
18814
{
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;
21015
}
21116

21217
}
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+
}

0 commit comments

Comments
 (0)