[svn] r6821: vs-plugin/trunk: ConsoleTest/Program.cs
Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj ...
VladD2
svnadmin at nemerle.org
Thu Nov 2 14:00:07 CET 2006
Log:
Work on incremental compilation of methods body.
Implement ISourceTextManager.GetRegion()
Author: VladD2
Date: Thu Nov 2 14:00:04 2006
New Revision: 6821
Modified:
vs-plugin/trunk/ConsoleTest/Program.cs
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n
Modified: vs-plugin/trunk/ConsoleTest/Program.cs
==============================================================================
--- vs-plugin/trunk/ConsoleTest/Program.cs (original)
+++ vs-plugin/trunk/ConsoleTest/Program.cs Thu Nov 2 14:00:04 2006
@@ -12,6 +12,9 @@
Test1 test = new Test1();
test.Init();
+ test.SimpleSourceTextManager_Start_block_1();
+ test.SimpleSourceTextManager_Start_block_2();
+ test.SimpleSourceTextManager_Start_block_3();
test.Hint_on_return();
test.Hint_in_body_of_implicit_match();
test.Overload1();
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 Thu Nov 2 14:00:04 2006
@@ -149,7 +149,7 @@
<ItemGroup>
<Compile Include="Nemerle.Completion2\TextManagement\IProjectManager.n" />
<Compile Include="Nemerle.Completion2\TextManagement\ISourceTextManager.n" />
- <None Include="Nemerle.Completion2\TextManagement\ProjectManager.n" />
+ <Compile Include="Nemerle.Completion2\TextManagement\ProjectManager.n" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
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 Thu Nov 2 14:00:04 2006
@@ -96,6 +96,20 @@
return/*Hint on return:-1*/;
}
+ public Method12(x : bool) : void
+ {
+ /*Start block 1:-0*/;
+ /*End block 1:0*/
+
+ /*Start block 2:-0*/;/*End block 2:0*/
+
+ /*Start block 3:-0*/;
+ // Some code line...
+ // Some code line...
+ // Some code line...
+ /*End block 3:0*/
+ }
+
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 Thu Nov 2 14:00:04 2006
@@ -14,6 +14,45 @@
public partial class Test1
{
[Test]
+ public SimpleSourceTextManager_Start_block_1() : void
+ {
+ SimpleSourceTextManager_Start_block(1,
+ @"/*Start block 1:-0*/;
+ /*End block 1:0*/");
+ }
+
+ [Test]
+ public SimpleSourceTextManager_Start_block_2() : void
+ {
+ SimpleSourceTextManager_Start_block(2,
+ @"/*Start block 2:-0*/;/*End block 2:0*/");
+ }
+
+ [Test]
+ public SimpleSourceTextManager_Start_block_3() : void
+ {
+ SimpleSourceTextManager_Start_block(3,
+ @"/*Start block 3:-0*/;
+ // Some code line...
+ // Some code line...
+ // Some code line...
+ /*End block 3:0*/");
+ }
+
+ private SimpleSourceTextManager_Start_block(blockNum : int, testStr : string) : void
+ {
+ def file = FilePath1;
+ def (line, col) = ReadLocation(file, $"Start block $blockNum");
+ def (endLine, endCol) = ReadLocation(file, $"End block $blockNum");
+ def txtMan = ProjectManager.SimpleSourceTextManager(File.ReadAllText(file));
+
+ def result = txtMan.GetRegion(line, col, endLine, endCol);
+
+ Assert.IsNotNull(result, "result is null");
+ Assert.AreEqual (result, testStr);
+ }
+
+ [Test]
public Hint_on_return() : void
{
def file = FilePath1;
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n Thu Nov 2 14:00:04 2006
@@ -5,6 +5,6 @@
{
public interface IProjectManager
{
- SourceManager[filePath : string] : ISourceTextManager { get; }
+ GetSourceManager(filePath : string) : ISourceTextManager
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n Thu Nov 2 14:00:04 2006
@@ -9,9 +9,102 @@
{
[Accessor] _engine : Engine;
- public virtual ISourceTextManager SourceManager[string filePath]
+ public virtual GetSourceManager(filePath : string) : ISourceTextManager
{
- get { Engine.Sources[filePath] }
+ SimpleSourceTextManager(this.Engine.Sources[filePath])
}
+
+ [Record]
+ internal class SimpleSourceTextManager : ISourceTextManager
+ {
+ [Accessor] _code : string;
+
+ public GetRegion(lineStart : int, colStart : int, lineEnd : int, colEnd : int) : string
+ {
+ def lineStart = lineStart - 1;
+ def colStart = colStart - 1;
+ def lineEnd = lineEnd - 1;
+ def colEnd = colEnd - 1;
+ def code = Code;
+ mutable i = 0;
+ mutable startPos = -1;
+ mutable endPos = -1;
+ mutable chOffset = 0;
+ def peek() { if (i < code.Length) code[i] else '\0' }
+ def next() { def ch = peek(); i++; ch }
+ def skip() { i++; }
+
+ def scanChars(ch, stopChOffset)
+ {
+ match (ch)
+ {
+ | '\r' when peek() == '\n' =>
+ chOffset++;
+ scanChars(next(), stopChOffset);
+
+ | '\r' | '\n' | '\0' =>
+ if (chOffset == stopChOffset)
+ i - 1
+ else
+ throw ArgumentOutOfRangeException("colStart or colEnd");
+
+ | _ =>
+ if (chOffset == stopChOffset)
+ {
+ chOffset++;
+ i - 1
+ }
+ else
+ {
+ chOffset++;
+ scanChars(next(), stopChOffset);
}
-}
+ }
+ }
+
+ def scanLines(ln, stopLn)
+ {
+ def ch = next();
+
+ if (ln == stopLn)
+ if (startPos < 0)
+ {
+ startPos = scanChars(ch, colStart);
+ scanLines(ln, lineEnd)
+ }
+ else
+ {
+ when (lineStart != lineEnd)
+ chOffset = 0;
+ endPos = scanChars(ch, colEnd)
+ }
+ else match (ch)
+ {
+ | '\r' =>
+ when (peek() == '\n')
+ skip();
+ scanLines(ln + 1, stopLn)
+
+ | '\n' => scanLines(ln + 1, stopLn)
+ | '\0' => ()
+ | _ => scanLines(ln, stopLn)
+ }
+ }
+
+ scanLines(0, lineStart);
+ assert (startPos >= 0 && endPos >= 0);
+ code.Substring(startPos, endPos - startPos);
+ }
+
+ public GetRegion(location : Location) : string
+ {
+ def x = location;
+ GetRegion(x.Line, x.Column, x.EndLine, x.EndColumn)
+ }
+
+ public GetLine(_line : int) : string { throw NotImplementedException(); }
+ public GetNearestPosition(_line : int, _col : int) : int { throw NotImplementedException(); }
+ public GetLineAndColumn(_pos : int) : int * int { throw NotImplementedException(); }
+ } // class SimpleSourceTextManager
+ } // class ProjectManager
+} // namespace Nemerle.Completion2
More information about the svn
mailing list