Author: lluis
Date: 2007-06-13 11:23:56 -0400 (Wed, 13 Jun 2007)
New Revision: 79431
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs
Log:
* MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs: Read
assembly's references only when the assembly has changed since it
was parsed for the last time. Reduces loading time.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog 2007-06-13
15:18:21 UTC (rev 79430)
+++ trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog 2007-06-13
15:23:56 UTC (rev 79431)
@@ -1,3 +1,9 @@
+2007-06-13 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs: Read
+ assembly's references only when the assembly has changed since it
+ was parsed for the last time. Reduces loading time.
+
2007-06-06 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.Projects.Serialization/GenericCollectionHandler.cs: Unset
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs
2007-06-13 15:18:21 UTC (rev 79430)
+++
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/AssemblyCodeCompletionDatabase.cs
2007-06-13 15:23:56 UTC (rev 79431)
@@ -48,6 +48,7 @@
bool loadError;
bool isPackageAssembly;
bool parsing;
+ string assemblyFile;
// This is the package version of the assembly. It is
serialized.
string packageVersion;
@@ -55,11 +56,9 @@
public AssemblyCodeCompletionDatabase (string baseDir, string
assemblyName, ParserDatabase parserDatabase)
: base (parserDatabase)
{
- string assemblyFile;
- string[] refUris;
string name;
- if (!GetAssemblyInfo (assemblyName, out
this.assemblyName, out assemblyFile, out name, out refUris)) {
+ if (!GetAssemblyInfo (assemblyName, out
this.assemblyName, out assemblyFile, out name)) {
loadError = true;
return;
}
@@ -86,22 +85,26 @@
headers ["CheckFile"] = assemblyFile;
}
- // Update references to other assemblies
-
- Hashtable rs = new Hashtable ();
- foreach (string uri in refUris) {
- rs[uri] = null;
- if (!HasReference (uri))
- AddReference (uri);
+ FileEntry fe = GetFile (assemblyFile);
+ if (IsFileModified (fe)) {
+ string[] refUris = ReadAssemblyReferences ();
+ // Update references to other assemblies
+
+ Hashtable rs = new Hashtable ();
+ foreach (string uri in refUris) {
+ rs[uri] = null;
+ if (!HasReference (uri))
+ AddReference (uri);
+ }
+
+ ArrayList keys = new ArrayList ();
+ keys.AddRange (references);
+ foreach (ReferenceEntry re in keys)
+ {
+ if (!rs.Contains (re.Uri))
+ RemoveReference (re.Uri);
+ }
}
-
- ArrayList keys = new ArrayList ();
- keys.AddRange (references);
- foreach (ReferenceEntry re in keys)
- {
- if (!rs.Contains (re.Uri))
- RemoveReference (re.Uri);
- }
}
protected override bool IsFileModified (FileEntry file)
@@ -233,14 +236,12 @@
return new DatabaseGenerator ();
}
- public bool GetAssemblyInfo (string assemblyName, out string
realAssemblyName, out string assemblyFile, out string name, out string[]
references)
+ public bool GetAssemblyInfo (string assemblyName, out string
realAssemblyName, out string assemblyFile, out string name)
{
name = null;
assemblyFile = null;
realAssemblyName = null;
- references = null;
- AssemblyDefinition asm = null;
string ext = Path.GetExtension (assemblyName).ToLower
();
if (ext == ".dll" || ext == ".exe")
@@ -248,43 +249,47 @@
name = assemblyName.Substring (0,
assemblyName.Length - 4);
name = name.Replace(',','_').Replace("
","").Replace('/','_');
assemblyFile = assemblyName;
- try {
- asm =
AssemblyFactory.GetAssemblyManifest (assemblyFile);
- }
- catch {}
-
- if (asm == null) {
- Console.WriteLine ("Could not load
assembly: " + assemblyFile);
- return false;
- }
}
else
{
assemblyFile =
Runtime.SystemAssemblyService.GetAssemblyLocation (assemblyName);
- if (assemblyFile != null && File.Exists
(assemblyFile))
- asm =
AssemblyFactory.GetAssemblyManifest (assemblyFile);
-
- if (asm == null) {
+ bool gotname = false;
+ if (assemblyFile != null && File.Exists
(assemblyFile)) {
+ try {
+ assemblyName =
AssemblyName.GetAssemblyName (assemblyFile).FullName;
+ gotname = true;
+ } catch (Exception ex) {
+ Runtime.LoggingService.Error
(ex);
+ }
+ }
+ if (!gotname) {
Console.WriteLine ("Could not load
assembly: " + assemblyName);
return false;
}
-
- assemblyName = asm.Name.FullName;
name = EncodeGacAssemblyName (assemblyName);
}
realAssemblyName = assemblyName;
+ return true;
+ }
+
+ public string[] ReadAssemblyReferences ()
+ {
+ try {
+ AssemblyDefinition asm =
AssemblyFactory.GetAssemblyManifest (assemblyFile);
- // Update references to other assemblies
-
- AssemblyNameReferenceCollection names =
asm.MainModule.AssemblyReferences;
- references = new string [names.Count];
+ AssemblyNameReferenceCollection names =
asm.MainModule.AssemblyReferences;
+ string[] references = new string [names.Count];
- for (int n=0; n<names.Count; n++)
- references [n] = "Assembly:" + names
[n].FullName;
-
- return true;
+ for (int n=0; n<names.Count; n++)
+ references [n] = "Assembly:" + names
[n].FullName;
+ return references;
+
+ } catch (Exception ex) {
+ Runtime.LoggingService.Error (ex);
+ return null;
+ }
}
string EncodeGacAssemblyName (string assemblyName)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches