Skip to content

Commit 2384997

Browse files
committed
Added some error display when evaluating expressions
1 parent fb4621c commit 2384997

File tree

12 files changed

+71
-20
lines changed

12 files changed

+71
-20
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using PluginCore.Localization;
3+
using flash.tools.debugger.expression;
4+
5+
namespace FlashDebugger.Controls.DataTree
6+
{
7+
public class ErrorNode : DataNode
8+
{
9+
10+
private string _value;
11+
public override string Value
12+
{
13+
get { return _value; }
14+
set { throw new NotSupportedException(); }
15+
}
16+
17+
public override bool IsLeaf
18+
{
19+
get { return true; }
20+
}
21+
22+
public ErrorNode(string text, Exception ex)
23+
: base(text)
24+
{
25+
_value = ex.Message;
26+
}
27+
28+
}
29+
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ public override string Value
1515
set { throw new NotSupportedException(); }
1616
}
1717

18-
public ScalarNode(string text, string value)
19-
: base(text)
18+
public override bool IsLeaf
2019
{
21-
m_Value = value;
20+
get { return true; }
2221
}
2322

24-
public override bool IsLeaf
23+
public ScalarNode(string text, string value)
24+
: base(text)
2525
{
26-
get
27-
{
28-
return true;
29-
}
26+
m_Value = value;
3027
}
3128

3229
}

External/Plugins/FlashDebugger/Controls/DataTreeControl.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ void NameNodeTextBox_DrawText(object sender, DrawEventArgs e)
114114
try
115115
{
116116
if (e.Node.NextNode == null && e.Node.Level == 1 && !addingNewExpression)
117-
{
118117
e.Font = new Font(e.Font, FontStyle.Italic);
119-
}
118+
else if (e.Node.Tag is ErrorNode)
119+
e.TextColor = e.Node.IsSelected ? Color.White : Color.Gray;
120+
120121
}
121122
catch (Exception) { }
122123
}
@@ -248,12 +249,15 @@ void ValueNodeTextBox_DrawText(object sender, DrawEventArgs e)
248249
{
249250
try
250251
{
251-
VariableNode node = e.Node.Tag as VariableNode;
252-
FlashInterface flashInterface = PluginMain.debugManager.FlashInterface;
253-
if (node != null && node.Variable != null && node.Variable.hasValueChanged(flashInterface.Session))
252+
VariableNode variableNode = e.Node.Tag as VariableNode;
253+
if (variableNode != null)
254254
{
255-
e.TextColor = Color.Red;
255+
FlashInterface flashInterface = PluginMain.debugManager.FlashInterface;
256+
if (variableNode.Variable != null && variableNode.Variable.hasValueChanged(flashInterface.Session))
257+
e.TextColor = Color.Red;
256258
}
259+
else if (e.Node.Tag is ErrorNode)
260+
e.TextColor = e.Node.IsSelected ? Color.White : Color.Gray;
257261
}
258262
catch (NullReferenceException) { }
259263
}

External/Plugins/FlashDebugger/Controls/DataTreeModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private Node FindNode(Node root, string path, StringBuilder nodePath)
3333
int initialLength = nodePath.Length;
3434
foreach (Node node in root.Nodes)
3535
{
36-
nodePath = nodePath.Append(node.Text);
36+
nodePath.Append(node.Text);
3737
if (path == nodePath.ToString()) return node;
3838
nodePath.Append(".");
3939
if (path.StartsWith(nodePath.ToString()))

External/Plugins/FlashDebugger/Controls/WatchUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ public void UpdateElements()
102102
node = new ScalarNode(item, obj.toString());
103103
node.Tag = item;
104104
}
105-
catch
105+
catch (Exception ex)
106106
{
107-
node = new ValueNode(item);
107+
node = new ErrorNode(item, ex);
108108
}
109109
node.Text = item;
110110
treeControl.AddNode(node);

External/Plugins/FlashDebugger/Debugger/ExpressionContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void assign(java.lang.Object par0, Value par1)
4040
throw new NotSupportedException(TextHelper.GetString("Error.NoScalar"));
4141
}
4242
else
43-
throw new NoSuchVariableException(par0);
43+
throw new NoSuchVariableException(String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
4444
}
4545

4646
public Context createContext(java.lang.Object par0)
@@ -73,7 +73,7 @@ public java.lang.Object lookup(java.lang.Object par0)
7373
{
7474
if (v.getName().Equals(par0)) return (java.lang.Object)v;
7575
}
76-
throw new NoSuchVariableException(par0);
76+
throw new NoSuchVariableException(String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
7777
}
7878

7979
if ((java.lang.String)par0 == "this")
@@ -105,7 +105,7 @@ public java.lang.Object lookup(java.lang.Object par0)
105105
return (java.lang.Object)session.getGlobal(new java.lang.String(fullClassName));
106106
}
107107
}
108-
throw new NoSuchVariableException(par0);
108+
throw new NoSuchVariableException(String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
109109
//Value_.UNDEFINED;
110110
}
111111

External/Plugins/FlashDebugger/FlashDebugger.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
<ItemGroup>
100100
<Compile Include="Controls\DataTree\ContinuedDataNode.cs" />
101101
<Compile Include="Controls\DataTree\DataNode.cs" />
102+
<Compile Include="Controls\DataTree\ErrorNode.cs" />
102103
<Compile Include="Controls\DataTree\ScalarNode.cs" />
103104
<Compile Include="Controls\DataTree\ValueNode.cs" />
104105
<Compile Include="Controls\DataTree\VariableNode.cs" />

PluginCore/PluginCore/Resources/de_DE.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,10 @@ Bitte bedenken Sie, dass Sie viele Projektoptionen nicht mehr nutzen können, so
35433543
<value>Variable could not be reevaluated</value>
35443544
<comment>Added after 4.7.0</comment>
35453545
</data>
3546+
<data name="FlashDebugger.Error.NoSuchVariable" xml:space="preserve">
3547+
<value>{0} could not be resolved</value>
3548+
<comment>Added after 4.7.1</comment>
3549+
</data>
35463550
<data name="FlashDebugger.Error.NoScalar" xml:space="preserve">
35473551
<value>Only scalar variables can be modified</value>
35483552
<comment>Added after 4.7.0</comment>

PluginCore/PluginCore/Resources/en_US.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,10 @@ Please note that with injection enabled, you will not be able to use many projec
35483548
<value>Variable could not be reevaluated</value>
35493549
<comment>Added after 4.7.0</comment>
35503550
</data>
3551+
<data name="FlashDebugger.Error.NoSuchVariable" xml:space="preserve">
3552+
<value>{0} could not be resolved</value>
3553+
<comment>Added after 4.7.1</comment>
3554+
</data>
35513555
<data name="FlashDebugger.Error.NoScalar" xml:space="preserve">
35523556
<value>Only scalar variables can be modified</value>
35533557
<comment>Added after 4.7.0</comment>

PluginCore/PluginCore/Resources/eu_ES.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,10 @@ Kontutan izan injekzioa gaituz gero, ezin izanen diren proiektuaren hainbat auke
35353535
<value>Variable could not be reevaluated</value>
35363536
<comment>Added after 4.7.0</comment>
35373537
</data>
3538+
<data name="FlashDebugger.Error.NoSuchVariable" xml:space="preserve">
3539+
<value>{0} could not be resolved</value>
3540+
<comment>Added after 4.7.1</comment>
3541+
</data>
35383542
<data name="FlashDebugger.Error.NoScalar" xml:space="preserve">
35393543
<value>Only scalar variables can be modified</value>
35403544
<comment>Added after 4.7.0</comment>

0 commit comments

Comments
 (0)