View unanswered posts | View active topics



Reply to topic  [ 2 posts ] 
Haxe method signature tooltip fix for functions 
Author Message
Member

Joined: Mon Sep 20, 2010 8:55 am
Posts: 92
Reply with quote
Here's a problem:
Image
Image
The method takes only 2 arguments, one is a callback.

Patch:
Code:
Index: External/Plugins/HaXeContext/Context.cs
===================================================================
--- External/Plugins/HaXeContext/Context.cs   (revision 2289)
+++ External/Plugins/HaXeContext/Context.cs   (working copy)
@@ -1073,7 +1073,7 @@
 
                 string type = al[1].ToString();
 
-                Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
+                Array types = splitTypes(type);
 
                 // Function's arguments
                 member.Parameters = new List<MemberModel>();
@@ -1096,6 +1096,34 @@
                         
             return member;
         }
+        string[] splitTypes(string type)
+        {
+            List<string> list = new List<string>();
+            StringReader reader = new StringReader(type);
+            int nested = 0;
+            char[] buffer = new char[1];
+            string temp = "";
+            while (reader.Read(buffer, 0, 1) > 0)
+            {
+                char c = buffer[0];
+                temp += c.ToString();
+                if (c == '(')
+                {
+                    nested++;
+                }
+                else if (nested > 0 && c == ')')
+                {
+                    nested--;
+                }
+                if (nested == 0 && temp.EndsWith("->"))
+                {
+                    list.Add(temp.Substring(0, temp.Length - 2));
+                    temp = "";
+                }
+            }
+            list.Add(temp);
+            return list.ToArray();
+        }
 
         void removeTip(ScintillaNet.ScintillaControl sender, int ch)
         {


Fixed:
Image


Thu May 17, 2012 8:58 am
Profile
Member

Joined: Mon Sep 20, 2010 8:55 am
Posts: 92
Reply with quote
Further improvements:

1. We need to separate function arguments from return values. Currently the last argument is the return value, which is incorrect. Possible implementations I can think of:
Code:
f:(Int, Bool -> Void)
f:(Int, Bool):Void


2. Try this code:
Code:
static function imap(a:Int->(Int->Void)->Void, b:Void->Int):Bool->Int->Float
{
   return null;
}
imap(|

It compiles, but you'll see incorrect tooltip:
Image
HaXeCompletion.cs::getList() is not being called in this example.


Thu May 17, 2012 9:06 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.