Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2009-01-13 21:39:13 +0300
committerLluis Sanchez <lluis@novell.com>2009-01-13 21:39:13 +0300
commitbb3214f61a3a856f0a5a1e5811ec0d2d7b692029 (patch)
tree900cc266c42adfbb2e8f3d4c1712568a7cbdb151 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad
parent265120e84f255555248a4434a9ade561d77bc02b (diff)
* MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/GoToDialog.cs: Use a
faster comparer when sorting the results. * MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs: * MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs: * MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs: * MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs: Optimizations. Don't update the whole project tree when a file changes. Instead, locate the class that has changed and update it. svn path=/trunk/monodevelop/; revision=123231
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs6
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs100
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs113
4 files changed, 108 insertions, 120 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs
index 16c3a7da48..47e49e90d5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassData.cs
@@ -55,6 +55,12 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
get { return project; }
}
+ internal void UpdateFrom (ClassData cd)
+ {
+ cls = cd.cls;
+ project = cd.project;
+ }
+
public override bool Equals (object ob)
{
ClassData other = ob as ClassData;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs
index 307db4e6b4..e53a10a73a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs
@@ -116,12 +116,9 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
{
- ClassData classData = dataObject as ClassData;
- return classData.Class.InnerTypeCount > 0 ||
- classData.Class.MethodCount > 0 ||
- classData.Class.PropertyCount > 0 ||
- classData.Class.FieldCount > 0 ||
- classData.Class.EventCount > 0;
+ // Checking if a class has member is expensive since it requires loading the whole
+ // info from the db, so we always return true here. After all 99% of classes will have members
+ return true;
}
public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs
index fb52b82bcc..5a22f16ea7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/NamespaceNodeBuilder.cs
@@ -83,106 +83,6 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
}
-
-
-
-/* void OnClassInformationChanged (object sender, ClassInformationEventArgs e)
- {
- Hashtable oldStatus = new Hashtable ();
- ArrayList namespacesToClean = new ArrayList ();
- ITreeBuilder tb = Context.GetTreeBuilder ();
-
- foreach (IType cls in e.ClassInformation.Removed) {
- if (tb.MoveToObject (new ClassData (e.Project, cls))) {
- oldStatus [tb.DataItem] = tb.Expanded;
-
- ITreeNavigator np = tb.Clone ();
- np.MoveToParent ();
- oldStatus [np.DataItem] = np.Expanded;
-
- tb.Remove (true);
- }
- namespacesToClean.Add (cls.Namespace);
- }
-
- foreach (IType cls in e.ClassInformation.Modified) {
- if (tb.MoveToObject (new ClassData (e.Project, cls))) {
- oldStatus [tb.DataItem] = tb.Expanded;
-
- ITreeNavigator np = tb.Clone ();
- np.MoveToParent ();
- oldStatus [np.DataItem] = np.Expanded;
-
- tb.Remove (true);
- tb.AddChild (new ClassData (e.Project, cls));
- }
- }
-
- foreach (IType cls in e.ClassInformation.Added) {
- AddClass (e.Project, cls);
- }
-
- // Clean empty namespaces
-
- foreach (string ns in namespacesToClean) {
- string subns = ns;
- while (subns != null) {
- bool found = tb.MoveToObject (new NamespaceData (e.Project, subns));
- if (!found) found = tb.MoveToObject (new NamespaceData (null, subns));
- if (found) {
- while (tb.DataItem is NamespaceData && !tb.HasChildren())
- tb.Remove (true);
- break;
- }
- int i = subns.LastIndexOf ('.');
- if (i != -1) subns = subns.Substring (0,i);
- else subns = null;
- }
- }
-
- // Restore expand status
-
- foreach (DictionaryEntry de in oldStatus) {
- if ((bool)de.Value && tb.MoveToObject (de.Key)) {
- tb.ExpandToNode ();
- tb.Expanded = true;
- }
- }
- }
- */
- void AddClass (Project project, IType cls)
- {
- ITreeBuilder builder = Context.GetTreeBuilder ();
- if (!builder.MoveToObject (project)) {
- return; // The project is not there or may not yet be expanded
- }
-
- if (cls.Namespace == "") {
- builder.AddChild (new ClassData (project, cls));
- } else {
- if (builder.Options ["NestedNamespaces"]) {
- string[] nsparts = cls.Namespace.Split ('.');
- string ns = "";
- foreach (string nsp in nsparts) {
- if (builder.Filled) {
- if (ns.Length > 0) ns += ".";
- ns += nsp;
- if (!builder.MoveToChild (nsp, typeof(NamespaceData))) {
- builder.AddChild (new ProjectNamespaceData (project, ns), true);
- break;
- }
- } else
- break;
- }
- builder.AddChild (new ClassData (project, cls));
- } else {
- if (builder.MoveToChild (cls.Namespace, typeof(NamespaceData)))
- builder.AddChild (new ClassData (project, cls));
- else
- builder.AddChild (new ProjectNamespaceData (project, cls.Namespace));
- }
- }
- }
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs
index 29fd250f46..b480f8608c 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs
@@ -50,25 +50,15 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
projectNameChanged = (SolutionItemRenamedEventHandler) DispatchService.GuiDispatch (new SolutionItemRenamedEventHandler (OnProjectRenamed));
}
- EventHandler<ParsedDocumentEventArgs> compilationUnitUpdated;
+ EventHandler<TypeUpdateInformationEventArgs> compilationUnitUpdated;
protected override void Initialize ()
{
- compilationUnitUpdated = (EventHandler<ParsedDocumentEventArgs>) DispatchService.GuiDispatch (new EventHandler<ParsedDocumentEventArgs> (OnCompilationUnitUpdated));
- ProjectDomService.ParsedDocumentUpdated += compilationUnitUpdated;
+ compilationUnitUpdated = (EventHandler<TypeUpdateInformationEventArgs>) DispatchService.GuiDispatch (new EventHandler<TypeUpdateInformationEventArgs> (OnClassInformationChanged));
+ ProjectDomService.TypesUpdated += compilationUnitUpdated;
}
public override void Dispose ()
{
- ProjectDomService.ParsedDocumentUpdated -= compilationUnitUpdated;
- }
-
- void OnCompilationUnitUpdated (object sender, ParsedDocumentEventArgs args)
- {
- Gtk.Application.Invoke (delegate {
- if (!IdeApp.Workspace.IsOpen)
- return;
- ITreeBuilder tb = Context.GetTreeBuilder ();
- tb.UpdateAll ();
- });
+ ProjectDomService.TypesUpdated -= compilationUnitUpdated;
}
public override Type NodeDataType {
@@ -161,5 +151,100 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad
ITreeBuilder tb = Context.GetTreeBuilder (e.SolutionItem);
if (tb != null) tb.Update ();
}
+
+ void OnClassInformationChanged (object sender, TypeUpdateInformationEventArgs e)
+ {
+ DateTime t = DateTime.Now;
+ Dictionary<object,bool> oldStatus = new Dictionary<object,bool> ();
+ List<string> namespacesToClean = new List<string> ();
+ ITreeBuilder tb = Context.GetTreeBuilder ();
+
+ foreach (IType cls in e.TypeUpdateInformation.Removed) {
+ if (tb.MoveToObject (new ClassData (e.Project, cls))) {
+ oldStatus [tb.DataItem] = tb.Expanded;
+
+ ITreeNavigator np = tb.Clone ();
+ np.MoveToParent ();
+ oldStatus [np.DataItem] = np.Expanded;
+
+ tb.Remove (true);
+ }
+ namespacesToClean.Add (cls.Namespace);
+ }
+
+ foreach (IType cls in e.TypeUpdateInformation.Modified) {
+ ClassData ucd = new ClassData (e.Project, cls);
+ if (tb.MoveToObject (ucd)) {
+ ClassData cd = (ClassData) tb.DataItem;
+ cd.UpdateFrom (ucd);
+ tb.UpdateAll ();
+ }
+ }
+
+ foreach (IType cls in e.TypeUpdateInformation.Added) {
+ AddClass (e.Project, cls);
+ }
+
+ // Clean empty namespaces
+
+ foreach (string ns in namespacesToClean) {
+ string subns = ns;
+ while (subns != null) {
+ bool found = tb.MoveToObject (new ProjectNamespaceData (e.Project, subns));
+ if (!found) found = tb.MoveToObject (new ProjectNamespaceData (null, subns));
+ if (found) {
+ while (tb.DataItem is NamespaceData && !tb.HasChildren())
+ tb.Remove (true);
+ break;
+ }
+ int i = subns.LastIndexOf ('.');
+ if (i != -1) subns = subns.Substring (0,i);
+ else subns = null;
+ }
+ }
+
+ // Restore expand status
+
+ foreach (KeyValuePair<object,bool> de in oldStatus) {
+ if (de.Value && tb.MoveToObject (de.Key)) {
+ tb.ExpandToNode ();
+ tb.Expanded = true;
+ }
+ }
+ }
+
+ void AddClass (Project project, IType cls)
+ {
+ ITreeBuilder builder = Context.GetTreeBuilder ();
+ if (!builder.MoveToObject (project)) {
+ return; // The project is not there or may not yet be expanded
+ }
+
+ if (cls.Namespace == "") {
+ builder.AddChild (new ClassData (project, cls));
+ } else {
+ if (builder.Options ["NestedNamespaces"]) {
+ string[] nsparts = cls.Namespace.Split ('.');
+ string ns = "";
+ foreach (string nsp in nsparts) {
+ if (builder.Filled) {
+ if (ns.Length > 0) ns += ".";
+ ns += nsp;
+ if (!builder.MoveToChild (nsp, typeof(NamespaceData))) {
+ builder.AddChild (new ProjectNamespaceData (project, ns), true);
+ break;
+ }
+ } else
+ break;
+ }
+ builder.AddChild (new ClassData (project, cls));
+ } else {
+ if (builder.MoveToChild (cls.Namespace, typeof(NamespaceData)))
+ builder.AddChild (new ClassData (project, cls));
+ else
+ builder.AddChild (new ProjectNamespaceData (project, cls.Namespace));
+ }
+ }
+ }
}
}