Browse Source

Introduction of IAssemblyList interface and rework of ClassBrowser to operate with assembly lists instead of pure SpecialNodes.

pull/59/merge
Andreas Weizel 12 years ago
parent
commit
1c93eb4096
  1. 143
      src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs
  2. 2
      src/Main/Base/Project/Dom/ClassBrowser/BaseTypesTreeNode.cs
  3. 12
      src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs
  4. 19
      src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs
  5. 8
      src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs
  6. 20
      src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs
  7. 32
      src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs
  8. 28
      src/Main/Base/Project/Dom/IAssemblyList.cs
  9. 12
      src/Main/Base/Project/Dom/IAssemblyModel.cs
  10. 19
      src/Main/Base/Project/Dom/ISolutionAssemblyList.cs
  11. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  12. 10
      src/Main/SharpDevelop/Dom/AssemblyModel.cs
  13. 28
      src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs
  14. 8
      src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs
  15. 6
      src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs
  16. 36
      src/Main/SharpDevelop/Dom/SolutionAssemblyList.cs
  17. 1
      src/Main/SharpDevelop/SharpDevelop.csproj

143
src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs

@ -21,17 +21,18 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public static void Attach(Debugger.Process process) public static void Attach(Debugger.Process process)
{ {
var classBrowser = SD.GetService<IClassBrowser>(); var classBrowser = SD.GetService<IClassBrowser>();
classBrowser.SpecialNodes.Add(new DebuggerProcessTreeNode(process)); classBrowser.AssemblyLists.Add(new DebuggerProcessAssemblyList(process));
} }
public static void Detach(Debugger.Process process) public static void Detach(Debugger.Process process)
{ {
var classBrowser = SD.GetService<IClassBrowser>(); var classBrowser = SD.GetService<IClassBrowser>();
var nodes = classBrowser.SpecialNodes var nodes = classBrowser.AssemblyLists
.Where(n => n.Model == process) .OfType<DebuggerProcessAssemblyList>()
.Where(n => n.Process == process)
.ToArray(); .ToArray();
foreach (var node in nodes) { 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) public Type GetSupportedType(object model)
{ {
if (model is Debugger.Process) if (model is DebuggerProcessAssemblyList)
return typeof(Debugger.Process); return typeof(DebuggerProcessAssemblyList);
if (model is Debugger.Module) if (model is DebuggerModuleModel)
return typeof(Debugger.Module); return typeof(DebuggerModuleModel);
return null; return null;
} }
public ICSharpCode.TreeView.SharpTreeNode CreateTreeNode(object model) public ICSharpCode.TreeView.SharpTreeNode CreateTreeNode(object model)
{ {
if (model is Debugger.Process) if (model is DebuggerProcessAssemblyList)
return new DebuggerProcessTreeNode((Debugger.Process)model); return new DebuggerProcessTreeNode((DebuggerProcessAssemblyList)model);
if (model is Debugger.Module) if (model is DebuggerModuleModel)
return new DebuggerModuleTreeNode((Debugger.Module)model); return new DebuggerModuleTreeNode((DebuggerModuleModel)model);
return null; return null;
} }
} }
class DebuggerProcessTreeNode : ModelCollectionTreeNode class DebuggerProcessAssemblyList : IAssemblyList
{ {
Debugger.Process process; Debugger.Process process;
IMutableModelCollection<Debugger.Module> modules; IMutableModelCollection<DebuggerModuleModel> moduleModels;
public DebuggerProcessTreeNode(Debugger.Process process) public DebuggerProcessAssemblyList(Debugger.Process process)
{ {
if (process == null) if (process == null)
throw new ArgumentNullException("process"); throw new ArgumentNullException("process");
this.process = process; this.process = process;
this.modules = new NullSafeSimpleModelCollection<Debugger.Module>(); this.moduleModels = new NullSafeSimpleModelCollection<DebuggerModuleModel>();
this.modules.AddRange(this.process.Modules); this.moduleModels.AddRange(this.process.Modules.Select(m => new DebuggerModuleModel(m)));
this.Assemblies = new NullSafeSimpleModelCollection<IAssemblyModel>();
this.Assemblies.AddRange(moduleModels.Select(mm => mm.AssemblyModel));
this.process.ModuleLoaded += ModuleLoaded; this.process.ModuleLoaded += ModuleLoaded;
this.process.ModuleUnloaded += ModuleUnloaded; this.process.ModuleUnloaded += ModuleUnloaded;
} }
void ModuleLoaded(object sender, ModuleEventArgs e) 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) 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<IAssemblyModel> Assemblies { get; set; }
public IMutableModelCollection<DebuggerModuleModel> 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() protected override object GetModel()
{ {
return process; return process;
@ -90,7 +131,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
protected override IModelCollection<object> ModelChildren { protected override IModelCollection<object> ModelChildren {
get { 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) public DebuggerModuleModel(Module module)
: base(CreateAssemblyModel(module))
{ {
if (module == null) if (module == null)
throw new ArgumentNullException("module"); throw new ArgumentNullException("module");
this.module = 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<IModelFactory>().CreateAssemblyModel(context);
if (model is IUpdateableAssemblyModel) {
((IUpdateableAssemblyModel)model).Update(EmptyList<IUnresolvedTypeDefinition>.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 { public override object Icon {
@ -144,21 +222,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
var ctx = MenuService.ShowContextMenu(null, assemblyModel, "/SharpDevelop/Services/DebuggerService/ModuleContextMenu"); 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<IModelFactory>().CreateAssemblyModel(context);
if (model is IUpdateableAssemblyModel) {
((IUpdateableAssemblyModel)model).Update(EmptyList<IUnresolvedTypeDefinition>.Instance, module.Assembly.TopLevelTypeDefinitions.SelectMany(td => td.Parts).ToList());
}
return model;
}
} }
/// <summary> /// <summary>
/// RunAssemblyWithDebuggerCommand. /// AddModuleToWorkspaceCommand.
/// </summary> /// </summary>
class AddModuleToWorkspaceCommand : SimpleCommand class AddModuleToWorkspaceCommand : SimpleCommand
{ {
@ -178,7 +245,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
// Create a new copy of this assembly model // Create a new copy of this assembly model
IAssemblyModel newAssemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyModel.Context.Location); IAssemblyModel newAssemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyModel.Context.Location);
if (newAssemblyModel != null) if (newAssemblyModel != null)
classBrowser.AssemblyList.Assemblies.Add(newAssemblyModel); classBrowser.MainAssemblyList.Assemblies.Add(newAssemblyModel);
} }
} }
} }

2
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 // Try to get model from ClassBrowser's assembly list
var classBrowser = SD.GetService<IClassBrowser>(); var classBrowser = SD.GetService<IClassBrowser>();
if (classBrowser != null) { if (classBrowser != null) {
foreach (var assemblyModel in classBrowser.AssemblyList.Assemblies) { foreach (var assemblyModel in classBrowser.MainAssemblyList.Assemblies) {
model = assemblyModel.TopLevelTypeDefinitions[definition.FullTypeName]; model = assemblyModel.TopLevelTypeDefinitions[definition.FullTypeName];
if (model != null) { if (model != null) {
return model; return model;

12
src/Main/Base/Project/Dom/ClassBrowser/ClassBrowserTreeView.cs

@ -12,11 +12,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
#region IClassBrowser implementation #region IClassBrowser implementation
public ICollection<SharpTreeNode> SpecialNodes { public ICollection<IAssemblyList> AssemblyLists {
get { return ((WorkspaceTreeNode)Root).SpecialNodes; } get { return ((WorkspaceTreeNode)Root).AssemblyLists; }
} }
public AssemblyList AssemblyList { public IAssemblyList MainAssemblyList {
get { return ((WorkspaceTreeNode)Root).AssemblyList; } get { return ((WorkspaceTreeNode)Root).AssemblyList; }
set { ((WorkspaceTreeNode)Root).AssemblyList = value; } set { ((WorkspaceTreeNode)Root).AssemblyList = value; }
} }
@ -27,11 +27,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
WorkspaceTreeNode root = new WorkspaceTreeNode(); WorkspaceTreeNode root = new WorkspaceTreeNode();
ClassBrowserTreeView instance = this; ClassBrowserTreeView instance = this;
root.SpecialNodes.CollectionChanged += delegate { root.AssemblyLists.CollectionChanged += delegate {
instance.ShowRoot = root.Children.Count > 1; instance.ShowRoot = root.AssemblyLists.Count > 0;
}; };
root.PropertyChanged += delegate { root.PropertyChanged += delegate {
instance.ShowRoot = root.Children.Count > 1; instance.ShowRoot = root.AssemblyLists.Count > 0;
}; };
this.Root = root; this.Root = root;
} }

19
src/Main/Base/Project/Dom/ClassBrowser/IClassBrowser.cs

@ -9,19 +9,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
public interface IClassBrowser public interface IClassBrowser
{ {
ICollection<SharpTreeNode> SpecialNodes { get; } IAssemblyList MainAssemblyList { get; set; }
AssemblyList AssemblyList { get; set; } ICollection<IAssemblyList> AssemblyLists { get; }
}
public class AssemblyList
{
public string Name { get; set; }
public IMutableModelCollection<IAssemblyModel> Assemblies { get; set; }
public AssemblyList() /*
{ IAssemblyList MainAssemblyList { get; set; }
Name = "<default>"; ICollection<IAssemblyList> AssemblyLists { get; }
Assemblies = new NullSafeSimpleModelCollection<IAssemblyModel>(); */
}
} }
} }

8
src/Main/Base/Project/Dom/ClassBrowser/SolutionTreeNode.cs

@ -12,11 +12,11 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
ISolution solution; ISolution solution;
public SolutionTreeNode(ISolution solution) public SolutionTreeNode(ISolutionAssemblyList solutionAssemblyList)
{ {
if (solution == null) if (solutionAssemblyList == null)
throw new ArgumentNullException("solution"); throw new ArgumentNullException("solutionAssemblyList");
this.solution = solution; this.solution = solutionAssemblyList.Solution;
} }
protected override object GetModel() protected override object GetModel()

20
src/Main/Base/Project/Dom/ClassBrowser/WorkspaceModel.cs

@ -12,12 +12,12 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
/// </summary> /// </summary>
public class WorkspaceModel : System.ComponentModel.INotifyPropertyChanged public class WorkspaceModel : System.ComponentModel.INotifyPropertyChanged
{ {
IMutableModelCollection<SharpTreeNode> specialNodes; IMutableModelCollection<IAssemblyList> assemblyLists;
public IMutableModelCollection<SharpTreeNode> SpecialNodes { public IMutableModelCollection<IAssemblyList> AssemblyLists {
get { return specialNodes; } get { return assemblyLists; }
} }
AssemblyList assemblyList; IAssemblyList mainAssemblyList;
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
@ -28,21 +28,21 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
} }
} }
public AssemblyList AssemblyList { public IAssemblyList MainAssemblyList {
get { get {
return assemblyList; return mainAssemblyList;
} }
set { set {
if (assemblyList != value) { if (mainAssemblyList != value) {
assemblyList = value; mainAssemblyList = value;
OnPropertyChanged("AssemblyList"); OnPropertyChanged("AssemblyList");
} }
} }
} }
public WorkspaceModel() public WorkspaceModel()
{ {
this.specialNodes = new SimpleModelCollection<SharpTreeNode>(); this.assemblyLists = new SimpleModelCollection<IAssemblyList>();
this.AssemblyList = new AssemblyList(); this.MainAssemblyList = new AssemblyList();
} }
} }
} }

