[svn] r6827: vs-plugin/trunk: Nemerle.Compiler.Utils/CodeDomParser.n Nemerle.Compiler.Utils/Nemerle.Comple...

VladD2 svnadmin at nemerle.org
Fri Nov 3 15:52:43 CET 2006


Log:
1. Add ProjectSources property into Engine.
2. Move Engine to use ProjectSources.

Author: VladD2
Date: Fri Nov  3 15:52:38 2006
New Revision: 6827

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.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/Engine/Engine.Properties.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IProjectManager.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/ProjectManager.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
   vs-plugin/trunk/Nemerle.VsIntegration.Tests/Utils/CodeDomParser.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/ProjectManager.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomParser.n	Fri Nov  3 15:52:38 2006
@@ -28,6 +28,7 @@
 			def code = codeReader.ReadToEnd();
 			def fileName = GetFileName(codeReader);
 
+      //TODO: Ďĺđĺâĺńňč CodeDomParser íŕ Nemerle.Completion2.Engine.
 			def engine = Engine();
 			// áĺç ýňîé ńňđîęč âŕëčňń˙ exception â Location.Init()
 			ManagerClass.Instance = engine;

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 Nov  3 15:52:38 2006
@@ -208,9 +208,15 @@
         preparser.PreParse();
     }
 
-    protected override PreParseMethodBody (_method : MethodBuilder) : Token.BracesGroup
+    protected override PreParseMethodBody (method : MethodBuilder) : Token.BracesGroup
     {
-      throw System.NotImplementedException ();
+      def loc       = method.BodyLocation;
+      def filePath  = loc.File;
+      def source    = ProjectSources.GetSource(filePath);
+      def bodyCode  = source.GetRegion(loc);
+      def lexer     = LexerString(this, bodyCode, loc);
+      def preparser = PreParser(lexer);
+      preparser.PreParse()
     }
   } // 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 Nov  3 15:52:38 2006
