[Monodevelop-patches-list] r529 - trunk/MonoDevelop/src/Main/Base/Services/ParserService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Jan 17 19:33:20 EST 2004


Author: benm
Date: 2004-01-17 19:33:20 -0500 (Sat, 17 Jan 2004)
New Revision: 529

Modified:
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/ClassProxy.cs
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
Log:
speed up ClassProxy, dont inheirt from the other parser stuff, because that creates *tons* of array lists

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/ClassProxy.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/ClassProxy.cs	2004-01-17 23:34:57 UTC (rev 528)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/ClassProxy.cs	2004-01-18 00:33:20 UTC (rev 529)
@@ -17,59 +17,75 @@
 
 using ICSharpCode.SharpDevelop.Gui;
 
-namespace ICSharpCode.SharpDevelop.Services
-{
-	public class ClassProxy : AbstractClass, IComparable
-	{
-		uint offset = 0;
+namespace ICSharpCode.SharpDevelop.Services {
+	public class ClassProxy : IComparable {
+		public uint Offset = 0;
+		public readonly ClassType ClassType;
+		public readonly string FullyQualifiedName;
+		public readonly ModifierEnum Modifiers;
+		public readonly string Documentation;
+		private string className;
+		private string namespaceName;
 		
-		public uint Offset {
-			get {
-				return offset;
-			}
-			set {
-				offset = value;
-			}
-		}
-		
-		/// <value>
-		/// Class Proxies clases don't have a compilation unit.
-		/// </value>
-		public override ICompilationUnit CompilationUnit {
-			get {
-				return null;
-			}
-		}
-		
 		public int CompareTo(object obj) 
 		{
-			return FullyQualifiedName.CompareTo(((ClassProxy)obj).FullyQualifiedName);
+			return FullyQualifiedName.CompareTo (((ClassProxy) obj).FullyQualifiedName);
 		}
 		
 		public ClassProxy(BinaryReader reader)
 		{
-			FullyQualifiedName = reader.ReadString();
-			documentation      = reader.ReadString();
-			offset             = reader.ReadUInt32();
-			modifiers          = (ModifierEnum)reader.ReadUInt32();
-			classType          = (ClassType)reader.ReadInt16();
+			FullyQualifiedName = reader.ReadString ();
+			Documentation      = reader.ReadString ();
+			Offset             = reader.ReadUInt32 ();
+			Modifiers          = (ModifierEnum) reader.ReadUInt32 ();
+			ClassType          = (ClassType) reader.ReadInt16 ();
 		}
 		
 		public void WriteTo(BinaryWriter writer)
 		{
-			writer.Write(FullyQualifiedName);
-			writer.Write(documentation);
-			writer.Write(offset);
-			writer.Write((uint)modifiers);
-			writer.Write((short)classType);
+			writer.Write (FullyQualifiedName);
+			writer.Write (Documentation);
+			writer.Write (Offset);
+			writer.Write ((uint) Modifiers);
+			writer.Write ((short) ClassType);
 		}
 		
 		public ClassProxy(IClass c)
 		{
 			this.FullyQualifiedName  = c.FullyQualifiedName;
-			this.documentation       = c.Documentation;
-			this.modifiers           = c.Modifiers;
-			this.classType           = c.ClassType;
+			this.Documentation       = c.Documentation;
+			this.Modifiers           = c.Modifiers;
+			this.ClassType           = c.ClassType;
+		}
+		
+		public string Name {
+			get {
+				if (className == null && FullyQualifiedName != null) {
+					int lastIndex = FullyQualifiedName.LastIndexOfAny (new char[] { '.', '+' });
+					
+					if (lastIndex < 0)
+						className = FullyQualifiedName;
+					else
+						className = FullyQualifiedName.Substring(lastIndex + 1);
+				}
+				
+				return className;
+			}
+		}
+
+		public string Namespace {
+			get {
+				if (namespaceName == null && FullyQualifiedName != null) {
+					int lastIndex = FullyQualifiedName.LastIndexOf ('.');
+					
+					if (lastIndex < 0)
+						namespaceName = string.Empty;
+					else
+						namespaceName = FullyQualifiedName.Substring (0, lastIndex);
+				}
+				
+				return namespaceName;
+			}
 		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-01-17 23:34:57 UTC (rev 528)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-01-18 00:33:20 UTC (rev 529)
@@ -434,6 +434,34 @@
 				
 				return cur;
 			}
+		}
+		
+		Hashtable AddClassToNamespaceList(ClassProxy addClass)
+		{
+			string nSpace = addClass.Namespace;
+			if (nSpace == null) {
+				nSpace = String.Empty;
+			}
+			string[] path = nSpace.Split('.');
+			
+			lock (namespaces) {
+				Hashtable cur = namespaces;
+				
+				for (int i = 0; i < path.Length; ++i) {
+					if (cur[path[i]] == null) {
+						cur[path[i]] = new Hashtable();
+					} else {
+						if (!(cur[path[i]] is Hashtable)) {
+							return null;
+						}
+					}
+					cur = (Hashtable)cur[path[i]];
+				}
+				
+				cur[addClass.Name] = addClass;
+				
+				return cur;
+			}
 		}
 
 		public ArrayList GetNamespaceContents(string subNameSpace)




More information about the Monodevelop-patches-list mailing list