[svn] r7432: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2: CodeModel/Project.Refactoring.n C...

phantom svnadmin at nemerle.org
Thu Feb 15 17:56:19 CET 2007


Log:
Tests addendum & refactoring.

Author: phantom
Date: Thu Feb 15 17:56:16 2007
New Revision: 7432

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n	Thu Feb 15 17:56:16 2007
@@ -66,6 +66,38 @@
       }
     }
 
+    private GetDefinitionInsideType(typeDecl : Decl.Type, fileIndex : int, line : int, column : int) : list [GotoInfo]
+    {
+      def (_, _, tObj) = FindObject(typeDecl, fileIndex, line, column);
+
+      def getTypeGotoInfo(tv) 
+      {
+        | MType.Class(ty is TypeBuilder, _) => ty.AstParts.Map(p => GotoInfo(p.name.Location));
+        | MType.Class(ty, _)                => [GotoInfo(ty)]
+        | _                                 => []
+      }
+
+      match (tObj)
+      {
+        | me is TExpr.MacroEnvelope         => [GotoInfo(me)]
+        | lv is LocalValue                  => [GotoInfo(lv)]
+        | tc is TExpr.ImplicitValueTypeCtor => getTypeGotoInfo(tc.ty)
+        | tv is TyVar                       => getTypeGotoInfo(tv)
+        | mb is MethodBuilder               =>
+          if (mb.Name == ".ctor" && mb.Ast.name.Location.IsGenerated)
+            mb.DeclaringType.AstParts.Map(GotoInfo);
+          else
+            [GotoInfo(mb)]
+
+        // This code should be used instead of the code above.
+        // | mb is MethodBuilder when mb.Name == ".ctor" && mb.Ast.name.Location.IsGenerated with tb = mb.DeclaringType
+        | tb is TypeBuilder                 => tb.AstParts.Map(GotoInfo);
+        | fh is Typedtree.Fun_header        => [GotoInfo(fh)]
+        | m  is IMember                     => [GotoInfo(m)]
+        | p  is Pattern.Enum                => [GotoInfo(p.fld)]
+        | _                                 => []
+      }
+    }
 
     // TODO: implement get usages behaviour, this is a stub yet
     // Примерное описание алгоритма поиска члена класса:

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n	Thu Feb 15 17:56:16 2007
@@ -285,46 +285,6 @@
       }
     }
 
-    private GetDefinitionInsideType(
-      typeDecl  : Decl.Type,
-      fileIndex : int,
-      line      : int,
-      col       : int
-    )
-      : list [GotoInfo]
-    {
-      def (_, _, tObj) = FindObject(typeDecl, fileIndex, line, col);
-
-      def getTypeGotoInfo(tv) 
-      {
-      | MType.Class(ty is TypeBuilder, _) => ty.AstParts.Map(p => GotoInfo(p.name.Location));
-      | MType.Class(ty, _)                => [GotoInfo(ty)]
-      | _                                 => []
-      }
-
-      match (tObj)
-      {
-      | me is TExpr.MacroEnvelope         => [GotoInfo(me)]
-      | lv is LocalValue                  => [GotoInfo(lv)]
-      | tc is TExpr.ImplicitValueTypeCtor => getTypeGotoInfo(tc.ty)
-      | tv is TyVar                       => getTypeGotoInfo(tv)
-      | mb is MethodBuilder               =>
-
-        if (mb.Name == ".ctor" && mb.Ast.name.Location.IsGenerated)
-          mb.DeclaringType.AstParts.Map(GotoInfo);
-        else
-          [GotoInfo(mb)]
-
-      // This code should be used instead of the code above.
-      // | mb is MethodBuilder when mb.Name == ".ctor" && mb.Ast.name.Location.IsGenerated with tb = mb.DeclaringType
-      | tb is TypeBuilder                 => tb.AstParts.Map(GotoInfo);
-      | fh is Typedtree.Fun_header        => [GotoInfo(fh)]
-      | m  is IMember                     => [GotoInfo(m)]
-      | p  is Pattern.Enum                => [GotoInfo(p.fld)]
-      | _                                 => []
-      }
-    }
-
     GetMethodTip(
       typeDecl  : Decl.Type,
       fileIndex : int,

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n	Thu Feb 15 17:56:16 2007
@@ -18,7 +18,7 @@
 {
   public class TestRunner
   {
-    public stopAfterFirstFailedTest = false;
+    public stopAfterFirstFailedTest = true;
     
     skipTestProjects : list[string] = []; // neglect some projects for a while
     
@@ -31,7 +31,7 @@
     {
       def suite = FindDefinitionTestProjectTwo();
       suite.SetUp();
-      suite.Test030();
+      suite.Test036();
     }
 
     public static Explode(this s : string, delimiter : string) : list[string]
@@ -293,13 +293,11 @@
         def name = starter.Substring(starter.IndexOf('}') + 1).Trim();
         def position = line.IndexOf(name);
         def location = Location(declaration.File, declaration.Line, position, declaration.Line, position + name.Length);
-        WriteLine($"\nSearching for usages of '$name' (test case: $testCase, location: $location)... ");
+        def findings = if (alsoUsages) "definitions and usages" else "definitions";
+        WriteLine($"\nSearching for $findings of '$name' (test case: $testCase, location: $location)... ");
         // TODO: find multiple declarations (partial classes)
         mutable shouldFindRing = MakeUsage(line, declaration, name, starter) ::
           ScanSources(checkPhrase, testCase).Map((line, _, location, _) => MakeUsage(line, location, name, checkPhrase));
-        unless (alsoUsages)
-          shouldFindRing = shouldFindRing.Filter(usage => usage.UsageType == UsageType.Definition);
-        def findings = if (alsoUsages) "definitions and usages" else "definitions";
         Write($"\n Should find $(shouldFindRing.Length) $findings... ");
         def foundMultiple =
           shouldFindRing.Map(goto =>
@@ -323,11 +321,13 @@
             {
               | _ => false
             };
-          when (stopAfterFirstFailedTest)
+          when (stopAfterFirstFailedTest && alsoUsages)
             Assert.IsTrue(coincide, warning);
           ring
         });
-        Write($"found $(found.Length) usages, checking for correspondance... ");
+        Write($"found $(found.Length) $findings, checking for correspondance... ");
+        unless (alsoUsages)
+          shouldFindRing = shouldFindRing.Filter(usage => usage.UsageType == UsageType.Definition);
         def success = FoundUsagesAreRight(testCase, shouldFindRing, found); // put breakpoint here to see what usages are actually found
         def message = if (success) "ok" else "incorrect!.. saving changes...";
         WriteLine(message);

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n	Thu Feb 15 17:56:16 2007
@@ -15,5 +15,27 @@
       foo += bar; // usage {30} // usage {31}
       WriteLine(bar); // usage {31}
     }
+    
+    public NamesOverlap() : void
+    {
+      def foo = 1; // definition {32} foo
+      _ = foo;
+      def foo = 2; // definition {33} foo
+      _ = foo + foo - foo;
+      mutable bar = 1; // definition {34} bar
+      while (bar < 10)
+      {
+        def foo = bar + 1; // definition {35} foo
+        bar = foo + 1;
+      }
+    }
+    
+    public DoWhileMacro() : void
+    {
+			mutable foo = 0;  // definition {36} foo
+			do {
+				foo += 100; // usage {36}
+			} while (foo < 1000); // usage {36}
+    }
   }
 }
\ No newline at end of file



More information about the svn mailing list