32
src/Main/Base/Project/Dom/ClassBrowser/WorkspaceTreeNode.cs

@ -3,8 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using ICSharpCode.NRefactory.Utils;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
@ -26,7 +24,13 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
if (!(x is SolutionTreeNode) && (y is SolutionTreeNode)) if (!(x is SolutionTreeNode) && (y is SolutionTreeNode))
return 1; 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()); return stringComparer.Compare(x.Text.ToString(), y.Text.ToString());
} }
} }
@ -34,19 +38,19 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
WorkspaceModel workspace; WorkspaceModel workspace;
protected static readonly IComparer<SharpTreeNode> ChildNodeComparer = new WorkspaceChildComparer(); protected static readonly IComparer<SharpTreeNode> ChildNodeComparer = new WorkspaceChildComparer();
public IMutableModelCollection<SharpTreeNode> SpecialNodes { public IMutableModelCollection<IAssemblyList> AssemblyLists {
get { return workspace.SpecialNodes; } get { return workspace.AssemblyLists; }
} }
public AssemblyList AssemblyList { public IAssemblyList AssemblyList {
get { return workspace.AssemblyList; } get { return workspace.MainAssemblyList; }
set { workspace.AssemblyList = value; } set { workspace.MainAssemblyList = value; }
} }
public WorkspaceTreeNode() public WorkspaceTreeNode()
{ {
this.workspace = new WorkspaceModel(); this.workspace = new WorkspaceModel();
this.workspace.SpecialNodes.CollectionChanged += SpecialNodesModelCollectionChanged; this.workspace.AssemblyLists.CollectionChanged += AssemblyListsCollectionChanged;
} }
protected override object GetModel() protected override object GetModel()
@ -55,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
} }
protected override IModelCollection<object> ModelChildren { protected override IModelCollection<object> ModelChildren {
get { return workspace.AssemblyList.Assemblies; } get { return workspace.MainAssemblyList.Assemblies; }
} }
protected override IComparer<SharpTreeNode> NodeComparer { protected override IComparer<SharpTreeNode> NodeComparer {
@ -81,12 +85,14 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
protected override void InsertSpecialNodes() protected override void InsertSpecialNodes()
{ {
foreach (var node in workspace.SpecialNodes) { foreach (var assemblyList in workspace.AssemblyLists) {
Children.OrderedInsert(node, ChildNodeComparer); var treeNode = SD.TreeNodeFactory.CreateTreeNode(assemblyList);
if (treeNode != null)
Children.OrderedInsert(treeNode, ChildNodeComparer);
} }
} }
void SpecialNodesModelCollectionChanged(IReadOnlyCollection<SharpTreeNode> removedItems, IReadOnlyCollection<SharpTreeNode> addedItems) void AssemblyListsCollectionChanged(IReadOnlyCollection<IAssemblyList> removedItems, IReadOnlyCollection<IAssemblyList> addedItems)
{ {
SynchronizeModelChildren(); SynchronizeModelChildren();
} }

28
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
{
/// <summary>
/// Base interface for assembly list implementations.
/// </summary>
public interface IAssemblyList
{
string Name { get; set; }
IMutableModelCollection<IAssemblyModel> Assemblies { get; set; }
}
public class AssemblyList : IAssemblyList
{
public string Name { get; set; }
public IMutableModelCollection<IAssemblyModel> Assemblies { get; set; }
public AssemblyList()
{
Name = "<default>";
Assemblies = new NullSafeSimpleModelCollection<IAssemblyModel>();
}
}
}

12
src/Main/Base/Project/Dom/IAssemblyModel.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
@ -47,6 +48,11 @@ namespace ICSharpCode.SharpDevelop.Dom
/// Gets the <see cref="IEntityModelContext"/> of this assembly model. /// Gets the <see cref="IEntityModelContext"/> of this assembly model.
/// </summary> /// </summary>
IEntityModelContext Context { get; } IEntityModelContext Context { get; }
/// <summary>
/// Returns the location of the assembly represented by this model.
/// </summary>
FileName Location { get; }
} }
/// <summary> /// <summary>
@ -103,6 +109,12 @@ namespace ICSharpCode.SharpDevelop.Dom
return null; return null;
} }
} }
public FileName Location {
get {
return null;
}
}
} }
} }

