Author: mhutch
Date: 2007-09-19 13:13:16 -0400 (Wed, 19 Sep 2007)
New Revision: 86023
Added:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs
Modified:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/ChangeLog
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/Makefile.am
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.mdp
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindService.cs
Log:
* MonoDevelop.DesignerSupport.mdp,
MonoDevelop.DesignerSupport/CodeBehindService.cs,
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs,
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs,
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs,
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs,
Makefile.am: In CodeBehind service, track class names rather than
IClasses, as IClasses can change. Now much more careful to trigger
only the rebuilding of nodes which need to be rebuilt. May still be
some performance issues on large projects (from linear lookups of
class names, and requirement for CodeBehind parent parsing to
happen at project load time).
Modified: trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/ChangeLog
2007-09-19 16:55:17 UTC (rev 86022)
+++ trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/ChangeLog
2007-09-19 17:13:16 UTC (rev 86023)
@@ -1,5 +1,20 @@
2007-09-19 Michael Hutchinson <[EMAIL PROTECTED]>
+ * MonoDevelop.DesignerSupport.mdp,
+ MonoDevelop.DesignerSupport/CodeBehindService.cs,
+
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs,
+
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs,
+ MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs,
+ MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs,
Makefile.am:
+ In CodeBehind service, track class names rather than IClasses, as
+ IClasses can change. Now much more careful to trigger only the
+ rebuilding of nodes which need to be rebuilt. May still be some
+ performance issues on large projects (from linear lookups of class
+ names, and requirement for CodeBehind parent parsing to happen at
+ project load time).
+
+2007-09-19 Michael Hutchinson <[EMAIL PROTECTED]>
+
* MonoDevelop.DesignerSupport.addin.xml,
MonoDevelop.DesignerSupport/CodeBehindService.cs,
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs,
Modified: trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/Makefile.am
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/Makefile.am
2007-09-19 16:55:17 UTC (rev 86022)
+++ trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/Makefile.am
2007-09-19 17:13:16 UTC (rev 86023)
@@ -23,6 +23,8 @@
FILES = \
gtk-gui/generated.cs \
gtk-gui/MonoDevelop.DesignerSupport.Toolbox.ComponentSelectorDialog.cs \
+ MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs \
+ MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs \
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindDisplayBinding.cs \
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs
\
MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs \
Modified:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindService.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindService.cs
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/CodeBehindService.cs
2007-09-19 17:13:16 UTC (rev 86023)
@@ -30,6 +30,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+//#define DEBUGCODEBEHINDGROUPING
+
using System;
using System.Collections.Generic;
@@ -47,7 +49,7 @@
public class CodeBehindService
{
- Dictionary<ProjectFile, IClass> codeBehindBindings = new
Dictionary<ProjectFile, IClass> ();
+ Dictionary<ProjectFile, string> codeBehindBindings = new
Dictionary<ProjectFile, string> ();
#region Extension loading
@@ -64,7 +66,6 @@
IdeApp.ProjectOperations.FileAddedToProject +=
onFileEvent;
IdeApp.ProjectOperations.FileChangedInProject +=
onFileEvent;
IdeApp.ProjectOperations.FileRemovedFromProject +=
onFileEvent;
- //IdeApp.ProjectOperations.FileRenamedInProject -=
IdeApp.ProjectOperations.CombineClosed +=
onCombineClosed;
IdeApp.ProjectOperations.CombineOpened +=
onCombineOpened;
@@ -117,53 +118,64 @@
void onClassInformationChanged (object sender,
ClassInformationEventArgs e)
{
+#if DEBUGCODEBEHINDGROUPING
+ System.Console.WriteLine("onClassInformationChanged");
+ foreach (IClass cls in e.ClassInformation.Added)
+ System.Console.WriteLine("Added:{0}",
cls.FullyQualifiedName);
+ foreach (IClass cls in e.ClassInformation.Modified)
+ System.Console.WriteLine("Modified:{0}",
cls.FullyQualifiedName);
+ foreach (IClass cls in e.ClassInformation.Removed)
+ System.Console.WriteLine("Removed:{0}",
cls.FullyQualifiedName);
+#endif
+ if (e.Project == null)
+ return;
+
//have to queue up operations outside the foreaches or
the collections get out of synch
- List<KeyValuePair<ProjectFile, IClass>> updates = new
List<KeyValuePair<ProjectFile, IClass>> ();
+ List<ProjectFile> affectedChildren = new
List<ProjectFile> ();
+ List<ProjectFile> affectedParents = new
List<ProjectFile> ();
- //build a list of all relevant class changes
- foreach (KeyValuePair<ProjectFile, IClass> kvp in
codeBehindBindings) {
+ //find all ProjectFiles affected by the relevant class
updates
+ foreach (KeyValuePair<ProjectFile, string> kvp in
codeBehindBindings) {
//codebehind must be in same project as file
if (e.Project != kvp.Key.Project) continue;
+ bool affected = false;
foreach (IClass cls in
e.ClassInformation.Removed) {
- if (cls.FullyQualifiedName ==
kvp.Value.FullyQualifiedName) {
- //if class has gone missing,
create a dummy one
- NotFoundClass dummy = new
NotFoundClass ();
- dummy.FullyQualifiedName =
cls.FullyQualifiedName;
- updates.Add (new
KeyValuePair<ProjectFile, IClass> (kvp.Key, dummy));
- break;
+ if (cls.FullyQualifiedName ==
kvp.Value) {
+ AddAffectedFilesFromClass
(e.Project, cls, affectedChildren);
+ affected = true;
}
}
foreach (IClass cls in
e.ClassInformation.Added) {
- if (cls.FullyQualifiedName ==
kvp.Value.FullyQualifiedName) {
- updates.Add (new
KeyValuePair<ProjectFile, IClass> (kvp.Key, cls));
- break;
+ if (cls.FullyQualifiedName ==
kvp.Value) {
+ AddAffectedFilesFromClass
(e.Project, cls, affectedChildren);
+ affected = true;
}
}
- foreach (IClass cls in
e.ClassInformation.Modified) {
- if (cls.FullyQualifiedName ==
kvp.Value.FullyQualifiedName) {
- updates.Add (new
KeyValuePair<ProjectFile, IClass> (kvp.Key, cls));
- break;
- }
+ if (affected) {
+#if DEBUGCODEBEHINDGROUPING
+ System.Console.WriteLine("File affected
{0}", kvp.Key.FilePath);
+#endif
+ affectedParents.Add (kvp.Key);
}
}
- //apply class changes to the codeBehindBindings
collection
- foreach (KeyValuePair<ProjectFile, IClass> update in
updates) {
- IClass oldCB = codeBehindBindings[update.Key];
- IClass newCB = update.Value;
-
- if (oldCB == newCB && oldCB.Parts.Length ==
newCB.Parts.Length)
- //skip on if no change in class
- continue;
-
- codeBehindBindings[update.Key] = newCB;
-
- if (CodeBehindClassUpdated != null) {
- CodeBehindClassUpdated (oldCB);
- CodeBehindClassUpdated (newCB);
+ if (CodeBehindClassUpdated != null &&
affectedParents.Count > 0)
+ CodeBehindClassUpdated (this, new
CodeBehindClassEventArgs (e.Project, affectedParents, affectedChildren));
+
+ }
+
+ void AddAffectedFilesFromClass (Project project, IClass cls,
List<ProjectFile> list)
+ {
+ foreach (IClass part in cls.Parts) {
+ ProjectFile pf = project.ProjectFiles.GetFile
(part.Region.FileName);
+ if (pf != null && !list.Contains (pf)) {
+ list.Add (pf);
+#if DEBUGCODEBEHINDGROUPING
+ System.Console.WriteLine("Added
affected file {0}", pf.FilePath);
+#endif
}
}
}
@@ -195,77 +207,85 @@
void updateCodeBehind (ProjectFile file)
{
- IClass newCodeBehind = null;
- IClass oldCodeBehind = null;
+ if (file.Project == null)
+ return;
+ string newCodeBehind = null;
+ string oldCodeBehind = null;
+
+ codeBehindBindings.TryGetValue (file, out
oldCodeBehind);
+
+ //get the fully-qualified name of the codebehind class
if present
foreach (ICodeBehindProvider provider in providers) {
- //get the fully-qualified name of the
codebehind class if present
string name = provider.GetCodeBehindClassName
(file);
-
if (name != null) {
- //look it up in the parser database
- IParserContext ctx =
IdeApp.ProjectOperations.ParserDatabase.GetProjectParserContext (file.Project);
- newCodeBehind = ctx.GetClass (name);
-
- //if class was not found, create a
dummy one
- if (newCodeBehind == null) {
- NotFoundClass dummy = new
NotFoundClass ();
- dummy.FullyQualifiedName = name;
- newCodeBehind = dummy;
- }
+ newCodeBehind = name;
break;
}
}
- bool containsKey = this.codeBehindBindings.ContainsKey
(file);
+ //if no changes have happened, bail early
+ if (newCodeBehind == oldCodeBehind)
+ return;
- if (newCodeBehind == null) {
- if (containsKey) {
- //was codebehind, but no longer
- oldCodeBehind =
this.codeBehindBindings[file];
- this.codeBehindBindings.Remove (file);
- } else {
- //not codebehind, no updates
- return;
- }
- } else {
- if (containsKey) {
- //updating an existing binding
- oldCodeBehind =
this.codeBehindBindings[file];
-
- //if no changes have happened, bail
early
- if (oldCodeBehind == newCodeBehind)
return;
- }
-
- this.codeBehindBindings[file] = newCodeBehind;
- if (CodeBehindClassUpdated != null)
- CodeBehindClassUpdated (newCodeBehind);
+ //update the bindings list
+ if (newCodeBehind == null)
+ codeBehindBindings.Remove (file);
+ else
+ codeBehindBindings[file] = newCodeBehind;
+
+ //build a list of affected "child" files
+ List<ProjectFile> affectedChildren = new
List<ProjectFile> ();
+ IParserContext ctx =
IdeApp.ProjectOperations.ParserDatabase.GetProjectParserContext (file.Project);
+ if (newCodeBehind != null) {
+ IClass cls = ctx.GetClass (newCodeBehind);
+ if (cls != null)
+ AddAffectedFilesFromClass
(file.Project, cls, affectedChildren);
}
+ if (oldCodeBehind != null) {
+ IClass cls = ctx.GetClass (newCodeBehind);
+ if (cls != null)
+ AddAffectedFilesFromClass
(file.Project, cls, affectedChildren);
+ }
- if (CodeBehindFileUpdated != null)
- CodeBehindFileUpdated (file);
-
- if (oldCodeBehind != null && CodeBehindClassUpdated !=
null)
- CodeBehindClassUpdated (oldCodeBehind);
+ if (CodeBehindClassUpdated != null)
+ CodeBehindClassUpdated (this, new
CodeBehindClassEventArgs (file.Project, new ProjectFile[] { file } ,
affectedChildren));
}
#region public API for finding CodeBehind files
public bool HasChildren (ProjectFile file)
{
- IClass cls = GetChildClass (file);
+#if DEBUGCODEBEHINDGROUPING
+ System.Console.WriteLine("Checking whether {0} has
children",file.FilePath);
+#endif
+ CodeBehindClass cls = GetChildClass (file);
if (cls == null) return false;
- if (cls is NotFoundClass) return true;
- IList<ProjectFile> children = GetProjectFileChildren
(file, cls);
+ if (cls.IClass == null) return true;
+ IList<ProjectFile> children = GetProjectFileChildren
(file, cls.IClass);
return children != null && children.Count > 0;
}
- public IClass GetChildClass (ProjectFile file)
+ public CodeBehindClass GetChildClass (ProjectFile file)
{
+#if DEBUGCODEBEHINDGROUPING
+ System.Console.WriteLine("Getting child class for {0}",
file.FilePath);
+#endif
IClass cls = null;
- if (file != null)
- codeBehindBindings.TryGetValue (file, out cls);
- return cls;
+ if (file != null && file.Project != null) {
+ string clsName = null;
+ codeBehindBindings.TryGetValue (file, out
clsName);
+ if (clsName != null) {
+ IParserContext ctx =
IdeApp.ProjectOperations.ParserDatabase.GetProjectParserContext (file.Project);
+ cls = ctx.GetClass (clsName);
+ if (cls != null) {
+ return new CodeBehindClass
(cls);
+ } else {
+ return new CodeBehindClass
(clsName);
+ }
+ }
+ }
+ return null;
}
internal IList<ProjectFile> GetProjectFileChildren (ProjectFile
parent, IClass child)
@@ -292,11 +312,6 @@
return files;
}
- public bool IsCodeBehind (IClass cls)
- {
- return codeBehindBindings.ContainsValue (cls);
- }
-
//determines whether a file contains only codebehind classes
public bool ContainsCodeBehind (ProjectFile file)
{
@@ -309,30 +324,17 @@
return false;
foreach (IClass cls in classes)
- if (cls.SourceProject == file.Project)
- foreach (IClass boundCls in
codeBehindBindings.Values)
- if (cls.FullyQualifiedName ==
boundCls.FullyQualifiedName)
- return true;
+ foreach (KeyValuePair<ProjectFile, string> kvp
in codeBehindBindings)
+ if (kvp.Key.Project == file.Project &&
kvp.Value == cls.FullyQualifiedName)
+ return true;
return false;
}
- //fired when a CodeBehind class is updated
+ //fired when a CodeBehind association is updated
public event CodeBehindClassEventHandler CodeBehindClassUpdated;
- public delegate void CodeBehindClassEventHandler (IClass cls);
+ public delegate void CodeBehindClassEventHandler (object
sender, CodeBehindClassEventArgs e);
- //fired when a codebehind 'host' file is updated
- public event CodeBehindFileEventHandler CodeBehindFileUpdated;
- public delegate void CodeBehindFileEventHandler (ProjectFile
file);
-
#endregion
-
- //used for references to classes not found in the parse database
- internal class NotFoundClass : DefaultClass
- {
- public override IClass[] Parts {
- get { return new IClass[] { }; }
- }
- }
}
}
Added:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs
2007-09-19 17:13:16 UTC (rev 86023)
@@ -0,0 +1,59 @@
+// CodeBehindClass.cs
+//
+// Author:
+// Michael Hutchinson <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+
+using MonoDevelop.Projects.Parser;
+
+namespace MonoDevelop.DesignerSupport.CodeBehind
+{
+
+
+ public class CodeBehindClass
+ {
+ string fullyQualifiedName;
+ IClass cls;
+
+ public CodeBehindClass (string name)
+ {
+ fullyQualifiedName = name;
+ }
+
+ public CodeBehindClass (IClass cls)
+ {
+ fullyQualifiedName = cls.FullyQualifiedName;
+ this.cls = cls;
+ }
+
+ public string FullyQualifiedName {
+ get { return fullyQualifiedName; }
+ }
+
+ public IClass IClass {
+ get { return cls; }
+ }
+ }
+}
Added:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs
2007-09-19 17:13:16 UTC (rev 86023)
@@ -0,0 +1,67 @@
+// CodeBehindClassEventArgs.cs
+//
+// Author:
+// Michael Hutchinson <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.DesignerSupport.CodeBehind
+{
+
+
+ public class CodeBehindClassEventArgs
+ {
+ ICollection<ProjectFile> childFiles;
+ ICollection<ProjectFile> parentFiles;
+ Project project;
+
+ public CodeBehindClassEventArgs (Project affectedProject,
IList<ProjectFile> parentFiles, IList<ProjectFile> childFiles)
+ {
+ this.project = affectedProject;
+ this.childFiles = childFiles;
+ this.parentFiles = parentFiles;
+ }
+
+ public ICollection<ProjectFile> ChildFiles {
+ get {
+ return childFiles;
+ }
+ }
+
+ public ICollection<ProjectFile> ParentFiles {
+ get {
+ return parentFiles;
+ }
+ }
+
+ public Project Project {
+ get {
+ return project;
+ }
+ }
+ }
+}
Modified:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindMissingClassBuilder.cs
2007-09-19 17:13:16 UTC (rev 86023)
@@ -41,7 +41,7 @@
class CodeBehindMissingClassBuilder: TypeNodeBuilder
{
public override Type NodeDataType {
- get { return typeof
(MonoDevelop.DesignerSupport.CodeBehindService.NotFoundClass); }
+ get { return typeof (CodeBehindClass); }
}
public override string GetNodeName (ITreeNavigator thisNode,
object dataObject)
@@ -51,8 +51,7 @@
public override void BuildNode (ITreeBuilder treeBuilder,
object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf
closedIcon)
{
- IClass cls = (IClass) dataObject;
- icon = Context.GetIcon
(MonoDevelop.Ide.Gui.IdeApp.Services.Icons.GetIcon (cls));
+ CodeBehindClass cls = (CodeBehindClass) dataObject;
label = "<span foreground='red'>" +
MonoDevelop.Core.GettextCatalog.GetString("Missing CodeBehind class {0}",
cls.FullyQualifiedName) + "</span>";
}
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.CodeBehind/CodeBehindProjectFileExtension.cs
2007-09-19 17:13:16 UTC (rev 86023)
@@ -47,45 +47,34 @@
public class CodeBehindProjectFileExtension : NodeBuilderExtension
{
CodeBehindService.CodeBehindClassEventHandler
classChangeHandler;
- CodeBehindService.CodeBehindFileEventHandler fileChangeHandler;
protected override void Initialize ()
{
classChangeHandler =
(CodeBehindService.CodeBehindClassEventHandler)
DispatchService.GuiDispatch (new
CodeBehindService.CodeBehindClassEventHandler (onClassChanged));
DesignerSupport.Service.CodeBehindService.CodeBehindClassUpdated +=
classChangeHandler;
-
- fileChangeHandler =
(CodeBehindService.CodeBehindFileEventHandler)
- DispatchService.GuiDispatch (new
CodeBehindService.CodeBehindFileEventHandler (onFileChanged));
-
DesignerSupport.Service.CodeBehindService.CodeBehindFileUpdated +=
fileChangeHandler;
}
public override void Dispose ()
{
DesignerSupport.Service.CodeBehindService.CodeBehindClassUpdated -=
classChangeHandler;
-
DesignerSupport.Service.CodeBehindService.CodeBehindFileUpdated -=
fileChangeHandler;
}
- void onFileChanged (ProjectFile file)
+ void onClassChanged (object sender, CodeBehindClassEventArgs e)
{
- if (file.Project != null) {
- ITreeBuilder builder = Context.GetTreeBuilder
(file.Project);
+ if (e.ChildFiles.Count > 0) {
+ ITreeBuilder builder = Context.GetTreeBuilder
(e.Project);
if (builder != null)
builder.UpdateAll ();
+ } else {
+ foreach (ProjectFile affected in e.ParentFiles)
{
+ ITreeBuilder builder =
Context.GetTreeBuilder (affected);
+ if (builder != null)
+ builder.UpdateAll ();
+ }
}
}
- void onClassChanged (IClass cls)
- {
- //refresh the file containing the class to make it
hidden/visible
- //we can't locate the node in the tree more efficiently
than looking up its parent project
- if (cls.SourceProject == null)
- return;
- ITreeBuilder builder = Context.GetTreeBuilder
(cls.SourceProject);
- if (builder != null)
- builder.UpdateAll ();
- }
-
public override bool CanBuildNode (Type dataType)
{
return typeof (ProjectFile).IsAssignableFrom (dataType);
@@ -95,11 +84,11 @@
{
if (builder.Options ["GroupCodeBehind"]) {
ProjectFile file = (ProjectFile) dataObject;
- IClass cls =
DesignerSupport.Service.CodeBehindService.GetChildClass (file);
- if (cls is
MonoDevelop.DesignerSupport.CodeBehindService.NotFoundClass) {
+ CodeBehindClass cls =
DesignerSupport.Service.CodeBehindService.GetChildClass (file);
+ if (cls.IClass == null) {
builder.AddChild (cls);
} else {
- IList<ProjectFile> children =
DesignerSupport.Service.CodeBehindService.GetProjectFileChildren (file, cls);
+ IList<ProjectFile> children =
DesignerSupport.Service.CodeBehindService.GetProjectFileChildren (file,
cls.IClass);
foreach (ProjectFile child in children)
builder.AddChild (child);
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.mdp
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.mdp
2007-09-19 16:55:17 UTC (rev 86022)
+++
trunk/monodevelop/Extras/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.mdp
2007-09-19 17:13:16 UTC (rev 86023)
@@ -91,6 +91,8 @@
<File name="./MonoDevelop.DesignerSupport.Toolbox/ToolboxConfiguration.cs"
subtype="Code" buildaction="Compile" />
<File name="./MonoDevelop.DesignerSupport/Commands.cs" subtype="Code"
buildaction="Compile" />
<File
name="./MonoDevelop.DesignerSupport.Projects/PropertyPadTextEditorExtension.cs"
subtype="Code" buildaction="Compile" />
+ <File
name="./MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClassEventArgs.cs"
subtype="Code" buildaction="Compile" />
+ <File name="./MonoDevelop.DesignerSupport.CodeBehind/CodeBehindClass.cs"
subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches