View unanswered posts | View active topics



Reply to topic  [ 7 posts ] 
Inspect static properties and fields 
Author Message
Member

Joined: Thu Feb 02, 2012 5:59 pm
Posts: 78
Location: Alabama
Reply with quote
As part of my daily work, I deal with a lot of Model classes that expose static fields and properties.

I wanted to be able to inspect those while debugging which is what this patch enables.

Code:
Index: Debugger/ExpressionContext.cs
===================================================================
--- Debugger/ExpressionContext.cs   (revision 2205)
+++ Debugger/ExpressionContext.cs   (working copy)
@@ -3,6 +3,10 @@
 using flash.tools.debugger;
 using flash.tools.debugger.expression;
 using flash.tools.debugger.concrete;
+using ASCompletion.Model;
+using ASCompletion.Completion;
+using ASCompletion.Context;
+using System.Collections.Generic;
 
 namespace FlashDebugger
 {
@@ -76,11 +80,39 @@
                 {
                     if (v.getName().Equals(par0)) return (java.lang.Object)v;
                 }
+                var fullClassName = findClassName((java.lang.String)par0);
+                if (null != fullClassName)
+                {
+                    return (java.lang.Object)session.getGlobal(new java.lang.String(fullClassName));
+                }
             }
             throw new NoSuchVariableException(par0);
             //Value_.UNDEFINED;
         }
 
+        public string findClassName(java.lang.String className)
+        {
+            string endOfClassName = "." + className;
+            MemberList knownClasses = ASContext.Context.GetAllProjectClasses();
+
+            string prev = null;
+            FlagType mask = FlagType.Class | FlagType.Interface | FlagType.Enum;
+            foreach (MemberModel member in knownClasses)
+            {
+                if ((member.Flags & mask) == 0 || prev == member.Name)
+                    if (member.Type != "Class") continue;
+
+                prev = member.Name;
+
+                if (member.Name.EndsWith(endOfClassName))
+                {
+                    var lastPos = member.Name.LastIndexOf('.');
+                    return member.Name.Substring(0, lastPos) + "::" + className;
+                }
+            }
+            return null;
+        }
+
         public java.lang.Object lookupMembers(java.lang.Object par0)
         {
             java.lang.String name = "?";



Fri Feb 03, 2012 9:40 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Big big thank you for this patch, this was very annoying :)
Checked and committed.


Sat Feb 04, 2012 10:41 am
Profile WWW
Member

Joined: Thu Feb 02, 2012 5:59 pm
Posts: 78
Location: Alabama
Reply with quote
Now that I know a little more about your API, I changed the fullClassName lookup to loop through the import statements within the CurrentModel instead of looking at all classes in the project.

Code:
Index: Debugger/ExpressionContext.cs
===================================================================
--- Debugger/ExpressionContext.cs   (revision 2206)
+++ Debugger/ExpressionContext.cs   (working copy)
@@ -93,21 +93,18 @@
         public string findClassName(java.lang.String className)
         {
             string endOfClassName = "." + className;
-            MemberList knownClasses = ASContext.Context.GetAllProjectClasses();
-
-            string prev = null;
             FlagType mask = FlagType.Class | FlagType.Interface | FlagType.Enum;
-            foreach (MemberModel member in knownClasses)
+
+            MemberList imports = ASContext.Context.CurrentModel.Imports;
+            foreach (MemberModel member in imports)
             {
-                if ((member.Flags & mask) == 0 || prev == member.Name)
-                    if (member.Type != "Class") continue;
+                if ((member.Flags & mask) == 0)
+                    continue;
 
-                prev = member.Name;
-
-                if (member.Name.EndsWith(endOfClassName))
+                if (member.Type.EndsWith(endOfClassName))
                 {
-                    var lastPos = member.Name.LastIndexOf('.');
-                    return member.Name.Substring(0, lastPos) + "::" + className;
+                    var lastPos = member.Type.LastIndexOf('.');
+                    return member.Type.Substring(0, lastPos) + "::" + className;
                 }
             }
             return null;


Sat Feb 04, 2012 4:22 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
That's an idea, however imports can be .*
The solution is to use:
Code:
MemberList imports = ASContext.Context.ResolveImports(ASContext.Context.CurrentModel);

However this doesn't include global classes or classes from the same package, so you must actually do:
Code:
MemberList imports = ASContext.Context.GetVisibleExternalElements(true);

That's FYI, I'm finishing the code now that you pointed out the solution.


Sat Feb 04, 2012 6:39 pm
Profile WWW
Member

Joined: Thu Feb 02, 2012 5:59 pm
Posts: 78
Location: Alabama
Reply with quote
Great! I am looking forward to it. =)


Sat Feb 04, 2012 7:48 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Well it's committed already.


Sat Feb 04, 2012 8:22 pm
Profile WWW
Member

Joined: Mon Sep 27, 2010 8:30 pm
Posts: 38
Reply with quote
This is great news, but I am too lazy to build FD myself so I will wait for 4.0.2 :roll:


Sat Feb 04, 2012 10:29 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.