19
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
{
/// <summary>
/// Represents a solution assembly list.
/// </summary>
public interface ISolutionAssemblyList : IAssemblyList
{
/// <summary>
/// Returns the <see cref="ICSharpCode.SharpDevelop.Project.ISolution"/> instance behind this assembly list.
/// </summary>
ISolution Solution { get; }
}
}

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -96,6 +96,7 @@
<Compile Include="Dom\ClassBrowser\TypeDefinitionTreeNode.cs" /> <Compile Include="Dom\ClassBrowser\TypeDefinitionTreeNode.cs" />
<Compile Include="Dom\ClassBrowser\WorkspaceModel.cs" /> <Compile Include="Dom\ClassBrowser\WorkspaceModel.cs" />
<Compile Include="Dom\ClassBrowser\WorkspaceTreeNode.cs" /> <Compile Include="Dom\ClassBrowser\WorkspaceTreeNode.cs" />
<Compile Include="Dom\IAssemblyList.cs" />
<Compile Include="Dom\IAssemblyModel.cs" /> <Compile Include="Dom\IAssemblyModel.cs" />
<Compile Include="Dom\IEntityModelContext.cs" /> <Compile Include="Dom\IEntityModelContext.cs" />
<Compile Include="Dom\IEventModel.cs" /> <Compile Include="Dom\IEventModel.cs" />
@ -105,6 +106,7 @@
<Compile Include="Dom\IModelFactory.cs" /> <Compile Include="Dom\IModelFactory.cs" />
<Compile Include="Dom\INamespaceModel.cs" /> <Compile Include="Dom\INamespaceModel.cs" />
<Compile Include="Dom\IPropertyModel.cs" /> <Compile Include="Dom\IPropertyModel.cs" />
<Compile Include="Dom\ISolutionAssemblyList.cs" />
<Compile Include="Dom\ISymbolModel.cs" /> <Compile Include="Dom\ISymbolModel.cs" />
<Compile Include="Dom\ITypeDefinitionModel.cs" /> <Compile Include="Dom\ITypeDefinitionModel.cs" />
<Compile Include="Dom\ITypeDefinitionModelCollection.cs" /> <Compile Include="Dom\ITypeDefinitionModelCollection.cs" />

