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

VladD2 svnadmin at nemerle.org
Sat Feb 24 06:29:12 CET 2007


Log:
Work on ProjectReference.

Author: VladD2
Date: Sat Feb 24 06:29:04 2007
New Revision: 7479

Added:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/EngineCallbackStub.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IEngineCallback.n
Removed:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.crud.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/ReferenceCollection.n
Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElemFlags.n
   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/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/ProjectManager.n
   vs-plugin/trunk/Nemerle.VsIntegration.Tests/Utils/CodeDomParser.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.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	Sat Feb 24 06:29:04 2007
@@ -82,10 +82,8 @@
     <Compile Include="Nemerle.Completion2\Engine\Engine.Init.n" />
     <Compile Include="Nemerle.Completion2\Engine\Engine.ParseEvents.n" />
     <Compile Include="Nemerle.Completion2\Engine\Engine.Properties.n" />
-    <Compile Include="Nemerle.Completion2\Engine\Engine.crud.n" />
     <Compile Include="Nemerle.Completion2\Tests\Tests.Init.n" />
     <Compile Include="Nemerle.Completion2\Tests\Tests.n" />
-    <Compile Include="Nemerle.Completion2\TextManagement\IProjectManager.n" />
     <Compile Include="Nemerle.Completion2\TextManagement\ISource.n" />
     <Compile Include="Nemerle.Completion2\TextManagement\ProjectManager.n" />
     <Compile Include="Nemerle.Completion2\CompiledUnitAstBrowser.n" />
@@ -93,7 +91,6 @@
     <Compile Include="Nemerle.Completion2\Decl.n" />
     <Compile Include="Nemerle.Completion2\DefineCollection.n" />
     <Compile Include="Nemerle.Completion2\InternalReference.n" />
-    <Compile Include="Nemerle.Completion2\ReferenceCollection.n" />
     <Compile Include="Nemerle.Completion2\Relocation.n" />
     <Compile Include="Nemerle.Completion2\SourceCollection.n" />
     <Compile Include="Nemerle.Completion2\TraceWriter.n" />
@@ -144,6 +141,15 @@
   <ItemGroup>
     <Compile Include="Nemerle.Completion2\Engine\CompletionElemFlags.n" />
   </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Nemerle.Completion2\TextManagement\IEngineCallback.n" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Nemerle.Completion2\TextManagement\EngineCallbackStub.n" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Nemerle.Completion2\TextManagement\IProjectSources.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/Engine/CompletionElemFlags.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElemFlags.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/CompletionElemFlags.n	Sat Feb 24 06:29:04 2007
@@ -9,6 +9,6 @@
   public enum CompletionElemFlags
   {
     | None
-    | ForOverride
+    | ForOverriding
   }
 }
