[svn]
r7457: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2:
CodeModel/Static.Analysis.n Tests...
phantom
svnadmin at nemerle.org
Wed Feb 21 17:11:03 CET 2007
Log:
FindUsages refactoring.
Author: phantom
Date: Wed Feb 21 17:11:01 2007
New Revision: 7457
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Static.Analysis.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/Static.Analysis.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Static.Analysis.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Static.Analysis.n Wed Feb 21 17:11:01 2007
@@ -12,19 +12,19 @@
using Nemerle.Logging;
[assembly: LogFunction(Debug.WriteLine)]
-#if phantom
+//#if phantom
[assembly: LogFlag(phantom, true)]
-#else
- [assembly: LogFlag(phantom, false)]
-#endif
+//#else
+ //[assembly: LogFlag(phantom, false)]
+//#endif
namespace Nemerle.Completion2
{
public class Analyser
{
mutable localValue : LocalValue;
- mutable definitionBlock : TExpr.DefValIn;
mutable localValueEntries : list[GotoInfo];
+ mutable definitionBlock : TExpr.DefValIn;
mutable definitionFound : bool;
public FindLocalValueEntries(expressionRoot : TExpr, localValue : LocalValue) : list[GotoInfo]
@@ -74,40 +74,27 @@
def node = exprWalkInfo.Node;
log(phantom, $"processing node: $(node.ToString().Brief())");
log(phantom, $" type: $(node.GetType())");
- when (node is TExpr)
- {
- def node = node :> TExpr;
- if (definitionBlock != null)
- {
// TODO: enable this after locations of DefValIn will be fixed
- //if (node.Location.StartsAfterEndOf(definitionBlock.Location))
- //exprWalkInfo.Stop();
- //else
+ //if (node.Location.StartsAfterEndOf(definitionBlock.Location)) exprWalkInfo.Stop();
+ if (definitionFound)
match (node)
{
- | LocalRef(referencedLocalValue) =>
- when (referencedLocalValue.Equals(localValue))
- {
- log(phantom, $" it's a reference!");
- localValueEntries ::= GotoInfo(node.Location, UsageType.Usage);
- }
- | _ => log(phantom, $" skipping...");
- }
- }
- else if (node is TExpr.DefValIn)
- {
- def node = node :> TExpr.DefValIn;
- if (node.name.Equals(localValue))
- {
- log(phantom, $" it's a definition! restricting to the location $(node.Location)");
- definitionBlock = node;
- localValueEntries ::= GotoInfo(node.name.Location, UsageType.Definition);
+ | TExpr.LocalRef(referenced) as pointer when (referenced.Equals(localValue)) =>
+ log(phantom, " it's a reference!");
+ localValueEntries ::= GotoInfo(pointer.Location, UsageType.Usage);
+ | _ => log(phantom, " skipping...");
}
else
- log(phantom, $" this definition is not of our local value, skipping...");
- }
- else
- log(phantom, $" the definition hasn't been reached, skipping...");
+ match (node)
+ {
+ | TExpr.DefValIn(definition, _, _) as node when (definition.Equals(localValue))
+ | Pattern.As(_, definition) when (definition.Equals(localValue)) =>
+ log(phantom, " it's a definition!");
+ definitionFound = true;
+ //definitionBlock = node;
+ localValueEntries ::= GotoInfo(definition.Location, UsageType.Definition);
+ //| Match_case as node => definitionBlock = node.body;
+ | _ => log(phantom, " skipping...");
}
}
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 Wed Feb 21 17:11:01 2007
@@ -29,9 +29,10 @@
public static RunTheTest() : void
{
- def suite = FindDefinitionTestProjectTwo();
+ //def suite = FindDefinitionTestProjectTwo();
+ def suite = FindUsagesTestProjectTwo();
suite.SetUp();
- suite.Test038();
+ suite.Test043();
}
public static Explode(this s : string, delimiter : string) : list[string]
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 Wed Feb 21 17:11:01 2007
@@ -6,7 +6,7 @@
namespace TestProjectTwo
{
- class SmallTestsOne
+ class SmallClass
{
public DelayedTExpr() : void
{
@@ -47,11 +47,37 @@
{
| 1 =>
def was = 13 + choice; // definition {38} was // usage {37}
- def bar = 1 - was; // definition {39} // usage {38}
+ def bar = 1 - was; // definition {39} bar // usage {38}
_ = bar; // usage {39}
| _ => ()
}
}
}
+
+ public SimpleTuples(): void
+ {
+ def foo2 = (1, "hoho"); // definition {40} foo2
+ WriteLine(foo2[1]); // usage {40}
+ def (foo, bar) = foo2; // usage {40} // definition {41} foo // definition {42} bar
+ WriteLine(foo); // usage {41}
+ WriteLine(bar); // usage {42}
+ }
+
+ public FunctionParameter(foo: int): void // definition {43} foo
+ {
+ WriteLine(foo); // usage {43}
+ }
+ }
+
+ module SmallModule
+ {
+ Foo(x : object) : void
+ {
+ | x is int => Bar(x)
+ | x is string => Bar(x)
+ }
+
+ Bar(_x : int) : void {}
+ Bar(_x : string) : void {}
}
}
\ No newline at end of file
More information about the svn
mailing list