1
1
using System ;
2
2
using flash . tools . debugger ;
3
3
using Double = java . lang . Double ;
4
+ using System . Text ;
4
5
5
6
namespace FlashDebugger . Controls . DataTree
6
7
{
@@ -34,20 +35,18 @@ public override string Value
34
35
string temp = null ;
35
36
if ( type == VariableType_ . MOVIECLIP || type == VariableType_ . OBJECT )
36
37
{
37
- string typeStr = "" ;
38
+ string typeStr = m_Value . getTypeName ( ) . ToString ( ) ;
39
+ // rename vector
40
+ typeStr = typeStr . Replace ( "__AS3__.vec::Vector.<" , "Vector.<" ) ;
38
41
if ( HideFullClasspath )
39
42
{
40
43
// return class type without classpath
41
- string typeName = m_Value . getTypeName ( ) . ToString ( ) ;
42
- if ( typeName . StartsWith ( "__AS3__.vec::Vector.<" ) || typeName . StartsWith ( "Vector.<" ) )
43
- typeStr = "Vector.<" + typeName . AfterLast ( "::" , true ) ;
44
- else
45
- typeStr = typeName . After ( "::" , 0 , true ) . Replace ( "::" , "." ) ;
44
+ typeStr = CleanTypeClassPaths ( typeStr ) ;
46
45
}
47
46
else
48
47
{
49
48
// return class type with classpath
50
- typeStr = m_Value . getTypeName ( ) . ToString ( ) . Replace ( "::" , "." ) ;
49
+ typeStr = typeStr . Replace ( "::" , "." ) ;
51
50
}
52
51
53
52
// show / hide IDs
@@ -59,12 +58,6 @@ public override string Value
59
58
typeStr = typeStr . Replace ( "[]" , "Array" ) ;
60
59
}
61
60
62
- // rename vector
63
- else if ( typeStr . StartsWith ( "__AS3__.vec.Vector.<" ) )
64
- {
65
- typeStr = typeStr . Replace ( "__AS3__.vec.Vector.<" , "Vector.<" ) ;
66
- }
67
-
68
61
return typeStr ;
69
62
}
70
63
else if ( type == VariableType_ . NUMBER )
@@ -206,24 +199,6 @@ public bool IsPrimitive
206
199
}
207
200
}
208
201
209
-
210
- private string Escape ( string text )
211
- {
212
- text = text . Replace ( "\\ " , "\\ \\ " ) ;
213
- text = text . Replace ( "\" " , "\\ \" " ) ;
214
- text = text . Replace ( "\0 " , "\\ 0" ) ;
215
- text = text . Replace ( "\a " , "\\ a" ) ;
216
- text = text . Replace ( "\b " , "\\ b" ) ;
217
- text = text . Replace ( "\f " , "\\ f" ) ;
218
- text = text . Replace ( "\n " , "\\ n" ) ;
219
- text = text . Replace ( "\r " , "\\ r" ) ;
220
- text = text . Replace ( "\t " , "\\ t" ) ;
221
- text = text . Replace ( "\v " , "\\ v" ) ;
222
- if ( text . Length > 65533 )
223
- text = text . Substring ( 0 , 65533 - 5 ) + "[...]" ;
224
- return text ;
225
- }
226
-
227
202
public Value PlayerValue
228
203
{
229
204
get
@@ -274,6 +249,67 @@ public ValueNode(string text, Value value)
274
249
m_Value = value ;
275
250
}
276
251
252
+ internal static string Escape ( string text )
253
+ {
254
+ text = text . Replace ( "\\ " , "\\ \\ " ) ;
255
+ text = text . Replace ( "\" " , "\\ \" " ) ;
256
+ text = text . Replace ( "\0 " , "\\ 0" ) ;
257
+ text = text . Replace ( "\a " , "\\ a" ) ;
258
+ text = text . Replace ( "\b " , "\\ b" ) ;
259
+ text = text . Replace ( "\f " , "\\ f" ) ;
260
+ text = text . Replace ( "\n " , "\\ n" ) ;
261
+ text = text . Replace ( "\r " , "\\ r" ) ;
262
+ text = text . Replace ( "\t " , "\\ t" ) ;
263
+ text = text . Replace ( "\v " , "\\ v" ) ;
264
+ if ( text . Length > 65533 )
265
+ text = text . Substring ( 0 , 65533 - 5 ) + "[...]" ;
266
+ return text ;
267
+ }
268
+
269
+ /// <summary>
270
+ /// Removes any class path from a fully qualified name. Eg.: flash.display::Sprite becomes Sprite
271
+ /// </summary>
272
+ /// <param name="qualifiedName">The fully qualified name to clean</param>
273
+ /// <returns>The class name with no class paths</returns>
274
+ internal static string CleanTypeClassPaths ( string qualifiedName )
275
+ {
276
+ char [ ] delims = { ',' , ' ' , '<' , '>' } ;
277
+ var buffer = new StringBuilder ( ) ;
278
+ bool inPackage = false ;
279
+
280
+ /**
281
+ In order to strip the class-path we are going to traverse the class type in
282
+ reverse so we don't need to keep extra buffers or use complex splitting or regexes.
283
+ Packages are always separated by colons or dots, so the first time we found one we
284
+ are on the package (watch out with Vector.<> notation), and the whole type is always
285
+ together, so any delim means that we finished with the type, and since this comes
286
+ from the debugger we know that we are not going to find any other type delimiter,
287
+ or incomplete/wrong case. We could check for Char.IsWhiteSpace for other uses.
288
+ In resume, with this method we could support without much problem even complex cases like:
289
+ Collections.Generic.Dictionary<Collections.Generic.Dictionary<String, Test.CustomClassKey>, Collections.Generic.List<Test.CustomClass>>
290
+ */
291
+ for ( int i = qualifiedName . Length - 1 ; i >= 0 ; i -- )
292
+ {
293
+ char c = qualifiedName [ i ] ;
294
+
295
+ if ( inPackage )
296
+ {
297
+ if ( Array . IndexOf ( delims , c ) < 0 )
298
+ continue ;
299
+
300
+ inPackage = false ;
301
+ }
302
+ else if ( ( c == '.' && qualifiedName [ i + 1 ] != '<' ) || c == ':' )
303
+ {
304
+ inPackage = true ;
305
+ continue ;
306
+ }
307
+
308
+ buffer . Insert ( 0 , c ) ;
309
+ }
310
+
311
+ return buffer . ToString ( ) ;
312
+ }
277
313
}
278
314
279
315
}
0 commit comments