[svn] r7436: nemerle/trunk/ncc/parsing/ParseTree.n vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completi...

IT svnadmin at nemerle.org
Fri Feb 16 05:31:33 CET 2007


Log:
Working on ExprFinder.

Author: IT
Date: Fri Feb 16 05:31:28 2007
New Revision: 7436

Modified:
   nemerle/trunk/ncc/parsing/ParseTree.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n

Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n	(original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n	Fri Feb 16 05:31:28 2007
@@ -27,7 +27,6 @@
  */
 
 using Nemerle.Compiler;
-using Nemerle.Compiler.Parsetree;
 using Nemerle.Utility;
 
 namespace Nemerle.Compiler.Parsetree
@@ -583,6 +582,11 @@
   {
     public header : Fun_header;
     public mutable body : PExpr;
+
+    public Location : Location
+    {
+      get { header.Location.Combine(body.Location) }
+    }
   }
 
   [Record]
@@ -597,6 +601,18 @@
     public body : PExpr;
     public mutable disable_warnings : bool;
 
+    public Location : Location
+    {
+      get
+      {
+        mutable loc = body.Location;
+
+        patterns.Iter(p => loc = loc.Combine(p.Location));
+
+        loc;
+      }
+    }
+
     public override ToString () : string
     {
       $"| $(patterns.ToString(\" | \")) => $body"
@@ -627,6 +643,26 @@
     | EventBuilder     { body : Compiler.EventBuilder; }
     | ParameterBuilder { body : Typedtree.Fun_parm; }
 
+    public Location : Location {
+      get {
+        match (this) {
+          | Expression       (body : Located)
+          | Parameter        (body : Located)
+          | TType            (body : Located)
+          | ClassMember      (body : Located)
+          | ParameterBuilder (body : Located)       => body.Location;
+          | FieldBuilder     (body : MemberBuilder)
+          | MethodBuilder    (body : MemberBuilder)
+          | PropertyBuilder  (body : MemberBuilder)
+          | EventBuilder     (body : MemberBuilder) => body.Location;
+          | MatchCase        (body)                 => body.Location;
+          | Function         (body)                 => body.Location;
+          | RawToken         (body)                 => body.Location;
+          | TypeBuilder      (body)                 => body.Location;
+        }
+      }
+    }
+
     public override ToString () : string {
       match (this) {
         | SyntaxElement.Expression (null) => ""

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	Fri Feb 16 05:31:28 2007
@@ -106,9 +106,14 @@
 
           _texprObject = match (_texprObject)
           {
+          | Pattern.Application    (name, _) =>
+
+            def dt = name.DeclaringType;
+          if (dt != null && dt.Name == _pexprObject.ToString()) dt else name : object
+
+          | Pattern.As             (_, decl)        when IsInEx(decl.NameLocation) => decl;
           | TExpr.DefValIn         (name, _, _)     when IsInEx(name.NameLocation) => setloc(name, name.NameLocation);
           | TExpr.TypeConversion   (_, ty, _, tloc) when IsInEx(tloc)              => setloc(ty,   tloc);
-          | Pattern.As             (_, decl)        when IsInEx(decl.NameLocation) => decl;
           | parm is T.Fun_parm      => parm.decl;
           | TExpr.ConstantObjectRef(_, o)
           | TExpr.StaticPropertyRef(_, o)

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	Fri Feb 16 05:31:28 2007
@@ -268,7 +268,17 @@
         | Lambda          (decl)   => Go(decl);       // { decl : Function_decl; }
         | Try             (b, cs)  => Go(b); Go(cs);  // { body : PExpr; cases : list [TryCase]; }
         | Quoted          (el)     => Go(el);         // { body : SyntaxElement; }
-        | MacroCall  (_, _, parms) => Go(parms);      // { name : Name; ns : NamespaceTree.Node; parms : list [SyntaxElement]; }
+        | MacroCall  (_, _, parms) =>                 // { name : Name; ns : NamespaceTree.Node; parms : list [SyntaxElement]; }
+
+          Go(parms.Sort((p1, p2) =>
+          {
+            match (p1.Location.Line - p2.Location.Line)
+            {
+            | p when p < 0 => -1
+            | 0            => p1.Location.Column - p2.Location.Column
+            | _            =>  1
+            }
+          }));
         }
 
         _info.Pop();

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	Fri Feb 16 05:31:28 2007
@@ -2,10 +2,30 @@
 
 namespace QtTest
 {
+  variant MyVar
+  {
+  | Op1
+  | Op2
+  }
+
   public class Class1
   {
-    MatchTest(sss : string) : void
+    DoTest()
     {
+      mutable foo = 0;
+      do {
+        foo /*017:-2*/+= 100;
+      } while (foo < 1000);
+    }
+
+    MatchTest(sss : string, myvar : MyVar) : void
+    {
+      match (myvar)
+      {
+      | Op1 /*016:-2*/=> ()
+      | Op2 => ()
+      }
+
       def chk (x, n) { x == n }
       match (sss.Length)
       {

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 Feb 16 05:31:28 2007
@@ -38,6 +38,8 @@
           Assert.AreEqual(len, result.ColEnd - result.ColStart);
       }
 
+      test("017", 3, "foo");
+      test("016", 3, "Op1");
       test("015", 3, "chk");
       test("014", 2, "xx");
       test("013", 2, "xx");



More information about the svn mailing list