[svn] r6630: vs-plugin/trunk: ConsoleTest/Program.cs Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Eng...

VladD2 svnadmin at nemerle.org
Fri Sep 8 12:24:57 CEST 2006


Log:
1. Add test (hint in method with implicit matching).
2. Fix parsing method body which contains implicit match.

Author: VladD2
Date: Fri Sep  8 12:24:49 2006
New Revision: 6630

Modified:
   vs-plugin/trunk/ConsoleTest/Program.cs
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n

Modified: vs-plugin/trunk/ConsoleTest/Program.cs
==============================================================================
--- vs-plugin/trunk/ConsoleTest/Program.cs	(original)
+++ vs-plugin/trunk/ConsoleTest/Program.cs	Fri Sep  8 12:24:49 2006
@@ -12,6 +12,7 @@
 			Test1 test = new Test1();
 			test.Init();
 
+			test.Hint_in_body_of_implicit_match();
 			test.Overload1();
 			test.QuickTip_ClassExtension();
 			test.Complete_generic_type_cast();

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n	Fri Sep  8 12:24:49 2006
@@ -129,7 +129,7 @@
     }
 
     public RunCompletionEngine (
-      [NotNull] observedMethod   : MethodBuilder, 
+      [NotNull] method   : MethodBuilder, 
       [NotNull] content          : string,
       mutable completionPosition : int
     ) : CompletionResult
@@ -152,7 +152,6 @@
             content;
 
         mutable completionList = null;
-        def env = observedMethod.DeclaringType.GlobalEnv;
 
         def content = if (completionPosition == content.Length)
           content + " " else content;
@@ -160,10 +159,8 @@
         def lexer = LexerCompletion (this, content, completionPosition);
         try
         {
-          observedMethod.GetHeader().body = 
-            FunBody.Parsed (MainParser.ParseExpr (env, lexer, true));
-    
-          observedMethod.RunBodyTyper ();
+          _ = ParseMethodBody(method, lexer);
+          method.RunBodyTyper ();
         }
         catch
         {
@@ -176,25 +173,29 @@
         completionList
     }
 
+    private ParseMethodBody(method : MethodBuilder, lexer : LexerBase) : FunBody.Parsed
+    {
+      def env = method.DeclaringType.GlobalEnv;
+      def header = method.GetHeader();
+      def body = FunBody.Parsed(MainParser.ParseExpr(env, lexer, method.ParsedFunction.header));
+      header.body = body;
+      body
+    }
+
     public CompileMethod(
       /*[NotNull]*/ method   : MethodBuilder,
       /*[NotNull]*/ content  : string,
-                    location : Location)
-    : (FunBody.Parsed * FunBody.Typed * Exception)
+                    location : Location
+    ) : (FunBody.Parsed * FunBody.Typed * Exception)
     {
         ClearCompilerMessages();
         _isInCompletionMode = true;
 
-        mutable pBody : FunBody.Parsed = null;
         mutable tBody : FunBody.Typed  = null;
         mutable ex    : Exception      = null;
 
-        def env   = method.DeclaringType.GlobalEnv;
         def lexer = LexerString(this, content, location);
-
-        method.GetHeader().body = FunBody.Parsed(MainParser.ParseExpr(env, lexer, true));
-
-        pBody = method.GetHeader().body :> FunBody.Parsed;
+        def pBody = ParseMethodBody(method, lexer);
 
         when (pBody.expr != null)
         {

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n	Fri Sep  8 12:24:49 2006
@@ -84,6 +84,12 @@
 		      def b = a : System.Collections.Generic.IL/*Complete generic type cast:-0*/;
         }
 
+        public Method11(pattern : TestVariant1) : string
+        {
+          | Aaa/*Hint in body of implicit match:-1*/ => "Aaa"
+          | Bbb => "Bbb"
+        }
+
         xxx : TestVariant2;
       }
     }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	Fri Sep  8 12:24:49 2006
@@ -13,6 +13,17 @@
   [TestFixture]
   public partial class Test1
   {
+    public Hint_in_body_of_implicit_match() : void
+    {
+      def file = FilePath1;
+      def (line, col) = ReadLocation(file, "Hint in body of implicit match");
+      def result = _project.GetQuickTipInfo(file, line, col, GetTextFromFile(file, _, _, _, _));
+
+      Assert.IsNotNull(result, "result is null");
+      //WriteLine(result.Text);
+      Assert.AreEqual (result.Text.Split('\n')[0], "internal sealed variant option TestVariant1.Aaa");
+    }
+
     [Test]
     public Overload1() : void
     {



More information about the svn mailing list