[svn] r7408: nemerle/trunk/ncc/external/LibrariesLoader.n
nemerle/trunk/ncc/parsing/MainParser.n nemerle/t...
IT
svnadmin at nemerle.org
Mon Feb 12 06:14:33 CET 2007
Log:
Working on TExpr locations.
Author: IT
Date: Mon Feb 12 06:14:13 2007
New Revision: 7408
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
Modified:
nemerle/trunk/ncc/external/LibrariesLoader.n
nemerle/trunk/ncc/parsing/MainParser.n
nemerle/trunk/ncc/typing/TypedTree.n
nemerle/trunk/ncc/typing/Typer.n
vs-plugin/trunk/ConsoleTest/Program.cs
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
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/Tests.Init.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
Modified: nemerle/trunk/ncc/external/LibrariesLoader.n
==============================================================================
--- nemerle/trunk/ncc/external/LibrariesLoader.n (original)
+++ nemerle/trunk/ncc/external/LibrariesLoader.n Mon Feb 12 06:14:13 2007
@@ -577,6 +577,7 @@
Manager = mgr.Manager;
_library = assembly;
_location = Location (Location.GetFileIndex (System.Uri (assembly.CodeBase).LocalPath), 0, 0);
+ _location.MarkAsGenerated();
// Scans the assembly custom attributes looking for something interesting...
foreach (x :> SR.AssemblyConfigurationAttribute in
Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser.n Mon Feb 12 06:14:13 2007
@@ -2249,7 +2249,12 @@
parse_funs (fd :: acc, id)
}
else
- PExpr.DefFunctions (loc + h.loc, List.Rev (fd :: acc))
+ {
+ def lst = List.Rev (fd :: acc);
+ def func = lst.Last;
+ def floc = loc.Combine(if (func.body != null) func.body.Location else func.header.Location);
+ PExpr.DefFunctions (floc, lst)
+ }
};
match (maybe_parse_ellipsis ()) {
Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n (original)
+++ nemerle/trunk/ncc/typing/TypedTree.n Mon Feb 12 06:14:13 2007
@@ -258,6 +258,10 @@
id - other.id
}
+ debug() : void
+ {
+ }
+
public this (loc : Location,
name : string,
[NotNull] ret_type : TyVar,
@@ -268,6 +272,9 @@
{
base (loc);
+ unless (loc.IsGenerated)
+ debug();
+
this.name = name;
this.ret_type = ret_type;
this.ret_type_loc = ret_type_loc;
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Mon Feb 12 06:14:13 2007
@@ -342,7 +342,7 @@
def e' = AddCastTo (e', current_fun.ret_type, "function return value");
def e' =
if (skip_n_return) e'
- else TExpr.Block (current_fun.ret_type, local, e');
+ else TExpr.Block (e'.Location, current_fun.ret_type, local, e');
current_fun.body = FunBody.Typed (e');
| FunBody.Abstract => ()
@@ -1151,7 +1151,7 @@
Manager.Complete (expression, expected, this, env);
}
- match (expression)
+ def texpr = match (expression)
{
| PT.PExpr.ParmByRef
| PT.PExpr.ParmOut =>
@@ -1236,11 +1236,11 @@
| PT.PExpr.DefFunctions (functions) =>
if (Expect (expected, InternalType.Void, "definition ``result''"))
if (is_toplevel_in_seq)
- TypeLocalFunction (functions)
+ TypeLocalFunction (expression.Location, functions)
else
try {
PushLocals ();
- TypeLocalFunction (functions)
+ TypeLocalFunction (expression.Location, functions)
} finally {
PopLocals ()
}
@@ -1721,6 +1721,9 @@
| PT.PExpr.ToComplete =>
Util.ice ("The completion tokens allowed only if Manager.IsCompletioInProgress is true.")
}
+
+ texpr.loc = expression.loc;
+ texpr
}
#endregion
@@ -1786,7 +1789,7 @@
}
- TypeLocalFunction (functions : list [PT.Function_decl]) : TExpr
+ TypeLocalFunction (loc : Location, functions : list [PT.Function_decl]) : TExpr
{
mutable headers = [];
@@ -1842,7 +1845,7 @@
_ = Manager.ComponentsFactory.CreateTyper (this, hd);
}
- TExpr.DefFunctionsIn (headers, null)
+ TExpr.DefFunctionsIn (loc, null, headers, null)
}
Modified: vs-plugin/trunk/ConsoleTest/Program.cs
==============================================================================
--- vs-plugin/trunk/ConsoleTest/Program.cs (original)
+++ vs-plugin/trunk/ConsoleTest/Program.cs Mon Feb 12 06:14:13 2007
@@ -12,6 +12,7 @@
Test1 test = new Test1();
test.Init();
+ test.QuickTip001();
test.Complete_in_return_type_1();
test.Complete_in_return_type_2();
test.Complete_in_return_type_3();
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Mon Feb 12 06:14:13 2007
@@ -137,6 +137,11 @@
<Compile Include="Nemerle.Completion2\CompilerConcreteDefinitions\IntelliSenseModeTyper.n" />
<Compile Include="Nemerle.Completion2\CompilerConcreteDefinitions\IntelliSenseModeLibraryReferenceManager.n" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Nemerle.Completion2\Tests\Content\QuickTip2.n">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
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 Mon Feb 12 06:14:13 2007
@@ -155,18 +155,11 @@
TFinder(info : ExprWalkInfo) : void
{
- match (info.Node)
+ def find(obj : Located)
{
- | TExpr.Delayed(_susp) =>
- // Сюда можно добавить "нечто" для выдачи сообщения о том, что нечто
- // не может быть распознано.
- assert(true);
+ def loc = obj.Location;
- | _ when (info.Node is Located) =>
-
- def loc = (info.Node :> Located).Location;
-
- Print(info.Node, loc, info.Nodes.Length);
+ Print(obj, loc, info.Nodes.Length);
if (IsIn(loc))
{
@@ -175,7 +168,7 @@
PrintAdd(info.Nodes.Length);
_texprLocation = loc;
- _texprObject = info.Node;
+ _texprObject = obj;
def isInExpr(expr)
{
@@ -183,7 +176,7 @@
| _ => false;
}
- when (loc == _pexprLocation || isInExpr(info.Node))
+ when (loc == _pexprLocation || isInExpr(obj))
info.Stop();
}
}
@@ -191,7 +184,24 @@
info.Stop()
else when (_line > loc.EndLine || _line == loc.EndLine && _col > loc.EndColumn)
info.Skip();
+ }
+
+ match (info.Node)
+ {
+ | TExpr.Delayed(_susp) =>
+ // Сюда можно добавить "нечто" для выдачи сообщения о том, что нечто
+ // не может быть распознано.
+ assert(true);
+
+ | h is T.Fun_header =>
+
+ match (h.body)
+ {
+ | Typed(e) when IsIn(e.Location) => ()
+ | _ => find(h);
+ }
+ | l is Located => find(l);
| _ => ()
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n Mon Feb 12 06:14:13 2007
@@ -0,0 +1,17 @@
+using System.Console;
+
+namespace QtTest
+{
+ public class Class1
+ {
+ Foo() : void
+ {
+ def bar()
+ {
+ _ = ReadLine/*001:-1*/();
+ }
+
+ bar();
+ }
+ }
+}
\ No newline at end of file
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n Mon Feb 12 06:14:13 2007
@@ -47,6 +47,9 @@
addSource(FileQuickTip);
Assert.AreEqual(4, _engine.Sources.Count, "Expected Failure.");
+ addSource(FileQuickTip2);
+ Assert.AreEqual(5, _engine.Sources.Count, "Expected Failure.");
+
_project = _engine.Project;
Assert.IsNotNull(_project, "_project is null");
}
@@ -55,6 +58,7 @@
FilePath2 = @"Nemerle.Completion2\Tests\Content\Class1-2.n";
FilePath3 = @"Nemerle.Completion2\Tests\Content\Class1-3.n";
FileQuickTip = @"Nemerle.Completion2\Tests\Content\QuickTip.n";
+ FileQuickTip2 = @"Nemerle.Completion2\Tests\Content\QuickTip2.n";
mutable _project : Project;
mutable _engine : Engine;
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 Mon Feb 12 06:14:13 2007
@@ -16,6 +16,17 @@
public partial class Test1
{
[Test]
+ public QuickTip001() : void
+ {
+ def file = FileQuickTip2;
+ def (line, col) = ReadLocation(file, "001");
+ def result = _project.GetQuickTipInfo(file, line, col);
+
+ Assert.IsNotNull(result, "result is null");
+ Assert.IsTrue (result.Text.Split('\n')[0].IndexOf("ReadLine") > 0);
+ }
+
+ [Test]
public Complete_in_return_type_1() : void
{
def file = FilePath1;
More information about the svn
mailing list