[Monodevelop-patches-list] r2625 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Services/ParserService
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Mon Jul 11 10:19:57 EDT 2005
Author: lluis
Date: 2005-07-11 10:19:57 -0400 (Mon, 11 Jul 2005)
New Revision: 2625
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs
Log:
2005-07-11 Lluis Sanchez Gual <lluis at novell.com>
* Services/ParserService/AssemblyCodeCompletionDatabase.cs:
Load referenced assemblies in an external process. gtk# 1.0 projects
should work again.
* Services/ParserService/IParserService.cs:
* Services/ParserService/DefaultParserService.cs: Added GetProjectContents
method.
* Services/ParserService/CodeCompletionDatabase.cs: Added GetClassList
method (to support GetProjectContents).
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-07-11 14:12:47 UTC (rev 2624)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-07-11 14:19:57 UTC (rev 2625)
@@ -1,3 +1,14 @@
+2005-07-11 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Services/ParserService/AssemblyCodeCompletionDatabase.cs:
+ Load referenced assemblies in an external process. gtk# 1.0 projects
+ should work again.
+ * Services/ParserService/IParserService.cs:
+ * Services/ParserService/DefaultParserService.cs: Added GetProjectContents
+ method.
+ * Services/ParserService/CodeCompletionDatabase.cs: Added GetClassList
+ method (to support GetProjectContents).
+
2005-07-08 John Luke <john.luke at gmail.com>
* Makefile.am: remove MONO_POSIX_OEE defines
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs 2005-07-11 14:12:47 UTC (rev 2624)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs 2005-07-11 14:19:57 UTC (rev 2625)
@@ -34,6 +34,7 @@
using MonoDevelop.Internal.Project;
using MonoDevelop.Internal.Parser;
using System.Reflection;
+using MonoDevelop.Core.Services;
namespace MonoDevelop.Services
{
@@ -47,39 +48,14 @@
: base (parserService)
{
string assemblyFile;
+ string[] refUris;
string name;
- Assembly asm = null;
- if (assemblyName.ToLower().EndsWith (".dll"))
+ using (AssemblyDatabaseHelper helper = GetExternalHelper (true))
{
- name = assemblyName.Substring (0, assemblyName.Length - 4);
- name = name.Replace(',','_').Replace(" ","").Replace('/','_');
- assemblyFile = assemblyName;
- try {
- asm = Assembly.LoadFrom (assemblyFile);
- }
- catch {}
-
- if (asm == null) {
- Runtime.LoggingService.Info ("Could not load assembly: " + assemblyFile);
- return;
- }
+ helper.GetAssemblyInfo (assemblyName, out this.assemblyName, out assemblyFile, out name, out refUris);
}
- else
- {
- asm = FindAssembly (assemblyName);
-
- if (asm == null) {
- Runtime.LoggingService.Info ("Could not load assembly: " + assemblyName);
- return;
- }
-
- assemblyName = asm.GetName().FullName;
- name = EncodeGacAssemblyName (assemblyName);
- assemblyFile = asm.Location;
- }
- this.assemblyName = assemblyName;
this.baseDir = baseDir;
SetLocation (baseDir, name);
@@ -94,8 +70,7 @@
// Update references to other assemblies
Hashtable rs = new Hashtable ();
- foreach (AssemblyName aname in asm.GetReferencedAssemblies ()) {
- string uri = "Assembly:" + aname.ToString();
+ foreach (string uri in refUris) {
rs[uri] = null;
if (!HasReference (uri))
AddReference (uri);
@@ -112,53 +87,12 @@
public static string GetFullAssemblyName (string s)
{
- if (s.ToLower().EndsWith (".dll"))
- return s;
-
- Assembly asm = FindAssembly (s);
-
- if (asm != null)
- return asm.GetName().FullName;
- else
- return s;
- }
-
- public static Assembly FindAssembly (string name)
- {
- Assembly asm = null;
- try {
- asm = Assembly.Load (name);
+ using (AssemblyDatabaseHelper helper = GetExternalHelper (true))
+ {
+ return helper.GetFullAssemblyName (s);
}
- catch {}
-
- if (asm == null) {
- try {
- asm = Assembly.LoadWithPartialName (name);
- }
- catch {}
- }
- return asm;
}
- string EncodeGacAssemblyName (string assemblyName)
- {
- string[] assemblyPieces = assemblyName.Split(',');
- string res = "";
- foreach (string item in assemblyPieces) {
- string[] pieces = item.Trim ().Split (new char[] { '=' }, 2);
- if(pieces.Length == 1)
- res += pieces[0];
- else if (!(pieces[0] == "Culture" && pieces[1] != "Neutral"))
- res += "_" + pieces[1];
- }
- return res;
- }
-
- public string AssemblyName
- {
- get { return assemblyName; }
- }
-
protected override void ParseFile (string fileName, IProgressMonitor parentMonitor)
{
IProgressMonitor monitor = parentMonitor;
@@ -168,10 +102,11 @@
monitor.BeginTask ("Parsing assembly: " + Path.GetFileName (fileName), 1);
if (useExternalProcess)
{
- string dbgen = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "dbgen.exe");
- Process proc = Process.Start ("mono " + dbgen, "\"" + baseDir + "\" \"" + assemblyName + "\"");
- proc.WaitForExit ();
- Read ();
+ using (AssemblyDatabaseHelper helper = GetExternalHelper (true))
+ {
+ helper.GenerateDatabase (baseDir, assemblyName);
+ Read ();
+ }
}
else
{
@@ -203,5 +138,122 @@
Runtime.LoggingService.Info ("Deleted " + dataFile);
}
}
+
+
+ static AssemblyDatabaseHelper GetExternalHelper (bool share)
+ {
+ if (Runtime.ProcessService != null)
+ return (AssemblyDatabaseHelper) Runtime.ProcessService.CreateExternalProcessObject (typeof(AssemblyDatabaseHelper), share);
+ else
+ return new AssemblyDatabaseHelper ();
+ }
}
+
+ public class AssemblyDatabaseHelper: RemoteProcessObject
+ {
+ public bool GetAssemblyInfo (string assemblyName, out string realAssemblyName, out string assemblyFile, out string name, out string[] references)
+ {
+ name = null;
+ assemblyFile = null;
+ realAssemblyName = null;
+ references = null;
+
+ Assembly asm = null;
+
+ if (assemblyName.ToLower().EndsWith (".dll"))
+ {
+ name = assemblyName.Substring (0, assemblyName.Length - 4);
+ name = name.Replace(',','_').Replace(" ","").Replace('/','_');
+ assemblyFile = assemblyName;
+ try {
+ asm = Assembly.LoadFrom (assemblyFile);
+ }
+ catch {}
+
+ if (asm == null) {
+ Console.WriteLine ("Could not load assembly: " + assemblyFile);
+ return false;
+ }
+ }
+ else
+ {
+ asm = FindAssembly (assemblyName);
+
+ if (asm == null) {
+ Console.WriteLine ("Could not load assembly: " + assemblyName);
+ return false;
+ }
+
+ assemblyName = asm.GetName().FullName;
+ name = EncodeGacAssemblyName (assemblyName);
+ assemblyFile = asm.Location;
+ }
+
+ realAssemblyName = assemblyName;
+
+ // Update references to other assemblies
+
+ AssemblyName[] names = asm.GetReferencedAssemblies ();
+ references = new string [names.Length];
+
+ for (int n=0; n<names.Length; n++)
+ references [n] = "Assembly:" + names [n].ToString();
+
+ return true;
+ }
+
+ public string GetFullAssemblyName (string s)
+ {
+ if (s.ToLower().EndsWith (".dll"))
+ return s;
+
+ Assembly asm = FindAssembly (s);
+
+ if (asm != null)
+ return asm.GetName().FullName;
+ else
+ return s;
+ }
+
+ public void GenerateDatabase (string baseDir, string assemblyName)
+ {
+ if (ServiceManager.GetService (typeof(MonodocService)) == null)
+ ServiceManager.AddService (new MonodocService());
+
+ DefaultParserService parserService = new DefaultParserService ();
+ parserService.GenerateAssemblyDatabase (baseDir, assemblyName);
+ }
+
+ Assembly FindAssembly (string name)
+ {
+ Assembly asm = null;
+ try {
+ asm = Assembly.Load (name);
+ }
+ catch {}
+
+ if (asm == null) {
+ try {
+ asm = Assembly.LoadWithPartialName (name);
+ }
+ catch {}
+ }
+ return asm;
+ }
+
+ string EncodeGacAssemblyName (string assemblyName)
+ {
+ string[] assemblyPieces = assemblyName.Split(',');
+ string res = "";
+ foreach (string item in assemblyPieces) {
+ string[] pieces = item.Trim ().Split (new char[] { '=' }, 2);
+ if(pieces.Length == 1)
+ res += pieces[0];
+ else if (!(pieces[0] == "Culture" && pieces[1] != "Neutral"))
+ res += "_" + pieces[1];
+ }
+ return res;
+ }
+ }
+
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs 2005-07-11 14:12:47 UTC (rev 2624)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs 2005-07-11 14:19:57 UTC (rev 2625)
@@ -594,6 +594,22 @@
}
}
+ public IClass[] GetClassList ()
+ {
+ lock (rwlock)
+ {
+ ArrayList list = new ArrayList ();
+ foreach (FileEntry fe in files.Values) {
+ ClassEntry ce = fe.FirstClass;
+ while (ce != null) {
+ list.Add (GetClass (ce));
+ ce = ce.NextInFile;
+ }
+ }
+ return (IClass[]) list.ToArray (typeof(IClass));
+ }
+ }
+
public void GetNamespaceList (ArrayList list, string subNameSpace, bool caseSensitive)
{
lock (rwlock)
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-07-11 14:12:47 UTC (rev 2624)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-07-11 14:19:57 UTC (rev 2625)
@@ -783,6 +783,15 @@
return null;
}
+ public IClass[] GetProjectContents (Project project)
+ {
+ CodeCompletionDatabase db = GetProjectDatabase (project);
+ if (db != null)
+ return db.GetClassList ();
+ else
+ return new IClass[0];
+ }
+
public string[] GetClassList (Project project, string subNameSpace, bool includeReferences)
{
return GetClassList (project, subNameSpace, includeReferences, true);
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs 2005-07-11 14:12:47 UTC (rev 2624)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs 2005-07-11 14:19:57 UTC (rev 2625)
@@ -68,6 +68,7 @@
IEnumerable GetClassInheritanceTree (Project project, IClass cls);
IClass[] GetFileContents (Project project, string fileName);
+ IClass[] GetProjectContents (Project project);
////////////////////////////////////////////
More information about the Monodevelop-patches-list
mailing list