Author: fejj
Date: 2007-05-04 17:49:30 -0400 (Fri, 04 May 2007)
New Revision: 76727

Modified:
   trunk/monodevelop/Extras/CSharpBinding/ChangeLog
   trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
Log:
2007-05-04  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * Parser/CodeGenerator.cs (GetParameterNamePosition): Implemented.

        * Parser/Resolver.cs (GetMethod): Check if the cursor is within the
        declaration bounds as well, so that parameter searching works.



Modified: trunk/monodevelop/Extras/CSharpBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-05-04 20:59:04 UTC 
(rev 76726)
+++ trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-05-04 21:49:30 UTC 
(rev 76727)
@@ -1,5 +1,7 @@
 2007-05-04  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
+       * Parser/CodeGenerator.cs (GetParameterNamePosition): Implemented.
+
        * Parser/Resolver.cs (GetMethod): Check if the cursor is within the
        declaration bounds as well, so that parameter searching works.
 

Modified: trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs      
2007-05-04 20:59:04 UTC (rev 76726)
+++ trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs      
2007-05-04 21:49:30 UTC (rev 76727)
@@ -105,20 +105,55 @@
                
                protected override int GetVariableNamePosition 
(IEditableTextFile file, LocalVariable var)
                {
-                       int pos1 = file.GetPositionFromLineColumn 
(var.Region.BeginLine, var.Region.BeginColumn);
-                       int pos2 = file.GetPositionFromLineColumn 
(var.Region.EndLine, var.Region.EndColumn);
-                       string txt = file.GetText (pos1, pos2);
+                       int begin = file.GetPositionFromLineColumn 
(var.Region.BeginLine, var.Region.BeginColumn);
+                       int end = file.GetPositionFromLineColumn 
(var.Region.EndLine, var.Region.EndColumn);
+                       string txt = file.GetText (begin, end);
                        
                        int i = txt.IndexOf ('=');
-                       if (i == -1) i = txt.Length;
-                       int p = txt.LastIndexOf (var.Name, i);
-                       if (p == -1) return -1;
-                       return pos1 + p;
+                       if (i == -1)
+                               i = txt.Length;
+                       
+                       int pos = txt.LastIndexOf (var.Name, i);
+                       if (pos == -1)
+                               return -1;
+                       
+                       return begin + pos;
                }
                
                protected override int GetParameterNamePosition 
(IEditableTextFile file, IMethod method, IParameter param)
                {
-                       // FIXME: implement me
+                       int begin = file.GetPositionFromLineColumn 
(method.Region.BeginLine, method.Region.BeginColumn);
+                       int end = file.GetPositionFromLineColumn 
(method.Region.EndLine, method.Region.EndColumn);
+                       string txt = file.GetText (begin, end);
+                       int open, close, i, j;
+                       
+                       Console.WriteLine ("Searching for param '{0}' in 
'{1}'", param.Name, txt);
+                       
+                       if ((open = txt.IndexOf ('(')) == -1)
+                               return -1;
+                       
+                       if ((close = txt.LastIndexOf (')')) == -1)
+                               return -1;
+                       
+                       open++;
+                       
+                       while (open < close) {
+                               if ((i = txt.IndexOf (param.Name, open)) == -1)
+                                       return -1;
+                               
+                               if (!Char.IsWhiteSpace (txt[i - 1]))
+                                       return -1;
+                               
+                               j = i + param.Name.Length;
+                               if (j == close || Char.IsWhiteSpace (txt[j]) || 
txt[j] == ',')
+                                       return begin + i;
+                               
+                               if ((open = txt.IndexOf (',', i)) == -1)
+                                       return -1;
+                               
+                               open++;
+                       }
+                       
                        return -1;
                }
                

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to