[svn] r6815: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Nemerle.Compiler.Utils/...

VladD2 svnadmin at nemerle.org
Tue Oct 31 10:54:51 CET 2006


Log:
Work on incremental compilation of methods body.

Author: VladD2
Date: Tue Oct 31 10:54:45 2006
New Revision: 6815

Added:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ISourceTextManager.n
      - copied, changed from rev 6812, vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ISourceTextManager.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n
Removed:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ISourceTextManager.n
Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/DefineCollection.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs

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	Tue Oct 31 10:54:45 2006
@@ -120,9 +120,6 @@
     <Compile Include="Nemerle.Completion2\CompiledUnitAstBrowser.n" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Nemerle.Completion2\ISourceTextManager.n" />
-  </ItemGroup>
-  <ItemGroup>
     <Compile Include="Nemerle.Completion2\CodeModel\ExprWalker.n" />
   </ItemGroup>
   <ItemGroup>
@@ -149,6 +146,11 @@
   <ItemGroup>
     <Compile Include="Nemerle.Completion2\CodeModel\TokenFinder.n" />
   </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Nemerle.Completion2\TextManagement\IProjectManager.n" />
+    <Compile Include="Nemerle.Completion2\TextManagement\ISourceTextManager.n" />
+    <None 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. 
        Other similar extension points exist, see Microsoft.Common.targets.

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n	Tue Oct 31 10:54:45 2006
@@ -1,4 +1,5 @@
 using Nemerle.Assertions;
+using Nemerle.Collections;
 using Nemerle.Compiler;
 using Nemerle.Compiler.Parsetree;
 using Nemerle.Utility;
@@ -9,14 +10,17 @@
   public class CompileUnitCollection
   {
     public this([NotNull] engine        : Engine, 
-                [NotNull] fileInfos     : array[Decl.Namespace])
+                [NotNull] fileInfos     : array[Decl.Namespace],
+                [NotNull] regionsMap    : Hashtable[string, list[Region]])
     {
       _engine = engine;
       _fileInfos = fileInfos;
+      _regionsMap = regionsMap
     }
 
     _engine : Engine;
     _fileInfos : array[Decl.Namespace];
+    _regionsMap : Hashtable[string, list[Region]];
 
 
     public GetFileIndex(filePath : string) : int
@@ -24,6 +28,11 @@
       Location.GetFileIndex(filePath);
     }
 
