[svn] r7092: vs-plugin/trunk: ConsoleTest/Program.cs
Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Eng...
VladD2
svnadmin at nemerle.org
Fri Dec 15 11:07:21 CET 2006
Log:
1. Sync with compiler.
2. Move RunCompletionEngine() from Engine-main.n into Engine.Completion.n.
3. Add completion tests.
Author: VladD2
Date: Fri Dec 15 11:07:18 2006
New Revision: 7092
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/Engine/Engine.Completion.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.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 Dec 15 11:07:18 2006
@@ -12,9 +12,10 @@
Test1 test = new Test1();
test.Init();
- test.Complete_empty();
test.Complete_System_Collections_Generic_List__Collections();
test.Complete_namespace_2();
+ test.Complete_2();
+ test.Complete_empty();
test.Complete_Complete_expr();
test.Complete_type_escalation_3();
test.Complete_Complete_aliased_type();
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 Dec 15 11:07:18 2006
@@ -136,38 +136,6 @@
}
}
- public RunCompletionEngine (
- [NotNull] method : MethodBuilder,
- [NotNull] content : string,
- methodBodyLocation : Location,
- completionMarkLine : int,
- completionMarkChar : int
- )
- : CompletionResult
- {
- _currentMessages = SCG.List(32);
-
- mutable completionList = null;
-
- def content = content + " ";
-
- def lexer = LexerCompletion (this, content, methodBodyLocation, completionMarkLine, completionMarkChar);
- try
- {
- _ = ParseMethodBody(method, lexer);
- method.RunBodyTyper ();
- }
- catch
- {
- | e is CompletionResult => completionList = e;
- | e => Trace.WriteLine (e.Message);
- }
-
- _currentMessages = null;
-
- completionList
- }
-
private ParseMethodBody(method : MethodBuilder, lexer : LexerBase) : FunBody.Parsed
{
def header = method.GetHeader();
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n Fri Dec 15 11:07:18 2006
@@ -20,12 +20,14 @@
{
public partial class Engine
{
+ // Callback method. Process completion in expressin.
protected override Complete (
expression : PExpr,
expected : TyVar,
typer : Typer,
env : GlobalEnv) : void
{
+ assert(true);
match (expression)
{
| PExpr.Member (obj, Splicable.HalfId (name)) =>
@@ -49,7 +51,8 @@
def tryInterpretAsQualifiedName() : void
{
// Try interpret as qualified name...
- AddOverloads(typer.TypeNameFull(expression, Solver.FreshTyVar (), true));
+ def overloads = typer.TypeNameFull(expression, Solver.FreshTyVar (), true);
+ AddOverloads(overloads);
}
def tryInterpretAsExtentionMethods() : void
@@ -77,8 +80,8 @@
}
}
- tryInterpretAsGlobals();
tryInterpretAsQualifiedName();
+ tryInterpretAsGlobals();
tryInterpretAsExtentionMethods();
tryInterpretAsMemberAccessAtGeneralExpression();
@@ -86,6 +89,10 @@
compl_exc.ObjectType = tobj.Type.Fix();
throw compl_exc
+ | PExpr.Member (obj, _) =>
+ // Try find completion token in nested member access expressions.
+ Complete (obj, expected, typer, env);
+
| PExpr.ToComplete (name) =>
def prefix = name.Id;
//def builder = CurrentMethodBuilder;
@@ -106,11 +113,11 @@
throw CompletionResult (elems, prefix)
- | _ => throw System.NotImplementedException ();
+ | _ => ();
}
}
- /// Process completion in patterns.
+ /// Callback method. Process completion in patterns.
protected override CompletePattern (
expression : PExpr,
matched_value_type : TyVar,
@@ -169,5 +176,47 @@
| _ => ()
}
}
+
+ /// Try compile method body, find completion token and build completion list.
+ public RunCompletionEngine (
+ [NotNull] method : MethodBuilder,
+ [NotNull] content : string,
+ methodBodyLocation : Location,
+ completionMarkLine : int,
+ completionMarkChar : int
+ )
+ : CompletionResult
+ {
+ _isCompletioInProgress = true;
+
+ try
+ {
+ _currentMessages = SCG.List(32);
+
+ mutable completionList = null;
+
+ def content = content + " ";
+
+ def lexer = LexerCompletion (this, content, methodBodyLocation, completionMarkLine, completionMarkChar);
+ try
+ {
+ _ = ParseMethodBody(method, lexer);
+ method.RunBodyTyper ();
+ }
+ catch
+ {
+ | e is CompletionResult => completionList = e;
+ | e => Trace.WriteLine (e.Message);
+ }
+
+ _currentMessages = null;
+
+ completionList
+ }
+ finally
+ {
+ _isCompletioInProgress = false;
+ }
+ }
} // end class Engine
} // end namespace
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n Fri Dec 15 11:07:18 2006
@@ -34,7 +34,7 @@
base (options);
Output = output;
_state = EngineState.Pure;
- _isInCompletionMode = true;
+ _isIntelliSenseMode = true;
syncObject = object();
_defines = DefineCollection (this);
_references = ReferenceCollection (this);
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 Dec 15 11:07:18 2006
@@ -129,7 +129,8 @@
public Method17() : void
{
- System.Collections.Tex/*Complete namespace 2:-0*/
+ System.Collections.Gen/*Complete namespace 2:-0*/
+ System.Collec/*Complete namespace 22:-0*/
}
public Method18() : void
@@ -143,6 +144,14 @@
/*Complete empty:-0*/
}
+ public Method20() : void
+ {
+ /*Complete 2:-0*/
+ when (true)
+ xxx = TestVariant2.AValue;
+
+ }
+
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 Dec 15 11:07:18 2006
@@ -16,6 +16,16 @@
public partial class Test1
{
[Test]
+ public Complete_2() : void
+ {
+ def file = FilePath1;
+ def (line, col) = ReadLocation(file, "Complete 2");
+ def result = _project.CompleteWord(file, line, col, TestSourceTextManager(file));
+ Assert.IsNotNull(result, "result is null");
+ Assert.Greater(result.Length, 10);
+ }
+
+ [Test]
public Complete_empty() : void
{
def file = FilePath1;
More information about the svn
mailing list