[svn] r6398: nemerle/trunk/ncc: testsuite/completion-playground/compl3.n typing/OverloadPossibility.n typi...

nazgul svnadmin at nemerle.org
Tue Jun 13 23:08:09 CEST 2006


Log:
Make local values appear in completion

Author: nazgul
Date: Tue Jun 13 23:08:06 2006
New Revision: 6398

Modified:
   nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
   nemerle/trunk/ncc/typing/OverloadPossibility.n
   nemerle/trunk/ncc/typing/Typer.n

Modified: nemerle/trunk/ncc/testsuite/completion-playground/compl3.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/completion-playground/compl3.n	(original)
+++ nemerle/trunk/ncc/testsuite/completion-playground/compl3.n	Tue Jun 13 23:08:06 2006
@@ -161,6 +161,9 @@
             else
               null;
             
+            if (overl is LocalValueCompletionPossibility)
+              WriteLine ($"    local value ==> $overl");
+            else
             WriteLine ($"    $(overl.Member.Name)  ==> $overl"
               " $(overl.Member.Attributes) Is extension method $isExtension $typ");
           }
@@ -175,19 +178,19 @@
 }
 
 //FixMe: Bugs
-try_completion (@"
-  def name = 1;
-  na?
-           ");
-try_completion ("def arr = array[1, 2, 3]; arr.M?");
+try_completion ("def arr = array[1, 2, 3]; arr.M?"); // this requires filtering out extension methods in Typer.n:2366  / NAZGUL 
 try_completion ("1.Map?");
 
 //TODO: Imlement this.
-try_completion (" ? ");
+try_completion (" ? ");           // this should yield running typer with PExpr.ToComplete (Name ("", ..)), it seems to crash on parsing  / NAZGUL 
 try_completion ("def _ = 0; ? ");
 
 
 // Work fine:
+try_completion (@"
+  def name = 1;
+  na?
+           ");
 try_completion ("Fo?");
 try_completion ("this.Fo?");
 try_completion (@"

Modified: nemerle/trunk/ncc/typing/OverloadPossibility.n
==============================================================================
--- nemerle/trunk/ncc/typing/OverloadPossibility.n	(original)
+++ nemerle/trunk/ncc/typing/OverloadPossibility.n	Tue Jun 13 23:08:06 2006
@@ -417,4 +417,11 @@
     }
 
   }
+  
+  [Record]
+  public class LocalValueCompletionPossibility : OverloadPossibility {
+    public Value : LocalValue;
+    
+    public override ToString () : string { Value.ToString () }
+  }
 }

Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n	(original)
+++ nemerle/trunk/ncc/typing/Typer.n	Tue Jun 13 23:08:06 2006
@@ -1367,9 +1367,16 @@
           throw compl_exc
 
         | PT.PExpr.ToComplete (name) =>
-          // FIXME: check locals first
           def overloads =
             TypeNameFull (expression, expected, for_completion = true);
+            
+          def overloads = local_context.Fold (overloads, fun (locname, x, acc) {
+            if (locname.Id.StartsWith (name.Id))
+              LocalValueCompletionPossibility (this, x.Type, null, null, current_method_builder, null, x) :: acc
+            else
+              acc
+          });
+            
           throw CompletionResult (overloads, name.Id)
 
           
@@ -2354,10 +2361,14 @@
         }
 
         foreach (meth in Manager.LibrariesManager.GetExtensionMethods (name.Id, name.GetEnv (env), false))//for_completion))
+        {
+          //when (possible_type != null && !possible_type.TryProvide (meth.GetParameters ().Head.ty))
+          //  Nemerle.Imperative.Continue ();
           foreach (over in ConstructMethodOverload (meth, maybe_varargs = true)) {
             over.ExtensionMethodObject = obj;
             res ::= over;
           }
+        }
 
         Some (res)
       }



More information about the svn mailing list