10
src/Main/SharpDevelop/Dom/AssemblyModel.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser; 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) public void Update(IUnresolvedFile oldFile, IUnresolvedFile newFile)
{ {
IList<IUnresolvedTypeDefinition> old = EmptyList<IUnresolvedTypeDefinition>.Instance; IList<IUnresolvedTypeDefinition> old = EmptyList<IUnresolvedTypeDefinition>.Instance;

28
src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs

@ -78,13 +78,13 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
#region IClassBrowser implementation #region IClassBrowser implementation
public ICollection<SharpTreeNode> SpecialNodes { public ICollection<IAssemblyList> AssemblyLists {
get { return treeView.SpecialNodes; } get { return treeView.AssemblyLists; }
} }
public AssemblyList AssemblyList { public IAssemblyList MainAssemblyList {
get { return treeView.AssemblyList; } get { return treeView.MainAssemblyList; }
set { treeView.AssemblyList = value; } set { treeView.MainAssemblyList = value; }
} }
#endregion #endregion
@ -141,10 +141,10 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
void ProjectServiceCurrentSolutionChanged(object sender, EventArgs e) void ProjectServiceCurrentSolutionChanged(object sender, EventArgs e)
{ {
foreach (var node in treeView.SpecialNodes.OfType<SolutionTreeNode>().ToArray()) foreach (var node in treeView.AssemblyLists.OfType<ISolutionAssemblyList>().ToArray())
treeView.SpecialNodes.Remove(node); treeView.AssemblyLists.Remove(node);
if (projectService.CurrentSolution != null) if (projectService.CurrentSolution != null)
treeView.SpecialNodes.Add(new SolutionTreeNode(projectService.CurrentSolution)); treeView.AssemblyLists.Add(new SolutionAssemblyList(projectService.CurrentSolution));
} }
void AssemblyListCollectionChanged(IReadOnlyCollection<IAssemblyModel> removedItems, IReadOnlyCollection<IAssemblyModel> addedItems) void AssemblyListCollectionChanged(IReadOnlyCollection<IAssemblyModel> removedItems, IReadOnlyCollection<IAssemblyModel> addedItems)
@ -241,7 +241,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
IAssemblyModel assemblyModel = SafelyCreateAssemblyModelFromFile(assemblyFile); IAssemblyModel assemblyModel = SafelyCreateAssemblyModelFromFile(assemblyFile);
if (assemblyModel != null) { if (assemblyModel != null) {
AssemblyList.Assemblies.Add(assemblyModel); MainAssemblyList.Assemblies.Add(assemblyModel);
} }
} }
@ -263,9 +263,9 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
/// </summary> /// </summary>
void UpdateActiveWorkspace() void UpdateActiveWorkspace()
{ {
if ((AssemblyList != null) && (activeWorkspace != null)) { if ((MainAssemblyList != null) && (activeWorkspace != null)) {
// Temporarily detach from event handler // Temporarily detach from event handler
AssemblyList.Assemblies.CollectionChanged -= AssemblyListCollectionChanged; MainAssemblyList.Assemblies.CollectionChanged -= AssemblyListCollectionChanged;
} }
activeWorkspace = persistedWorkspaces.FirstOrDefault(w => w.IsActive); activeWorkspace = persistedWorkspaces.FirstOrDefault(w => w.IsActive);
@ -276,7 +276,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
defaultWorkspace.IsActive = true; defaultWorkspace.IsActive = true;
} }
AssemblyList.Assemblies.Clear(); MainAssemblyList.Assemblies.Clear();
if (activeWorkspace != null) { if (activeWorkspace != null) {
foreach (string assemblyFile in activeWorkspace.AssemblyFiles) { foreach (string assemblyFile in activeWorkspace.AssemblyFiles) {
AppendAssemblyFileToList(assemblyFile); AppendAssemblyFileToList(assemblyFile);
@ -284,8 +284,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
} }
// Attach to event handler, again. // Attach to event handler, again.
if (AssemblyList != null) { if (MainAssemblyList != null) {
AssemblyList.Assemblies.CollectionChanged += AssemblyListCollectionChanged; MainAssemblyList.Assemblies.CollectionChanged += AssemblyListCollectionChanged;
} }
} }
} }