+    public GetRegions(filePath : string) : list[Region]
+    {
+      _regionsMap[filePath];
+    }
+
     public Item[fileIndex : int] : Decl.Namespace
     {
       get

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	Tue Oct 31 10:54:45 2006
@@ -86,6 +86,9 @@
         else typeBuilder.GetActiveMember(fileIndex, line, col,
           fun(m1, m2)
           {
+            // Ýňîň ęîä âűëĺňŕĺň ďî NulReferenceException ĺńëč, íŕďđčěĺđ, íŕâĺńňč 
+            // ęóđńîđ íŕ "Message_output" â ńňđîęĺ 46 ôŕéëŕ:
+            // Nemerle.Compiler.Utils\Nemerle.Completion2\Engine\Engine.Properties.n
             def loc1 = m1.Location;
             def loc2 = m2.Location;
 
@@ -103,9 +106,7 @@
 
         if (loc.Contains(line, col)) // in method body
         {
-          def bodyCode = source.GetRegion(loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
-
-          def (pBody, tBody, _) = _engine.CompileMethod(method, bodyCode, loc);
+          def (pBody, tBody, _) = method.GetMethodBody(source);
 
           ExprFinder().Find(pBody, tBody, line, col);
         }
@@ -142,6 +143,9 @@
       line      : int,
       col       : int,
       source    : ISourceTextManager,
+      //2IT: ďđŕęňč÷ĺńęč ëţáîé ęëŕńń â ęîěďčë˙ňîđĺ ńîäĺđćčň ńńűëęó íŕ ManagerClass.
+      // Ďî ęđŕéíĺé ěĺđĺ MemberBuilder č TypeBuilder ňî÷íî čő čěĺţň.
+      // Ňŕę ÷ňî ýňîň ďŕđŕěĺňđ ńęîđĺĺ âńĺăî îřčáęŕ.
       manager   : ManagerClass
     )
       : QuickTipInfo
@@ -152,6 +156,8 @@
       {
       | me is TExpr.MacroEnvelope  => (QuickTipInfo(loc,         me))
       | lv is LocalValue           => (QuickTipInfo(loc,         lv))
+      // IMember đĺŕëčçóţň âńĺ íŕńëĺäíčęč MemberBuilder.  ňîě ÷čńëĺ č FieldBuilder.
+      // Ňŕę ÷ňî ďđîâĺđęŕ íŕ ýňîň číňĺđôĺéń äîëćíŕ čäňč â ńŕěîě ęîíöĺ.
       | mm is IMember              => (QuickTipInfo(loc,         mm, manager))
       | tv is TyVar                => (QuickTipInfo(loc,         tv))
       | fh is Typedtree.Fun_header => (QuickTipInfo(loc,         fh))

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	Tue Oct 31 10:54:45 2006
@@ -247,10 +247,7 @@
 #endif
               // Get errors.
               //
-              def location = method.BodyLocation;
-              def bodyCode = source.GetRegion(location.Line, location.Column, location.EndLine, location.EndColumn);
-
-              def (pExpr, _, _) = _engine.CompileMethod(method, bodyCode, location);
+              def (pExpr, _, _) = method.GetMethodBody(source);
 
               when (pExpr != null)
               {
@@ -373,12 +370,11 @@
           }
         }
 
-        match (_engine.Sources._sources[fileName])
-        {
-        | ParsedFile.Parsed(_, _, regions) =>
-
+        //TODO: Đĺăčîíű ďîęŕ íĺ đĺëîęĺéň˙ňń˙. Ňŕę ÷ňî ďđč çěĺíĺíčč čńőîäíčęîâ îíč äîëćíű âđŕňü.
+        def regions = CompileUnits.GetRegions(fileName);
           foreach (r in regions)
           {
+          // Ęŕęîé ńěűńë â mutable? Äŕ č âîîáůĺ çŕ÷ĺě ęîďčđîâŕňü Location â ďĺđĺěĺííűĺ?
             mutable lineStart = r.Location.Line;
             mutable colStart  = r.Location.Column;
             mutable lineEnd   = r.Location.EndLine;
@@ -390,9 +386,7 @@
 
             addHiddenRegion(
               Location(fileIndex, lineStart, colStart, lineEnd, colEnd),
-              if (string.IsNullOrEmpty(r.Text)) "#region" else r.Text, true);
-          }
-        | _ => ()
+            if (r.Text.IsNullOrEmpty()) "#region" else r.Text, true);
         }
       }
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/DefineCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/DefineCollection.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/DefineCollection.n	Tue Oct 31 10:54:45 2006
@@ -28,7 +28,7 @@
         {
             _defines ::= define;
             _engine.Options.DefineConstant (define);
-            _engine.Sources.set_unparsed_state ();
+            _engine.ResetTypeTree();
         }
     }
     
@@ -36,9 +36,9 @@
     {
         when (_defines.Contains (define))
         {
-            _ = _defines.Remove (define);
-            _engine.Options.UndefineConstant (define);
-            _engine.Sources.set_unparsed_state ();
+            _ = _defines.Remove(define);
+            _engine.Options.UndefineConstant(define);
+            _engine.ResetTypeTree();
         }
     }
     
@@ -54,7 +54,7 @@
             foreach (define in _defines)
                 _engine.Options.UndefineConstant (define);
             _defines = [];
-            _engine.Sources.set_unparsed_state();
+            _engine.ResetTypeTree();
         }
     }
     

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	Tue Oct 31 10:54:45 2006
@@ -14,6 +14,7 @@
 using Nemerle.Compiler.Utils;
 
 using Typed = Nemerle.Compiler.Typedtree;
+using TExpr = Nemerle.Compiler.Typedtree.TExpr;
 
 namespace Nemerle.Completion2
 {
@@ -35,25 +36,21 @@
       this.Hierarchy = TypesManager (this);
 
       mutable trees = [];
+      def regionsMap = Hashtable();
 
-      foreach ((filePath, fileInfo) in Sources._sources.KeyValuePairs)
+      foreach ((filePath, code) in Sources._sources.KeyValuePairs)
       {
-          match (fileInfo)
-          {
-          | Parsed(_, code, _)
-          | NotParsed(code) =>
               _fileIndex = Location.GetFileIndex(filePath);
               BeginParseFile(_fileIndex);
               try
               {
                 def lexer = LexerString (this, code, Location(_fileIndex, 1, 1));
                 def decls = ParsingPipeline (lexer);
-                Sources._sources[filePath] = ParsedFile.Parsed(decls, code, lexer.Regions);
+          regionsMap.Add(filePath, lexer.Regions);
                 trees ::= decls;
               }
               finally { EndParseFile(_fileIndex); }
           }
-      }
        
       // create N.C.TypeBuilders for all parsed types and add them to namespace hierarchy
       try
@@ -115,7 +112,7 @@
         when (_fileInfos[i] != null)
           AddTypeBilders(_fileInfos[i], i, nsTree);
 
-      _project = Project(this, CompileUnitCollection(this, _fileInfos), nsTree);
+      _project = Project(this, CompileUnitCollection(this, _fileInfos, regionsMap), nsTree);
     }
 
     public RunCompletionEngine (
@@ -179,7 +176,7 @@
       /*[NotNull]*/ content  : string,
                     location : Location
     )
-      : PExpr * Typedtree.TExpr * Exception
+      : PExpr * TExpr * Exception
     {
         ClearCompilerMessages();
         _isInCompletionMode = true;
@@ -211,6 +208,10 @@
         preparser.PreParse();
     }
 
+    protected override PreParseMethodBody (_method : MethodBuilder) : Token.BracesGroup
+    {
+      throw System.NotImplementedException ();
+    }
   } // 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	Tue Oct 31 10:54:45 2006
@@ -33,7 +33,7 @@
       syncObject = object();
       _defines = DefineCollection (this);
       _references = ReferenceCollection (this);
-      _sources = SourceCollection ();
+      _sources = SourceCollection (this);
       MessageOccured += ProcessCompilerMessage;
       Options.GreedyReferences = true;
       Options.ColorMessages = false;
@@ -62,7 +62,7 @@
       
       // next time Init is called, we won't rebuild external types
       _state = EngineState.LoadedLibs; 
-      // Sources.set_unparsed_state ();
+      ResetTypeTree();
     }
   } // end class Engine
 } // end namespace

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ParsedFile.n	Tue Oct 31 10:54:45 2006
@@ -1,19 +1,19 @@
-using System;
-using Nemerle.Assertions;
-using Nemerle.Collections;
-using Nemerle.Compiler;
-using Nemerle.Compiler.Parsetree;
-using Nemerle.Utility;
-
-using Typed = Nemerle.Compiler.Typedtree;
-using SR = System.Reflection;
-
-namespace Nemerle.Completion2
-{
-  internal variant ParsedFile
-  {
-  | NotParsed { code : string }
-  | Parsed { decls : list [TopDeclaration]; code : string; regions : list[Region]; }
-  }
-} // end namespace
+//using System;
+//using Nemerle.Assertions;
+//using Nemerle.Collections;
+//using Nemerle.Compiler;
+//using Nemerle.Compiler.Parsetree;
+//using Nemerle.Utility;
+//
+//using Typed = Nemerle.Compiler.Typedtree;
+//using SR = System.Reflection;
+//
+//namespace Nemerle.Completion2
+//{
+//  internal variant ParsedFile
+//  {
+//  | NotParsed { code : string }
+//  | Parsed { decls : list [TopDeclaration]; code : string; regions : list[Region]; }
+//  }
+//} // end namespace
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n	Tue Oct 31 10:54:45 2006
@@ -29,6 +29,7 @@
         {
           references.Add (key, InternalReference.Library (path));
           _engine.AddLibrary(path);
+          _engine.ResetTypeTree();
         }
       }
       
@@ -38,6 +39,7 @@
         {
           references.Add (key, InternalReference.Assembly (loadedAssembly));
           _engine.AddAssembly (loadedAssembly);
+          _engine.ResetTypeTree();
         }
       }
       
@@ -47,7 +49,7 @@
         {
           references.Remove (key);
           _engine._state = EngineState.Pure;
-          _engine.Sources.set_unparsed_state ();
+          _engine.ResetTypeTree();
           
           foreach (reference in references.Values)
           {
@@ -61,7 +63,7 @@
       {
         references = Hashtable ();
         _engine._state = EngineState.Pure;
-        _engine.Sources.set_unparsed_state ();
+        _engine.ResetTypeTree();
       }
       
       public ContainsKey (key : string) : bool

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/SourceCollection.n	Tue Oct 31 10:54:45 2006
@@ -14,46 +14,48 @@
   {
     public class SourceCollection
     {
-      internal this ()
+      _engine : Engine;
+
+      internal this (engine : Engine)
       {
-        _sources = Hashtable ();
+        _engine  = engine;
+        _sources = Hashtable();
       }
       
-      internal mutable _sources : Hashtable[string, ParsedFile];
+      internal mutable _sources : Hashtable[string, string];
 
       public AddOrUpdate (file : string, content : string) : void
       {
-        _sources[file] = ParsedFile.NotParsed(content);
+        when (!ContainsKey(file))
+          _engine.ResetTypeTree();
+
+        _sources[file] = content;
       }
       
       public Remove (dile : string) : void
       {
         _sources.Remove (dile);
-        // Íó, č çŕ÷ĺě ýňî äĺëŕňü?
-        // Ęŕęîé ńěűńë áűëî äĺëŕňü öĺëóţ číôđŕńňđóęňóđó ńáĺđĺćĺíč˙ đĺńóđńîâ ďŕđńĺđŕ
-        // č â ęîíĺ÷íîě čňîăĺ ďđč ďîëîâčíĺ čçěĺíĺíčé â ďđîĺęňĺ â ňóďóţ âńĺ ďĺđĺďŕđńčâŕňü?
-        // ×ĺě óäŕëĺíčĺ ôŕéëŕ îňëč÷ŕĺňń˙ îň ĺăî îáíîâëĺíč˙?
-        //set_unparsed_state ();
+        _engine.ResetTypeTree();
       }
 
       public Clear () : void
       {
         _sources.Clear();
-        //set_unparsed_state();
-      }
-
-      internal set_unparsed_state () : void
-      {
-        foreach ((fileName, Parsed(_, code, _)) in _sources.KeyValuePairs)
-          _sources[fileName] = ParsedFile.NotParsed(code);
+        _engine.ResetTypeTree();
       }
 
       public ContainsKey (file : string) : bool { _sources.ContainsKey (file) }
+
       public GetKeys () : System.Collections.Generic.IEnumerable[string]
       {
         _sources.Keys
       }
 
+      public Item[filePath : string] : string
+      {
+        get { _sources[filePath] }
+      }
+
       public Count : int { get { _sources.Count } }
     }
   }

Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n	Tue Oct 31 10:54:45 2006
@@ -0,0 +1,10 @@
+using System;
+using Nemerle.Compiler;
+
+namespace Nemerle.Completion2
+{
+  public interface IProjectManager
+  {
+    SourceManager[filePath : string] : ISourceTextManager { get; }
+  }
+}

Copied: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ISourceTextManager.n (from rev 6812, vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ISourceTextManager.n)
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ISourceTextManager.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ISourceTextManager.n	Tue Oct 31 10:54:45 2006
@@ -1,15 +1,14 @@
 using System;
-
 using Nemerle.Compiler;
 
 namespace Nemerle.Completion2
 {
   public interface ISourceTextManager
   {
-    GetRegion         (lineStart : int, colStart : int, lineEnd : int, colEnd : int) : string;
-    GetRegion         (location : Location) : string;
-    GetLine           (line : int) : string;
+    GetRegion(lineStart : int, colStart : int, lineEnd : int, colEnd : int) : string;
+    GetRegion(location : Location) : string;
+    GetLine(line : int) : string;
     GetNearestPosition(line : int, col : int) : int;
-    GetLineAndColumn  (pos  : int) : int * int;
+    GetLineAndColumn(pos  : int) : int * int;
   }
 }

Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n	Tue Oct 31 10:54:45 2006
@@ -0,0 +1,17 @@
+using System;
+using Nemerle.Compiler;
+using Nemerle.Utility;
+
+namespace Nemerle.Completion2
+{
+  [Record]
+  class ProjectManager : IProjectManager
+	{
+    [Accessor] _engine : Engine;
+
+    public virtual ISourceTextManager SourceManager[string filePath]
+    {
+      get { Engine.Sources[filePath] }
+    }
+	}
+}

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	Tue Oct 31 10:54:45 2006
@@ -7,10 +7,25 @@
 using System;
 using Nemerle.Utility;
 
+using Nemerle.Compiler.Parsetree;
+using TExpr = Nemerle.Compiler.Typedtree.TExpr;
+
 namespace Nemerle.Compiler.Utils
 {
   public module Utils
   {
+    public GetMethodBody(
+      this /*[NotNull]*/ method   : MethodBuilder,
+           /*[NotNull]*/ source   : ISourceTextManager
+    )
+      : PExpr * TExpr * Exception
+    {
+      def loc = method.BodyLocation;
+      def bodyCode = source.GetRegion(loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
+      def engine = method.Manager :> Engine;
+      engine.CompileMethod(method, bodyCode, loc);
+    }
+
     public IsNullOrEmpty(this value : string) : bool
     {
       if (value == null) true else value.Length == 0

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	Tue Oct 31 10:54:45 2006
@@ -20,6 +20,20 @@
 			: base(service, textLines, colorizer)
 		{
 			//BeginParse();
+      string path = GetFilePath();
+      ProjectInfo info = ProjectInfo.FindProject(path);
+      if (info != null)
+        info.AddSource(this);
+    }
+
+    public override void Dispose()
+    {
+      string path = GetFilePath();
+      ProjectInfo info = ProjectInfo.FindProject(path);
+      if (info != null)
+        info.RemoveSource(this);
+
+      base.Dispose();
 		}
 
 		public override CommentInfo GetCommentFormat()

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs	Tue Oct 31 10:54:45 2006
@@ -16,6 +16,7 @@
 using Nemerle.VisualStudio.LanguageService;
 
 using MSBuild = Microsoft.Build.BuildEngine;
+using SourceMap = System.Collections.Generic.Dictionary<string, Nemerle.VisualStudio.LanguageService.NemerleSource>;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -23,6 +24,7 @@
 	{
 		private HierarchyListener              _listener;
 		private Dictionary<string, int>        _fileMap  = new Dictionary<string, int>();
+    private SourceMap                      _sourceMap = new SourceMap();
 
 		private static Collection<ProjectInfo> _projects = new Collection<ProjectInfo>();
 		private string                         _projectLocation;
@@ -133,6 +135,24 @@
 
 		#endregion
 
+    internal void AddSource(NemerleSource source)
+    {
+      string path = source.GetFilePath();
+      _sourceMap.Add(path, source);
+    }
+
+    internal void RemoveSource(NemerleSource source)
+    {
+      string path = source.GetFilePath();
+      _sourceMap.Remove(path);
+    }
+
+    public NemerleSource GetSource(string filePath)
+    {
+      NemerleSource source;
+      return _sourceMap.TryGetValue(filePath, out source) ? source : null;
+    }
+
 		/// <summary>
 		/// If the provided file is attached to the project,  its timestamp (version) is returned.
 		/// Otherwise 0.
@@ -203,7 +223,7 @@
 
 		private void FileAdded(object sender, HierarchyEventArgs ergs)
 		{
-			Debug.Assert(ergs.TextBuffer == null);
+			Trace.Assert(ergs.TextBuffer == null);
 
 			NemerleFileNodeProperties nodeProps = GetNodeProperties((IVsHierarchy)sender, ergs.ItemID);
 
@@ -271,8 +291,8 @@
 				return;
 
 			// If can't add relocation we must reparse types tree.
-			if (!Project.AddRelocation(
-				filePath, newEndIndex, newEndLine, oldEndIndex, oldEndLine, startIndex, startLine))
+			if (!Project.AddRelocation(filePath, newEndIndex, newEndLine, 
+        oldEndIndex, oldEndLine, startIndex, startLine))
 			{
 				// Âđĺěĺííî îňęëţ÷ĺíî!
 				//NemerleSource source = Utils.GetFileSource(_site, filePath);
@@ -300,8 +320,9 @@
 				// Update file content, because it is changed, but engine still doesn't know it.
 				if (ProjectNode.Site != null)
 				{
-					string code = Utils.GetFileCode(ProjectNode.Site, filePath);
-					Engine.Sources.AddOrUpdate(filePath, code);
+          NemerleSource source = GetSource(filePath);
+          if (source != null)
+					  Engine.Sources.AddOrUpdate(filePath, source.GetText());
 				}
 
 #endif



More information about the svn mailing list