\ No newline at end of file

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	Sat Feb 24 06:29:04 2007
@@ -53,7 +53,9 @@
               Hierarchy.RemoveProgramTypes();
           else
           {
-            References.UpdateLibrariesManager();
+            foreach (asm in _callback.GetAssemblyReferences())
+              LibrariesManager.AddLibrary(asm);
+            
             LoadExternalLibraries ();
           }
           

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	Sat Feb 24 06:29:04 2007
@@ -243,7 +243,7 @@
                 def res = canOverride.MapToArray(e => CompletionElem(
                   (if (e is IProperty) GlyphType.Property else GlyphType.Method) :> int,
                   e.Name, "info not implemented", array[Elem.Member(e)], 
-                  CompletionElemFlags.ForOverride));
+                  CompletionElemFlags.ForOverriding));
                 res;
 
               | _ => TopKeywords

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	Sat Feb 24 06:29:04 2007
@@ -18,17 +18,19 @@
 {
   public partial class Engine
   {
-    public this(projectSources : IProjectSources, output : TextWriter)
+    public this(callback: IEngineCallback, projectSources : IProjectSources, output : TextWriter)
     {
-      this (CompilationOptions (), projectSources, output);
+      this (callback, CompilationOptions (), projectSources, output);
     }
     
     public this (
+      callback        : IEngineCallback,
       options         : CompilationOptions,
       projectSources  : IProjectSources,
       output          : TextWriter
     )
     {
+      _callback = callback;
       _projectSources = projectSources;
       //TODO: Read all option from project file.
       options.GreedyReferences = false;
@@ -37,7 +39,6 @@
       _isIntelliSenseMode = true;
       syncObject = object();
       _defines = DefineCollection (this);
-      _references = ReferenceCollection (this);
       _sources = SourceCollection (this);
       MessageOccured += ProcessTopLevelCompilerMessage;
 
@@ -62,7 +63,7 @@
 
     /// Reset Engine state (include: TypeTree, LibRefs and so on).
     /// Call this method if you need reload libs and completely rebuild TypeTree.
-    Reset() : void
+    public Reset() : void
     {
       when (_isCanBeReset)
       {

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	Sat Feb 24 06:29:04 2007
@@ -22,7 +22,6 @@
     syncObject : object;
 
     [Accessor] mutable _defines        : DefineCollection;
-    [Accessor] mutable _references     : ReferenceCollection;
     [Accessor]         _sources        : SourceCollection;
     /// [Obsolete] for dont us it accidentally.
     /// Don't use this field directly! Use Project propert.
@@ -30,6 +29,7 @@
     /// Don't use this field directly! Use Project propert.
     [Obsolete] mutable _rowProject     : Project;
     [Accessor]         _projectSources : IProjectSources;
+                       _callback       : IEngineCallback;
 
     static StrsToCompletionElems(
       strs      : SCG.IEnumerable[string],

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	Sat Feb 24 06:29:04 2007
@@ -21,15 +21,16 @@
     public Init() : void
     {
       def pm = ProjectManager();
-      _engine = Engine(pm, TraceWriter());
+      def callback = EngineCallbackStub(
+        "mscorlib",
+        "System",
+        "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
+        "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
+        "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+      );
+      _engine = Engine(callback, pm, TraceWriter());
       pm.Engine = _engine;
 
-      def AddAssembly(name) { _engine.References.Add(name, Assembly.Load(name)); }
-
-      AddAssembly("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
-      AddAssembly("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
-      AddAssembly("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
-
       def addSource(source)
       {
         _engine.Sources.AddOrUpdate(source, File.ReadAllText(source));

Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/EngineCallbackStub.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/EngineCallbackStub.n	Sat Feb 24 06:29:04 2007
@@ -0,0 +1,24 @@
+using System;
+using Nemerle.Compiler;
+using System.Collections.Generic;
+
+namespace Nemerle.Completion2
+{
+  [Record]
+  public class EngineCallbackStub : IEngineCallback
+  {
+    public static Default : EngineCallbackStub = EngineCallbackStub("mscorlib", "System");
+
+    _assemblyReferences : IEnumerable[string];
+
+    public this(params assemblyReferences : array[string])
+    {
+      _assemblyReferences = assemblyReferences;
+    }
+
+    public GetAssemblyReferences() : IEnumerable[string]
+    {
+      _assemblyReferences
+    }
+  }
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IEngineCallback.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/TextManagement/IEngineCallback.n	Sat Feb 24 06:29:04 2007
@@ -0,0 +1,11 @@
+using System;
+using Nemerle.Compiler;
+using System.Collections.Generic;
+
+namespace Nemerle.Completion2
+{
+  public interface IEngineCallback
+  {
+    GetAssemblyReferences() : IEnumerable[string];
+  }
+}
\ No newline at end of file

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	Sat Feb 24 06:29:04 2007
@@ -59,15 +59,9 @@
           {
             def chOffset = if (startLine == stopLn) @char - startChar else @char;
             if (chOffset + i >= code.Length)
-            {
-              assert(true);
               throw ArgumentOutOfRangeException("char");
-            }
             else if (code.IndexOfAny(array['\r', '\n'], i - 1, chOffset) >= 0)
-            {
-              assert(true);
               throw ArgumentOutOfRangeException("char");
-            }
             else
               i + chOffset - 1
           }

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	Sat Feb 24 06:29:04 2007
@@ -17,7 +17,14 @@
 		public void SetUp()
 		{
 			ProjectManager pm = new ProjectManager();
-			Engine engine = new Engine(pm, new TraceWriter());
+      EngineCallbackStub callback = new EngineCallbackStub(
+        "mscorlib",
+        "System",
+        "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
+        "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
+        "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+      );
+			Engine engine = new Engine(callback, pm, new TraceWriter());
 			pm.Engine = engine;
 		}
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	Sat Feb 24 06:29:04 2007
@@ -416,7 +416,8 @@
 					// Quickly compile and find the _exact_ location(s)
 					//
 					Nemerle.Completion2.ProjectManager pm = new Nemerle.Completion2.ProjectManager();
-					Nemerle.Completion2.Engine e = new Nemerle.Completion2.Engine(pm, new TraceWriter());
+					Nemerle.Completion2.Engine e = new Nemerle.Completion2.Engine(
+						EngineCallbackStub.Default, pm, new TraceWriter());
 
 					pm.Engine = e;
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs	Sat Feb 24 06:29:04 2007
@@ -44,7 +44,8 @@
 				{
 					// TODO: We need to create hidden project for files which are not included
 					// in any project.
-					engine = new Engine(new ProjectManager(_languageService), new TraceWriter());
+					engine = new Engine(EngineCallbackStub.Default, 
+						new ProjectManager(_languageService), new TraceWriter());
 					object tmp = engine.Project;
 				}
 				else

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs	Sat Feb 24 06:29:04 2007
@@ -5,6 +5,7 @@
 using Microsoft.VisualStudio.Package.Automation;
 using System;
 using System.Diagnostics;
+using Microsoft.VisualStudio.Shell;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -61,26 +62,19 @@
 
 		public override void AddChild(HierarchyNode node)
 		{
+			EventSinkCollection map = this.ProjectMgr.ItemIdMap;
+
+			// make sure the node is in the map.
+			Object nodeWithSameID = this.ProjectMgr.ItemIdMap[node.ID];
+
 			base.AddChild(node);
 
 			NemerleProjectNode project = ProjectMgr as NemerleProjectNode;
 
 			if (project != null)
 			{
-				if (node is ComReferenceNode || node is AssemblyReferenceNode)
-				{
-					// IT: if dll does not exist, the Url will be null.
-					//
-					if (node.Url != null)
-					{
-						AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
-						project.ProjectInfo.AddAssembly(assemblyName);
-					}
-				}
-				else if (node is ProjectReferenceNode)
-				{
-					project.ProjectInfo.AddProject((ProjectReferenceNode)node);
-				}
+				ReferenceNode referenceNode = (ReferenceNode)node;
+				project.ProjectInfo.AddAssembly(referenceNode);
 			}
 		}
 
@@ -92,18 +86,8 @@
 
 			if (project != null)
 			{
-				if (node is ComReferenceNode || node is AssemblyReferenceNode)
-				{
-					if (node.Url != null)
-					{
-						AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
-						project.ProjectInfo.RemoveAssembly(assemblyName);
-					}
-				}
-				else if (node is ProjectReferenceNode)
-				{
-					project.ProjectInfo.RemoveProject((ProjectReferenceNode)node);
-				}
+				ReferenceNode referenceNode = (ReferenceNode)node;
+				project.ProjectInfo.RemoveAssembly(referenceNode);
 			}
 		}
 	}

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	Sat Feb 24 06:29:04 2007
@@ -19,10 +19,11 @@
 using SourceMap = System.Collections.Generic.Dictionary<string, Nemerle.VisualStudio.LanguageService.NemerleSource>;
 using ProjectManager = Nemerle.VisualStudio.LanguageService.ProjectManager;
 using Nemerle.VisualStudio.GUI;
+using Microsoft.VisualStudio.Shell;
 
 namespace Nemerle.VisualStudio.Project
 {
-	public class ProjectInfo
+	public class ProjectInfo : IEngineCallback
 	{
 		private HierarchyListener              _listener;
 		private Dictionary<string, int>        _fileMap  = new Dictionary<string, int>();
@@ -52,7 +53,7 @@
 			options.DoNotLoadMacros = NoStdMacros;
 			ProjectManager projectManager = new ProjectManager(languageService);
 
-			_engine = new Engine(options, projectManager, new TraceWriter()); // it enables parser working.
+			_engine = new Engine(this, options, projectManager, new TraceWriter()); // it enables parser working.
 
 			projectManager.Engine = Engine;
 
@@ -112,40 +113,40 @@
 
 		#region Project References
 
-		public void AddAssembly(AssemblyName assemblyName)
-		{
-			try
+		List<ReferenceNode> _assemblyReferences = new List<ReferenceNode>();
+
+		public void AddAssembly(ReferenceNode node)
 			{
-				string path = new Uri(assemblyName.CodeBase).LocalPath;
-				Engine.References.Add(path, Assembly.Load(assemblyName));
+			_assemblyReferences.Add(node);
+			Engine.Reset();
 			}
-			catch (Exception ex)
+
+		public void RemoveAssembly(ReferenceNode node)
 			{
-				MessageBox.Show("Can't add assembly reference: " + ex.Message);
-			}
+			bool res = _assemblyReferences.Remove(node);
+			Trace.Assert(res, "Can't remove assembly reference '"
+				+ node.Caption + "' (" + node.Url + ")");
+			Engine.Reset();
 		}
 
-		public void RemoveAssembly(AssemblyName assemblyName)
+		IEnumerable<string> IEngineCallback.GetAssemblyReferences()
 		{
-			try
+			foreach (ReferenceNode node in _assemblyReferences)
 			{
-				string path = new Uri(assemblyName.CodeBase).LocalPath;
-				Engine.References.Remove(path);
-			}
-			catch (Exception ex)
+				string assemblyId = null;
+				ProjectReferenceNode  prjRef = node as ProjectReferenceNode;
+				if (prjRef != null)
+					assemblyId = prjRef.ReferencedProjectOutputPath;
+				else if (node.Url != null) //IT: if dll does not exist, the Url will be null.
+					assemblyId = node.Url;
+				else
 			{
-				MessageBox.Show("Can't remove assembly reference: " + ex.Message);
-			}
+					//TODO: Notify user about reference does not exist. 
 		}
 
-		public void AddProject(ProjectReferenceNode projectReferenceNode)
-		{
-			// TODO: Add new project reference here.
+				if (assemblyId != null)
+					yield return assemblyId;
 		}
-
-		public void RemoveProject(ProjectReferenceNode projectReferenceNode)
-		{
-			// TODO: Remove project reference here.
 		}
 
 		#endregion



More information about the svn mailing list