@@ -18,13 +18,18 @@
 {
 	public partial class Engine
 	{
-    public this(output : TextWriter)
+    public this(projectSources : IProjectSources, output : TextWriter)
     {
-      this (CompilationOptions (), output);
+      this (CompilationOptions (), projectSources, output);
     }
     
-    public this (options : CompilationOptions, output : TextWriter)
+    public this (
+      options         : CompilationOptions,
+      projectSources  : IProjectSources,
+      output          : TextWriter
+    )
     {
+      _projectSources = projectSources;
       options.GreedyReferences = false;
       base (options);
       Output = output;

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n	Fri Nov  3 15:52:38 2006
@@ -25,6 +25,7 @@
     [Accessor]         _sources    : SourceCollection;
     [Accessor] mutable _state      : EngineState;
                mutable _project    : Project;
+    [Accessor]         _projectSources : IProjectSources;
     
     public Project : Project
     {

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	Fri Nov  3 15:52:38 2006
@@ -20,7 +20,9 @@
     [SetUp]
     public Init() : void
     {
-      _engine = Engine(TraceWriter());
+      def pm = ProjectManager();
+      _engine = Engine(pm, TraceWriter());
+      pm.Engine = _engine;
 
       def AddAssembly(name) { _engine.References.Add(name, Assembly.Load(name)); }
 

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	Fri Nov  3 15:52:38 2006
@@ -3,8 +3,8 @@
 
 namespace Nemerle.Completion2
 {
-  public interface IProjectManager
+  public interface IProjectSources
   {
-    GetSourceManager(filePath : string) : ISource
+    GetSource(filePath : string) : ISource
   }
 }

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	Fri Nov  3 15:52:38 2006
@@ -4,13 +4,12 @@
 
 namespace Nemerle.Completion2
 {
-  [Record]
-  public class ProjectManager : IProjectManager
+  public class ProjectManager : IProjectSources
   {
-    [Accessor] _engine : Engine;
+    [Accessor (flags = WantSetter)] mutable _engine : Engine;
 
     /// Get manager of code file.
-    public virtual GetSourceManager(filePath : string) : ISource
+    public virtual GetSource(filePath : string) : ISource
     {
       SimpleSourceTextManager(this.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	Fri Nov  3 15:52:38 2006
@@ -16,13 +16,15 @@
   {
     public GetMethodBody(
       this /*[NotNull]*/ method   : MethodBuilder,
-           /*[NotNull]*/ source   : ISource
+           /*[NotNull]*/ _source   : ISource
     )
       : PExpr * TExpr * Exception
     {
       def loc = method.BodyLocation;
-      def bodyCode = source.GetRegion(loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
+      def filePath = loc.File;
       def engine = method.Manager :> Engine;
+      def source   = engine.ProjectSources.GetSource(filePath);
+      def bodyCode = source.GetRegion(loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
       engine.CompileMethod(method, bodyCode, loc);
     }
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration.Tests/Utils/CodeDomParser.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration.Tests/Utils/CodeDomParser.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration.Tests/Utils/CodeDomParser.cs	Fri Nov  3 15:52:38 2006
@@ -1,7 +1,6 @@
 using System;
 using System.CodeDom;
 
-using Nemerle.Compiler;
 using Nemerle.Completion2;
 using NUnit.Framework;
 using Nemerle.VsIntegration.Tests.Utils;
@@ -17,12 +16,9 @@
 		[SetUp]
 		public void SetUp()
 		{
-			Engine engine = new Engine(null);
-			
-			// Without this line we got an exception in the Location.Init() method.
-			ManagerClass.Instance = engine;
-
-			engine.Init();
+			ProjectManager pm = new ProjectManager();
+			Engine engine = new Engine(pm, new TraceWriter());
+			pm.Engine = engine;
 		}
 
 		[Test]

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/ProjectManager.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/ProjectManager.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/ProjectManager.cs	Fri Nov  3 15:52:38 2006
@@ -6,8 +6,7 @@
 {
 	class ProjectManager : Nemerle.Completion2.ProjectManager
 	{
-		public ProjectManager(NemerleLanguageService languageService, Engine engine)
-			: base(engine)
+		public ProjectManager(NemerleLanguageService languageService)
 		{
 			ErrorHelper.ThrowIsNull(languageService, "languageService");
 			_languageService = languageService;
@@ -16,7 +15,7 @@
 		NemerleLanguageService _languageService;
 
 		/// Get manager of code file.
-		public override ISource GetSourceManager(string filePath)
+		public override ISource GetSource(string filePath)
 		{
 			ProjectInfo info = ProjectInfo.FindProject(filePath);
 			if (info == null)
@@ -26,7 +25,7 @@
 			{
 				NemerleSource source = info.GetSource(filePath);
 				if (source == null)
-					return base.GetSourceManager(filePath);
+					return base.GetSource(filePath);
 				else
 					return new SourceTextManager(info.GetSource(filePath));
 			}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs	Fri Nov  3 15:52:38 2006
@@ -15,6 +15,7 @@
 using Microsoft.VisualStudio.Shell;
 
 using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
+using Nemerle.VisualStudio.LanguageService;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -228,7 +229,8 @@
 			// IT: ProjectInfo needs to be created before loading
 			// as we will catch assembly reference adding.
 			//
-			_projectInfo = new ProjectInfo(this, InteropSafeHierarchy, filename, location);
+			_projectInfo = new ProjectInfo(this, InteropSafeHierarchy, 
+				Utils.GetService<NemerleLanguageService>(Site), filename, location);
 
 			ProjectInfo.Projects.Add(_projectInfo);
 

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	Fri Nov  3 15:52:38 2006
@@ -17,6 +17,7 @@
 
 using MSBuild = Microsoft.Build.BuildEngine;
 using SourceMap = System.Collections.Generic.Dictionary<string, Nemerle.VisualStudio.LanguageService.NemerleSource>;
+using ProjectManager = Nemerle.VisualStudio.LanguageService.ProjectManager;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -32,6 +33,7 @@
 		public ProjectInfo(
 			NemerleProjectNode projectNode,
 			IVsHierarchy       hierarchy, 
+			NemerleLanguageService languageService,
 			string             fileName, 
 			string             location
 		)
@@ -46,8 +48,11 @@
 
 			options.DoNotLoadStdlib = NoStdLib;
 			options.DoNotLoadMacros = NoStdMacros;
+			ProjectManager projectManager = new ProjectManager(languageService);
 
-			_engine = new Engine(options, new TraceWriter()); // it enables parser working.
+			_engine = new Engine(options, projectManager,
+				new TraceWriter()); // it enables parser working.
+			projectManager.Engine = _engine;
 
 			if (!string.IsNullOrEmpty(location))
 				_projectLocation = location;



More information about the svn mailing list