diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs index e289bf5e16..3c7ea4ca64 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs @@ -21,17 +21,18 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads public static void Attach(Debugger.Process process) { var classBrowser = SD.GetService(); - classBrowser.SpecialNodes.Add(new DebuggerProcessTreeNode(process)); + classBrowser.AssemblyLists.Add(new DebuggerProcessAssemblyList(process)); } public static void Detach(Debugger.Process process) { var classBrowser = SD.GetService(); - var nodes = classBrowser.SpecialNodes - .Where(n => n.Model == process) + var nodes = classBrowser.AssemblyLists + .OfType() + .Where(n => n.Process == process) .ToArray(); foreach (var node in nodes) { - classBrowser.SpecialNodes.Remove(node); + classBrowser.AssemblyLists.Remove(node); } } } @@ -40,49 +41,89 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { public Type GetSupportedType(object model) { - if (model is Debugger.Process) - return typeof(Debugger.Process); - if (model is Debugger.Module) - return typeof(Debugger.Module); + if (model is DebuggerProcessAssemblyList) + return typeof(DebuggerProcessAssemblyList); + if (model is DebuggerModuleModel) + return typeof(DebuggerModuleModel); return null; } public ICSharpCode.TreeView.SharpTreeNode CreateTreeNode(object model) { - if (model is Debugger.Process) - return new DebuggerProcessTreeNode((Debugger.Process)model); - if (model is Debugger.Module) - return new DebuggerModuleTreeNode((Debugger.Module)model); + if (model is DebuggerProcessAssemblyList) + return new DebuggerProcessTreeNode((DebuggerProcessAssemblyList)model); + if (model is DebuggerModuleModel) + return new DebuggerModuleTreeNode((DebuggerModuleModel)model); return null; } } - class DebuggerProcessTreeNode : ModelCollectionTreeNode + class DebuggerProcessAssemblyList : IAssemblyList { Debugger.Process process; - IMutableModelCollection modules; - - public DebuggerProcessTreeNode(Debugger.Process process) + IMutableModelCollection moduleModels; + + public DebuggerProcessAssemblyList(Debugger.Process process) { if (process == null) throw new ArgumentNullException("process"); this.process = process; - this.modules = new NullSafeSimpleModelCollection(); - this.modules.AddRange(this.process.Modules); + this.moduleModels = new NullSafeSimpleModelCollection(); + this.moduleModels.AddRange(this.process.Modules.Select(m => new DebuggerModuleModel(m))); + this.Assemblies = new NullSafeSimpleModelCollection(); + this.Assemblies.AddRange(moduleModels.Select(mm => mm.AssemblyModel)); this.process.ModuleLoaded += ModuleLoaded; this.process.ModuleUnloaded += ModuleUnloaded; } void ModuleLoaded(object sender, ModuleEventArgs e) { - modules.Add(e.Module); + DebuggerModuleModel model = new DebuggerModuleModel(e.Module); + moduleModels.Add(model); + Assemblies.Add(model.AssemblyModel); } void ModuleUnloaded(object sender, ModuleEventArgs e) { - modules.Remove(e.Module); + DebuggerModuleModel deletedModel = moduleModels.FirstOrDefault(mm => mm.Module == e.Module); + if (deletedModel != null) { + moduleModels.Remove(deletedModel); + Assemblies.Remove(deletedModel.AssemblyModel); + } } + + public string Name { get; set; } + public IMutableModelCollection Assemblies { get; set; } + + public IMutableModelCollection ModuleModels + { + get { + return moduleModels; + } + } + + public Debugger.Process Process + { + get { + return process; + } + } + } + + class DebuggerProcessTreeNode : ModelCollectionTreeNode + { + Debugger.Process process; + DebuggerProcessAssemblyList assemblyList; + + public DebuggerProcessTreeNode(DebuggerProcessAssemblyList assemblyList) + { + if (assemblyList == null) + throw new ArgumentNullException("assemblyList"); + this.assemblyList = assemblyList; + this.process = assemblyList.Process; + } + protected override object GetModel() { return process; @@ -90,7 +131,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads protected override IModelCollection ModelChildren { get { - return modules; + return assemblyList.ModuleModels; } } @@ -113,16 +154,53 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } } - class DebuggerModuleTreeNode : AssemblyTreeNode + class DebuggerModuleModel { - Debugger.Module module; + Module module; + IAssemblyModel assemblyModel; - public DebuggerModuleTreeNode(Module module) - : base(CreateAssemblyModel(module)) + public DebuggerModuleModel(Module module) { if (module == null) throw new ArgumentNullException("module"); this.module = module; + this.assemblyModel = CreateAssemblyModel(module); + } + + public Module Module + { + get { + return module; + } + } + + public IAssemblyModel AssemblyModel + { + get { + return assemblyModel; + } + } + + static IAssemblyModel CreateAssemblyModel(Module module) + { + // references?? + IEntityModelContext context = new AssemblyEntityModelContext(module.Assembly.UnresolvedAssembly); + IAssemblyModel model = SD.GetRequiredService().CreateAssemblyModel(context); + if (model is IUpdateableAssemblyModel) { + ((IUpdateableAssemblyModel)model).Update(EmptyList.Instance, module.Assembly.TopLevelTypeDefinitions.SelectMany(td => td.Parts).ToList()); + } + return model; + } + } + + class DebuggerModuleTreeNode : AssemblyTreeNode + { + Debugger.Module module; + + public DebuggerModuleTreeNode(DebuggerModuleModel model) + : base(model.AssemblyModel) + { + this.module = model.Module; } public override object Icon { @@ -144,21 +222,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads var ctx = MenuService.ShowContextMenu(null, assemblyModel, "/SharpDevelop/Services/DebuggerService/ModuleContextMenu"); } } - - static IAssemblyModel CreateAssemblyModel(Module module) - { - // references?? - IEntityModelContext context = new AssemblyEntityModelContext(module.Assembly.UnresolvedAssembly); - IAssemblyModel model = SD.GetRequiredService().CreateAssemblyModel(context); - if (model is IUpdateableAssemblyModel) { - ((IUpdateableAssemblyModel)model).Update(EmptyList.Instance, module.Assembly.TopLevelTypeDefinitions.SelectMany(td => td.Parts).ToList()); - } - return model; - } } /// - /// RunAssemblyWithDebuggerCommand. + /// AddModuleToWorkspaceCommand. /// class AddModuleToWorkspaceCommand : SimpleCommand { @@ -178,7 +245,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads // Create a new copy of this assembly model IAssemblyModel newAssemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyModel.Context.Location); if (newAssemblyModel != null) - classBrowser.AssemblyList.Assemblies.Add(newAssemblyModel); + classBrowser.MainAssemblyList.Assemblies.Add(newAssemblyModel); } } } diff --git a/src/Main/Base/Project/Dom/ClassBrowser/BaseTypesTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/BaseTypesTreeNode.cs index e663588ad0..0297c65ac6 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/BaseTypesTreeNode.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/BaseTypesTreeNode.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser // Try to get model from ClassBrowser's assembly list var classBrowser = SD.GetService(); if (classBrowser != null) { - foreach (var assemblyModel in classBrowser.AssemblyList.Assemblies) { + foreach (var assemblyModel in classBrowser.MainAssemblyList.Assemblies) { model = assemblyModel.TopLevelTypeDefinitions[definition.FullTypeName]; if (model != null) { return model; diff --git a/src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs b/src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs index 0a02246a14..792804a706 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs @@ -12,11 +12,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { #region IClassBrowser implementation - public ICollection SpecialNodes { - get { return ((WorkspaceTreeNode)Root).SpecialNodes; } + public ICollection AssemblyLists { + get { return ((WorkspaceTreeNode)Root).AssemblyLists; } } - public AssemblyList AssemblyList { + public IAssemblyList MainAssemblyList { get { return ((WorkspaceTreeNode)Root).AssemblyList; } set { ((WorkspaceTreeNode)Root).AssemblyList = value; } } @@ -27,11 +27,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { WorkspaceTreeNode root = new WorkspaceTreeNode(); ClassBrowserTreeView instance = this; - root.SpecialNodes.CollectionChanged += delegate { - instance.ShowRoot = root.Children.Count > 1; + root.AssemblyLists.CollectionChanged += delegate { + instance.ShowRoot = root.AssemblyLists.Count > 0; }; root.PropertyChanged += delegate { - instance.ShowRoot = root.Children.Count > 1; + instance.ShowRoot = root.AssemblyLists.Count > 0; }; this.Root = root; } diff --git a/src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs b/src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs index ab715b3cb4..b326dc5c02 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs @@ -9,19 +9,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { public interface IClassBrowser { - ICollection SpecialNodes { get; } - AssemblyList AssemblyList { get; set; } - } - - public class AssemblyList - { - public string Name { get; set; } - public IMutableModelCollection Assemblies { get; set; } + IAssemblyList MainAssemblyList { get; set; } + ICollection AssemblyLists { get; } - public AssemblyList() - { - Name = ""; - Assemblies = new NullSafeSimpleModelCollection(); - } + /* + IAssemblyList MainAssemblyList { get; set; } + ICollection AssemblyLists { get; } + */ } } diff --git a/src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs index 962d69e5db..de10610ebe 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs @@ -12,11 +12,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { ISolution solution; - public SolutionTreeNode(ISolution solution) + public SolutionTreeNode(ISolutionAssemblyList solutionAssemblyList) { - if (solution == null) - throw new ArgumentNullException("solution"); - this.solution = solution; + if (solutionAssemblyList == null) + throw new ArgumentNullException("solutionAssemblyList"); + this.solution = solutionAssemblyList.Solution; } protected override object GetModel() diff --git a/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs b/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs index 9e3e1da6e6..55b36892ac 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs @@ -12,12 +12,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser /// public class WorkspaceModel : System.ComponentModel.INotifyPropertyChanged { - IMutableModelCollection specialNodes; - public IMutableModelCollection SpecialNodes { - get { return specialNodes; } + IMutableModelCollection assemblyLists; + public IMutableModelCollection AssemblyLists { + get { return assemblyLists; } } - AssemblyList assemblyList; + IAssemblyList mainAssemblyList; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; @@ -28,21 +28,21 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser } } - public AssemblyList AssemblyList { + public IAssemblyList MainAssemblyList { get { - return assemblyList; + return mainAssemblyList; } set { - if (assemblyList != value) { - assemblyList = value; + if (mainAssemblyList != value) { + mainAssemblyList = value; OnPropertyChanged("AssemblyList"); } } } public WorkspaceModel() { - this.specialNodes = new SimpleModelCollection(); - this.AssemblyList = new AssemblyList(); + this.assemblyLists = new SimpleModelCollection(); + this.MainAssemblyList = new AssemblyList(); } } } diff --git a/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs index cf40c2ceb4..fd6e1c29ca 100644 --- a/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs +++ b/src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; -using ICSharpCode.NRefactory.Utils; using ICSharpCode.TreeView; namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser @@ -26,7 +24,13 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser if (!(x is SolutionTreeNode) && (y is SolutionTreeNode)) return 1; - // Both nodes are solutions or not solutions, compare their Text property + // AssemblyTreeNodes (no derived node classes!) appear at the bottom of list + if ((x.GetType() == typeof(AssemblyTreeNode)) && (y.GetType() != typeof(AssemblyTreeNode))) + return 1; + if ((x.GetType() != typeof(AssemblyTreeNode)) && (y.GetType() == typeof(AssemblyTreeNode))) + return -1; + + // All other nodes are compared by their Text property return stringComparer.Compare(x.Text.ToString(), y.Text.ToString()); } } @@ -34,19 +38,19 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser WorkspaceModel workspace; protected static readonly IComparer ChildNodeComparer = new WorkspaceChildComparer(); - public IMutableModelCollection SpecialNodes { - get { return workspace.SpecialNodes; } + public IMutableModelCollection AssemblyLists { + get { return workspace.AssemblyLists; } } - public AssemblyList AssemblyList { - get { return workspace.AssemblyList; } - set { workspace.AssemblyList = value; } + public IAssemblyList AssemblyList { + get { return workspace.MainAssemblyList; } + set { workspace.MainAssemblyList = value; } } public WorkspaceTreeNode() { this.workspace = new WorkspaceModel(); - this.workspace.SpecialNodes.CollectionChanged += SpecialNodesModelCollectionChanged; + this.workspace.AssemblyLists.CollectionChanged += AssemblyListsCollectionChanged; } protected override object GetModel() @@ -55,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser } protected override IModelCollection ModelChildren { - get { return workspace.AssemblyList.Assemblies; } + get { return workspace.MainAssemblyList.Assemblies; } } protected override IComparer NodeComparer { @@ -81,12 +85,14 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser protected override void InsertSpecialNodes() { - foreach (var node in workspace.SpecialNodes) { - Children.OrderedInsert(node, ChildNodeComparer); + foreach (var assemblyList in workspace.AssemblyLists) { + var treeNode = SD.TreeNodeFactory.CreateTreeNode(assemblyList); + if (treeNode != null) + Children.OrderedInsert(treeNode, ChildNodeComparer); } } - void SpecialNodesModelCollectionChanged(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems) + void AssemblyListsCollectionChanged(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems) { SynchronizeModelChildren(); } diff --git a/src/Main/Base/Project/Dom/IAssemblyList.cs b/src/Main/Base/Project/Dom/IAssemblyList.cs new file mode 100644 index 0000000000..fc3a3194bc --- /dev/null +++ b/src/Main/Base/Project/Dom/IAssemblyList.cs @@ -0,0 +1,28 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; + +namespace ICSharpCode.SharpDevelop.Dom +{ + /// + /// Base interface for assembly list implementations. + /// + public interface IAssemblyList + { + string Name { get; set; } + IMutableModelCollection Assemblies { get; set; } + } + + public class AssemblyList : IAssemblyList + { + public string Name { get; set; } + public IMutableModelCollection Assemblies { get; set; } + + public AssemblyList() + { + Name = ""; + Assemblies = new NullSafeSimpleModelCollection(); + } + } +} diff --git a/src/Main/Base/Project/Dom/IAssemblyModel.cs b/src/Main/Base/Project/Dom/IAssemblyModel.cs index f3df5c2589..379a3b68f5 100644 --- a/src/Main/Base/Project/Dom/IAssemblyModel.cs +++ b/src/Main/Base/Project/Dom/IAssemblyModel.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using ICSharpCode.Core; using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.SharpDevelop.Dom @@ -47,6 +48,11 @@ namespace ICSharpCode.SharpDevelop.Dom /// Gets the of this assembly model. /// IEntityModelContext Context { get; } + + /// + /// Returns the location of the assembly represented by this model. + /// + FileName Location { get; } } /// @@ -103,6 +109,12 @@ namespace ICSharpCode.SharpDevelop.Dom return null; } } + + public FileName Location { + get { + return null; + } + } } } diff --git a/src/Main/Base/Project/Dom/ISolutionAssemblyList.cs b/src/Main/Base/Project/Dom/ISolutionAssemblyList.cs new file mode 100644 index 0000000000..4ff2750491 --- /dev/null +++ b/src/Main/Base/Project/Dom/ISolutionAssemblyList.cs @@ -0,0 +1,19 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.SharpDevelop.Dom +{ + /// + /// Represents a solution assembly list. + /// + public interface ISolutionAssemblyList : IAssemblyList + { + /// + /// Returns the instance behind this assembly list. + /// + ISolution Solution { get; } + } +} \ No newline at end of file diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 7cef0ecbf2..78ac881be1 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -96,6 +96,7 @@ + @@ -105,6 +106,7 @@ + diff --git a/src/Main/SharpDevelop/Dom/AssemblyModel.cs b/src/Main/SharpDevelop/Dom/AssemblyModel.cs index b10684186e..cd7d41a5b7 100644 --- a/src/Main/SharpDevelop/Dom/AssemblyModel.cs +++ b/src/Main/SharpDevelop/Dom/AssemblyModel.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using ICSharpCode.Core; using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop.Parser; @@ -56,6 +57,15 @@ namespace ICSharpCode.SharpDevelop.Dom } } + public FileName Location { + get { + if (context != null) { + return new FileName(context.Location); + } + return null; + } + } + public void Update(IUnresolvedFile oldFile, IUnresolvedFile newFile) { IList old = EmptyList.Instance; diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs index eb29053cba..e1e38821cd 100644 --- a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs +++ b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs @@ -78,13 +78,13 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { #region IClassBrowser implementation - public ICollection SpecialNodes { - get { return treeView.SpecialNodes; } + public ICollection AssemblyLists { + get { return treeView.AssemblyLists; } } - public AssemblyList AssemblyList { - get { return treeView.AssemblyList; } - set { treeView.AssemblyList = value; } + public IAssemblyList MainAssemblyList { + get { return treeView.MainAssemblyList; } + set { treeView.MainAssemblyList = value; } } #endregion @@ -141,10 +141,10 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser void ProjectServiceCurrentSolutionChanged(object sender, EventArgs e) { - foreach (var node in treeView.SpecialNodes.OfType().ToArray()) - treeView.SpecialNodes.Remove(node); + foreach (var node in treeView.AssemblyLists.OfType().ToArray()) + treeView.AssemblyLists.Remove(node); if (projectService.CurrentSolution != null) - treeView.SpecialNodes.Add(new SolutionTreeNode(projectService.CurrentSolution)); + treeView.AssemblyLists.Add(new SolutionAssemblyList(projectService.CurrentSolution)); } void AssemblyListCollectionChanged(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems) @@ -241,7 +241,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { IAssemblyModel assemblyModel = SafelyCreateAssemblyModelFromFile(assemblyFile); if (assemblyModel != null) { - AssemblyList.Assemblies.Add(assemblyModel); + MainAssemblyList.Assemblies.Add(assemblyModel); } } @@ -263,9 +263,9 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser /// void UpdateActiveWorkspace() { - if ((AssemblyList != null) && (activeWorkspace != null)) { + if ((MainAssemblyList != null) && (activeWorkspace != null)) { // Temporarily detach from event handler - AssemblyList.Assemblies.CollectionChanged -= AssemblyListCollectionChanged; + MainAssemblyList.Assemblies.CollectionChanged -= AssemblyListCollectionChanged; } activeWorkspace = persistedWorkspaces.FirstOrDefault(w => w.IsActive); @@ -276,7 +276,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser defaultWorkspace.IsActive = true; } - AssemblyList.Assemblies.Clear(); + MainAssemblyList.Assemblies.Clear(); if (activeWorkspace != null) { foreach (string assemblyFile in activeWorkspace.AssemblyFiles) { AppendAssemblyFileToList(assemblyFile); @@ -284,8 +284,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser } // Attach to event handler, again. - if (AssemblyList != null) { - AssemblyList.Assemblies.CollectionChanged += AssemblyListCollectionChanged; + if (MainAssemblyList != null) { + MainAssemblyList.Assemblies.CollectionChanged += AssemblyListCollectionChanged; } } } diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs index 23fe3fcb2f..e3ceb7a8b2 100644 --- a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs +++ b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs @@ -11,8 +11,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { public Type GetSupportedType(object model) { - if (model is ISolution) - return typeof(ISolution); + if (model is ISolutionAssemblyList) + return typeof(ISolutionAssemblyList); if (model is IProject) return typeof(IProject); if (model is INamespaceModel) @@ -28,8 +28,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser public SharpTreeNode CreateTreeNode(object model) { - if (model is ISolution) - return new SolutionTreeNode((ISolution)model); + if (model is ISolutionAssemblyList) + return new SolutionTreeNode((ISolutionAssemblyList)model); if (model is IProject) return new ProjectTreeNode((IProject)model); if (model is INamespaceModel) diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs index c98047cb2e..fd72bb2a5f 100644 --- a/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs +++ b/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser { IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(openFileDialog.FileName); if (assemblyModel != null) - classBrowser.AssemblyList.Assemblies.Add(assemblyModel); + classBrowser.MainAssemblyList.Assemblies.Add(assemblyModel); } } } @@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser foreach (string assemblyFile in gacDialog.SelectedFileNames) { IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyFile); if (assemblyModel != null) - classBrowser.AssemblyList.Assemblies.Add(assemblyModel); + classBrowser.MainAssemblyList.Assemblies.Add(assemblyModel); } } } @@ -72,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser var classBrowser = SD.GetService(); if (classBrowser != null) { IAssemblyModel assemblyModel = (IAssemblyModel) parameter; - classBrowser.AssemblyList.Assemblies.Remove(assemblyModel); + classBrowser.MainAssemblyList.Assemblies.Remove(assemblyModel); } } } diff --git a/src/Main/SharpDevelop/Dom/SolutionAssemblyList.cs b/src/Main/SharpDevelop/Dom/SolutionAssemblyList.cs new file mode 100644 index 0000000000..627f5888ec --- /dev/null +++ b/src/Main/SharpDevelop/Dom/SolutionAssemblyList.cs @@ -0,0 +1,36 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.SharpDevelop.Dom +{ + /// + /// Implements an assembly list representing a solution. + /// + class SolutionAssemblyList : ISolutionAssemblyList + { + ISolution solution; + + public SolutionAssemblyList(ISolution solution) + { + this.solution = solution; + if (solution != null) { + Name = solution.Name; + Assemblies = new NullSafeSimpleModelCollection(); + Assemblies.AddRange(solution.Projects.Select(p => p.AssemblyModel)); + } + } + + public ISolution Solution { + get { + return solution; + } + } + + public string Name { get; set; } + + public IMutableModelCollection Assemblies { get; set; } + } +} \ No newline at end of file diff --git a/src/Main/SharpDevelop/SharpDevelop.csproj b/src/Main/SharpDevelop/SharpDevelop.csproj index 8eed81e197..ea0f0aec54 100644 --- a/src/Main/SharpDevelop/SharpDevelop.csproj +++ b/src/Main/SharpDevelop/SharpDevelop.csproj @@ -118,6 +118,7 @@ +