8
src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs

@ -11,8 +11,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
public Type GetSupportedType(object model) public Type GetSupportedType(object model)
{ {
if (model is ISolution) if (model is ISolutionAssemblyList)
return typeof(ISolution); return typeof(ISolutionAssemblyList);
if (model is IProject) if (model is IProject)
return typeof(IProject); return typeof(IProject);
if (model is INamespaceModel) if (model is INamespaceModel)
@ -28,8 +28,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
public SharpTreeNode CreateTreeNode(object model) public SharpTreeNode CreateTreeNode(object model)
{ {
if (model is ISolution) if (model is ISolutionAssemblyList)
return new SolutionTreeNode((ISolution)model); return new SolutionTreeNode((ISolutionAssemblyList)model);
if (model is IProject) if (model is IProject)
return new ProjectTreeNode((IProject)model); return new ProjectTreeNode((IProject)model);
if (model is INamespaceModel) if (model is INamespaceModel)

6
src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{ {
IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(openFileDialog.FileName); IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(openFileDialog.FileName);
if (assemblyModel != null) 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) { foreach (string assemblyFile in gacDialog.SelectedFileNames) {
IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyFile); IAssemblyModel assemblyModel = modelFactory.SafelyCreateAssemblyModelFromFile(assemblyFile);
if (assemblyModel != null) 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<IClassBrowser>(); var classBrowser = SD.GetService<IClassBrowser>();
if (classBrowser != null) { if (classBrowser != null) {
IAssemblyModel assemblyModel = (IAssemblyModel) parameter; IAssemblyModel assemblyModel = (IAssemblyModel) parameter;
classBrowser.AssemblyList.Assemblies.Remove(assemblyModel); classBrowser.MainAssemblyList.Assemblies.Remove(assemblyModel);
} }
} }
} }

36
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
{
/// <summary>
/// Implements an assembly list representing a solution.
/// </summary>
class SolutionAssemblyList : ISolutionAssemblyList
{
ISolution solution;
public SolutionAssemblyList(ISolution solution)
{
this.solution = solution;
if (solution != null) {
Name = solution.Name;
Assemblies = new NullSafeSimpleModelCollection<IAssemblyModel>();
Assemblies.AddRange(solution.Projects.Select(p => p.AssemblyModel));
}
}
public ISolution Solution {
get {
return solution;
}
}
public string Name { get; set; }
public IMutableModelCollection<IAssemblyModel> Assemblies { get; set; }
}
}

1
src/Main/SharpDevelop/SharpDevelop.csproj

@ -118,6 +118,7 @@
<Compile Include="Dom\NamespaceModel.cs" /> <Compile Include="Dom\NamespaceModel.cs" />
<Compile Include="Dom\NestedTypeDefinitionModelCollection.cs" /> <Compile Include="Dom\NestedTypeDefinitionModelCollection.cs" />
<Compile Include="Dom\AssemblyModel.cs" /> <Compile Include="Dom\AssemblyModel.cs" />
<Compile Include="Dom\SolutionAssemblyList.cs" />
<Compile Include="Dom\TopLevelTypeDefinitionModelCollection.cs" /> <Compile Include="Dom\TopLevelTypeDefinitionModelCollection.cs" />
<Compile Include="Dom\TreeNodeFactoryService.cs" /> <Compile Include="Dom\TreeNodeFactoryService.cs" />
<Compile Include="Dom\TypeDefinitionModel.cs" /> <Compile Include="Dom\TypeDefinitionModel.cs" />

Loading…
Cancel
Save