diff options
author | Mike Krüger <mkrueger@novell.com> | 2011-06-16 21:33:05 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2011-06-17 17:04:20 +0400 |
commit | 9070e9bec1383f72ec82f6c7523b82e4d4a0f6ea (patch) | |
tree | dba17f47cfc06a08dab200bc78dc7644c8d33008 /main/src/addins/MonoDevelop.AssemblyBrowser | |
parent | a65475b26b616be6528329deb7897635f6a440c7 (diff) |
Started type system translation.
I choose now to let the browser work on cecil directly instead of
using the type system, but I think I need to revert that and keep the
type system because of the ambience. I'll add a type system -> cecil
mapping in the class loader.
Diffstat (limited to 'main/src/addins/MonoDevelop.AssemblyBrowser')
23 files changed, 383 insertions, 436 deletions
diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/Makefile.am b/main/src/addins/MonoDevelop.AssemblyBrowser/Makefile.am index 1f85db4cff..1e50caad62 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/Makefile.am +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/Makefile.am @@ -19,7 +19,6 @@ FILES = \ MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs \ MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs \ MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs \ - MonoDevelop.AssemblyBrowser/DomReturnTypeNodeBuilder.cs \ MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs \ MonoDevelop.AssemblyBrowser/Error.cs \ MonoDevelop.AssemblyBrowser/ErrorNodeBuilder.cs \ diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj index d17786ccd4..19f3deaafe 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.csproj @@ -126,7 +126,6 @@ <Compile Include="MonoDevelop.AssemblyBrowser\ModuleReferenceNodeBuilder.cs" /> <Compile Include="MonoDevelop.AssemblyBrowser\BaseTypeFolder.cs" /> <Compile Include="MonoDevelop.AssemblyBrowser\BaseTypeFolderNodeBuilder.cs" /> - <Compile Include="MonoDevelop.AssemblyBrowser\DomReturnTypeNodeBuilder.cs" /> <Compile Include="MonoDevelop.AssemblyBrowser\IAssemblyBrowserNodeBuilder.cs" /> <Compile Include="gtk-gui\generated.cs" /> <Compile Include="gtk-gui\MonoDevelop.AssemblyBrowser.AssemblyBrowserWidget.cs" /> diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs index e9b1835f6a..81aa94b8c4 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs @@ -24,8 +24,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; +using ICSharpCode.NRefactory.TypeSystem; +using System; +using Mono.Cecil; namespace MonoDevelop.AssemblyBrowser { @@ -36,7 +38,7 @@ namespace MonoDevelop.AssemblyBrowser private set; } - protected Ambience Ambience { + protected MonoDevelop.TypeSystem.Ambience Ambience { get { return Widget.Ambience; } @@ -46,5 +48,10 @@ namespace MonoDevelop.AssemblyBrowser { this.Widget = assemblyBrowserWidget; } + + protected IProjectContent GetContent (ITreeBuilder treeBuilder) + { + return ((Tuple<AssemblyDefinition, IProjectContent>)treeBuilder.GetParentDataItem (typeof(Tuple<AssemblyDefinition, IProjectContent>), true)).Item2; + } } } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserView.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserView.cs index f5227a0f04..9d3ddad8df 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserView.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserView.cs @@ -28,8 +28,6 @@ using MonoDevelop.Ide; using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; using MonoDevelop.Refactoring; using System; @@ -85,31 +83,32 @@ namespace MonoDevelop.AssemblyBrowser } #endregion - - [MonoDevelop.Components.Commands.CommandHandler(MonoDevelop.Refactoring.RefactoryCommands.FindReferences)] - public void FindReferences () - { - IMember member = widget.ActiveMember; - if (member == null) - return; - ProjectDom dom = ProjectDomService.GetProjectDom (IdeApp.ProjectOperations.CurrentSelectedProject); - if (dom == null) - return; - Refactorer refactorer = new Refactorer (dom, null, null, member, null); - refactorer.FindReferences (); - } - - [MonoDevelop.Components.Commands.CommandHandler(MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses)] - public void FindDerivedClasses () - { - IMember member = widget.ActiveMember; - if (member == null) - return; - ProjectDom dom = ProjectDomService.GetProjectDom (IdeApp.ProjectOperations.CurrentSelectedProject); - if (dom == null) - return; - Refactorer refactorer = new Refactorer (dom, null, null, member, null); - refactorer.FindDerivedClasses (); - } + +// TODO: Type system conversion. +// [MonoDevelop.Components.Commands.CommandHandler(MonoDevelop.Refactoring.RefactoryCommands.FindReferences)] +// public void FindReferences () +// { +// IMember member = widget.ActiveMember; +// if (member == null) +// return; +// ITypeResolveContext dom = TypeSystemService.GetProjectDom (IdeApp.ProjectOperations.CurrentSelectedProject); +// if (dom == null) +// return; +// Refactorer refactorer = new Refactorer (dom, null, null, member, null); +// refactorer.FindReferences (); +// } +// +// [MonoDevelop.Components.Commands.CommandHandler(MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses)] +// public void FindDerivedClasses () +// { +// IMember member = widget.ActiveMember; +// if (member == null) +// return; +// ITypeResolveContext dom = TypeSystemService.GetProjectDom (IdeApp.ProjectOperations.CurrentSelectedProject); +// if (dom == null) +// return; +// Refactorer refactorer = new Refactorer (dom, null, null, member, null); +// refactorer.FindDerivedClasses (); +// } } } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs index 500bb3312f..a8ee0a955c 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs @@ -39,10 +39,10 @@ using MonoDevelop.Core; using MonoDevelop.Ide; using MonoDevelop.Ide.Commands; using MonoDevelop.Ide.Gui.Components; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using System.Linq; using Mono.TextEditor; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.AssemblyBrowser { @@ -69,7 +69,7 @@ namespace MonoDevelop.AssemblyBrowser Mono.TextEditor.TextEditor inspectEditor = new Mono.TextEditor.TextEditor (); public AssemblyBrowserWidget () { - this.Build(); + this.Build (); TreeView = new ExtensibleTreeView (new NodeBuilder[] { new ErrorNodeBuilder (), new AssemblyNodeBuilder (this), @@ -85,7 +85,6 @@ namespace MonoDevelop.AssemblyBrowser new DomEventNodeBuilder (this), new DomPropertyNodeBuilder (this), new BaseTypeFolderNodeBuilder (this), - new DomReturnTypeNodeBuilder (this), new ReferenceNodeBuilder (this), }, new TreePadOption [] { new TreePadOption ("PublicApiOnly", GettextCatalog.GetString ("Show public members only"), true) @@ -123,31 +122,33 @@ namespace MonoDevelop.AssemblyBrowser var referencedSegment = ReferencedSegments != null ? ReferencedSegments.FirstOrDefault (seg => seg.Contains (offset)) : null; if (referencedSegment == null) return null; - if (referencedSegment.Reference is TypeDefinition) - return new DomCecilType ((TypeDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is MethodDefinition) - return new DomCecilMethod ((MethodDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is PropertyDefinition) - return new DomCecilProperty ((PropertyDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is FieldDefinition) - return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is EventDefinition) - return new DomCecilEvent ((EventDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is FieldDefinition) - return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl; - - if (referencedSegment.Reference is TypeReference) { - var returnType = DomCecilMethod.GetReturnType ((TypeReference)referencedSegment.Reference); - if (returnType.GenericArguments.Count == 0) - return "T:" + returnType.FullName; - return "T:" + returnType.FullName + "`" + returnType.GenericArguments.Count; - } - return referencedSegment.Reference.ToString (); + return null; +// TODO: Type system conversion. +// if (referencedSegment.Reference is TypeDefinition) +// return new DomCecilType ((TypeDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is MethodDefinition) +// return new DomCecilMethod ((MethodDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is PropertyDefinition) +// return new DomCecilProperty ((PropertyDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is FieldDefinition) +// return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is EventDefinition) +// return new DomCecilEvent ((EventDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is FieldDefinition) +// return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl; +// +// if (referencedSegment.Reference is TypeReference) { +// var returnType = DomCecilMethod.GetReturnType ((TypeReference)referencedSegment.Reference); +// if (returnType.GenericArguments.Count == 0) +// return "T:" + returnType.FullName; +// return "T:" + returnType.FullName + "`" + returnType.GenericArguments.Count; +// } +// return referencedSegment.Reference.ToString (); }; this.inspectEditor.LinkRequest += InspectEditorhandleLinkRequest; @@ -255,8 +256,8 @@ namespace MonoDevelop.AssemblyBrowser { Gtk.TreeIter selectedIter; if (searchTreeview.Selection.GetSelected (out selectedIter)) { - MonoDevelop.Projects.Dom.IMember member = (MonoDevelop.Projects.Dom.IMember)(searchMode != SearchMode.Type ? memberListStore.GetValue (selectedIter, 4) : typeListStore.GetValue (selectedIter, 4)); - ITreeNavigator nav = SearchMember (member); + var member = (IMemberDefinition)(searchMode != SearchMode.Type ? memberListStore.GetValue (selectedIter, 4) : typeListStore.GetValue (selectedIter, 4)); + var nav = SearchMember (member); if (nav != null) { nav.ExpandToNode (); nav.Selected = true; @@ -290,20 +291,20 @@ namespace MonoDevelop.AssemblyBrowser } void InspectEditorhandleLinkRequest (object sender, Mono.TextEditor.LinkEventArgs args) - { - if (args.Button == 2 || (args.Button == 1 && (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)) { + { // TODO: Type system conversion. +/* if (args.Button == 2 || (args.Button == 1 && (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)) { AssemblyBrowserViewContent assemblyBrowserView = new AssemblyBrowserViewContent (); - foreach (DomCecilCompilationUnit cu in definitions) { + foreach (var cu in definitions) { assemblyBrowserView.Load (cu.FileName); } IdeApp.Workbench.OpenDocument (assemblyBrowserView, true); ((AssemblyBrowserWidget)assemblyBrowserView.Control).Open (args.Link); } else { this.Open (args.Link); - } + }*/ } - public MonoDevelop.Projects.Dom.IMember ActiveMember { + public IMember ActiveMember { get; set; } @@ -320,9 +321,11 @@ namespace MonoDevelop.AssemblyBrowser ((Mono.TextEditor.TextEditorOptions)this.inspectEditor.Options).ColorScheme = PropertyService.Get ("ColorScheme", "Default"); } - ITreeNavigator SearchMember (IMember member) + ITreeNavigator SearchMember (IMemberDefinition member) { - return SearchMember (member.HelpUrl); + // TODO: Type system conversion + // return SearchMember (member.HelpUrl); + return null; } ITreeNavigator SearchMember (string helpUrl) @@ -331,9 +334,10 @@ namespace MonoDevelop.AssemblyBrowser } static bool IsMatch (ITreeNavigator nav, string helpUrl) - { - IMember member = nav.DataItem as IMember; - return member != null && member.HelpUrl == helpUrl; + { // TODO: Type system conversion. +// IMember member = nav.DataItem as IMember; +// return member != null && member.HelpUrl == helpUrl; + return false; } static bool SkipChildren (ITreeNavigator nav, string helpUrl) @@ -365,7 +369,7 @@ namespace MonoDevelop.AssemblyBrowser if (!nav.MoveToParent ()) return null; try { - if (nav.DataItem is DomCecilType && nav.Options["PublicApiOnly"]) { + if (nav.DataItem is TypeDefinition && nav.Options["PublicApiOnly"]) { nav.Options["PublicApiOnly"] = false; nav.MoveToFirstChild (); result = SearchMember (nav, helpUrl); @@ -488,35 +492,37 @@ namespace MonoDevelop.AssemblyBrowser string pattern = e.Argument.ToString ().ToUpper (); int types = 0, curType = 0; - foreach (DomCecilCompilationUnit unit in this.definitions) { - types += unit.Types.Count; + foreach (var unit in this.definitions) { + foreach (var module in unit.Value.Modules) + types += module.Types.Count; } - List<IMember> members = new List<IMember> (); + var members = new List<IMemberDefinition> (); switch (searchMode) { case SearchMode.Member: - foreach (DomCecilCompilationUnit unit in this.definitions) { - foreach (IType type in unit.Types) { - if (worker.CancellationPending) - return; - curType++; - foreach (IMember member in type.Members) { + foreach (var unit in this.definitions) { + foreach (var module in unit.Value.Modules) + foreach (var type in module.Types) { if (worker.CancellationPending) return; - if (member.Name.ToUpper ().Contains (pattern)) { - members.Add (member); + curType++; + foreach (var member in type.Methods.Cast<IMemberDefinition> ().Concat (type.Properties).Concat (type.Fields).Concat (type.Events)) { + if (worker.CancellationPending) + return; + if (member.Name.ToUpper ().Contains (pattern)) { + members.Add (member); + } } } - } } Gtk.Application.Invoke (delegate { IdeApp.Workbench.StatusBar.SetProgressFraction ((double)curType / types); - foreach (MonoDevelop.Projects.Dom.IMember member in members) { + foreach (var member in members) { if (worker.CancellationPending) return; - memberListStore.AppendValues (ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), + memberListStore.AppendValues ("", //ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), member.Name, member.DeclaringType.FullName, - ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, + "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } }); @@ -525,71 +531,68 @@ namespace MonoDevelop.AssemblyBrowser Gtk.Application.Invoke (delegate { IdeApp.Workbench.StatusBar.BeginProgress (GettextCatalog.GetString ("Searching string in disassembled code...")); }); - foreach (DomCecilCompilationUnit unit in this.definitions) { - foreach (IType type in unit.Types) { - if (worker.CancellationPending) - return; - curType++; - foreach (IMethod method in type.Methods) { + foreach (var unit in this.definitions) { + foreach (var module in unit.Value.Modules) + foreach (var type in module.Types) { if (worker.CancellationPending) return; - DomCecilMethod domMethod = method as DomCecilMethod; - if (domMethod == null) - continue; -// if (DomMethodNodeBuilder.Disassemble (rd => rd.DisassembleMethod (domMethod.MethodDefinition)).ToUpper ().Contains (pattern)) { + curType++; + foreach (var method in type.Methods) { + if (worker.CancellationPending) + return; +// if (DomMethodNodeBuilder.Disassemble (rd => rd.DisassembleMethod (method)).ToUpper ().Contains (pattern)) { // members.Add (method); // } - } + } - } + } } Gtk.Application.Invoke (delegate { IdeApp.Workbench.StatusBar.SetProgressFraction ((double)curType / types); - foreach (MonoDevelop.Projects.Dom.IMember member in members) { + foreach (var member in members) { if (worker.CancellationPending) return; - memberListStore.AppendValues (ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), + memberListStore.AppendValues ("", //iImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), member.Name, member.DeclaringType.FullName, - ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, + "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } }); break; case SearchMode.Decompiler: - foreach (DomCecilCompilationUnit unit in this.definitions) { - foreach (IType type in unit.Types) { - if (worker.CancellationPending) - return; - curType++; - foreach (IMethod method in type.Methods) { + foreach (var unit in this.definitions) { + foreach (var module in unit.Value.Modules) + foreach (var type in module.Types) { if (worker.CancellationPending) return; - DomCecilMethod domMethod = method as DomCecilMethod; - if (domMethod == null) - continue; + curType++; + foreach (var method in type.Methods) { + if (worker.CancellationPending) + return; /* if (DomMethodNodeBuilder.Decompile (domMethod, false).ToUpper ().Contains (pattern)) { members.Add (method); }*/ + } } - } } Gtk.Application.Invoke (delegate { IdeApp.Workbench.StatusBar.SetProgressFraction ((double)curType / types); - foreach (MonoDevelop.Projects.Dom.IMember member in members) { + foreach (var member in members) { if (worker.CancellationPending) return; - memberListStore.AppendValues (ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), + memberListStore.AppendValues ("", //ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), member.Name, member.DeclaringType.FullName, - ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, + "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } }); break; case SearchMode.Type: - foreach (DomCecilCompilationUnit unit in this.definitions) { - foreach (IType type in unit.Types) { + foreach (var unit in this.definitions) { + foreach (var module in unit.Value.Modules) + foreach (var type in module.Types) { if (worker.CancellationPending) return; if (type.FullName.ToUpper ().IndexOf (pattern) >= 0) @@ -597,13 +600,13 @@ namespace MonoDevelop.AssemblyBrowser } } Gtk.Application.Invoke (delegate { - foreach (IType type in members) { + foreach (var type in members) { if (worker.CancellationPending) return; - typeListStore.AppendValues (ImageService.GetPixbuf (type.StockIcon, Gtk.IconSize.Menu), + typeListStore.AppendValues ("", //ImageService.GetPixbuf (type.StockIcon, Gtk.IconSize.Menu), type.Name, - type.Namespace, - ((DomCecilCompilationUnit)type.CompilationUnit).AssemblyDefinition.Name.FullName, + type.FullName.Substring (0, type.FullName.Length - type.Name.Length), + "", // ((DomCecilCompilationUnit)type.CompilationUnit).AssemblyDefinition.Name.FullName, type); } }); @@ -907,7 +910,7 @@ namespace MonoDevelop.AssemblyBrowser IMember member = nav.DataItem as IMember; string documentation = GettextCatalog.GetString ("No documentation available."); if (member != null) { - XmlNode node = member.GetMonodocDocumentation (); + XmlNode node = null; // member.GetMonodocDocumentation (); if (node != null) { documentation = TransformDocumentation (node) ?? documentation; /* @@ -953,8 +956,8 @@ namespace MonoDevelop.AssemblyBrowser { ITreeNavigator nav = SearchMember (url); if (nav == null) { - foreach (DomCecilCompilationUnit definition in definitions.ToArray ()) { - foreach (AssemblyNameReference assemblyNameReference in definition.AssemblyDefinition.MainModule.AssemblyReferences) { + foreach (var definition in definitions.ToArray ()) { + foreach (var assemblyNameReference in definition.Value.MainModule.AssemblyReferences) { string assemblyFile = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyLocation (assemblyNameReference.FullName, null); if (assemblyFile != null && System.IO.File.Exists (assemblyFile)) AddReference (assemblyFile); @@ -972,17 +975,17 @@ namespace MonoDevelop.AssemblyBrowser public void SelectAssembly (string fileName) { - DomCecilCompilationUnit cu = null; - foreach (DomCecilCompilationUnit unit in definitions) { - if (unit.FileName == fileName) - cu = unit; + AssemblyDefinition cu = null; + foreach (var unit in definitions) { + if (unit.Key == fileName) + cu = unit.Value; } if (cu == null) return; ITreeNavigator nav = TreeView.GetRootNode (); do { - if (nav.DataItem == cu.AssemblyDefinition) { + if (nav.DataItem == cu) { nav.ExpandToNode (); nav.Selected = true; return; @@ -1060,25 +1063,33 @@ namespace MonoDevelop.AssemblyBrowser base.OnDestroyed (); } - List<DomCecilCompilationUnit> definitions = new List<DomCecilCompilationUnit> (); - public AssemblyDefinition AddReference (string fileName) + static AssemblyDefinition ReadAssembly (string fileName) { - foreach (DomCecilCompilationUnit unit in definitions) { - if (unit.FileName == fileName) - return unit.AssemblyDefinition; + ReaderParameters parameters = new ReaderParameters (); +// parameters.AssemblyResolver = new SimpleAssemblyResolver (Path.GetDirectoryName (fileName)); + using (var stream = new System.IO.MemoryStream (System.IO.File.ReadAllBytes (fileName))) { + return AssemblyDefinition.ReadAssembly (stream, parameters); } - DomCecilCompilationUnit newUnit = DomCecilCompilationUnit.Load (fileName, true, false); - definitions.Add (newUnit); + } + Dictionary<string, AssemblyDefinition> definitions = new Dictionary<string, AssemblyDefinition> (); + public AssemblyDefinition AddReference (string fileName) + { + AssemblyDefinition result; + if (definitions.TryGetValue (fileName, out result)) + return result; + definitions [fileName] = result = ReadAssembly (fileName); + ITreeBuilder builder; if (definitions.Count == 1) { - builder = TreeView.LoadTree (newUnit); + builder = TreeView.LoadTree (Tuple.Create (result, new CecilLoader ().LoadAssembly (result))); } else { - builder = TreeView.AddChild (newUnit); + builder = TreeView.AddChild (Tuple.Create (result, new CecilLoader ().LoadAssembly (result))); } builder.MoveToFirstChild (); builder.Expanded = true; - return newUnit.AssemblyDefinition; + return result; + } [CommandHandler (SearchCommands.Find)] diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs index 29e0f724fb..ebc549a641 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs @@ -33,20 +33,19 @@ using System.Text; using Mono.Cecil; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Pads; using MonoDevelop.Ide.Gui.Components; using Mono.TextEditor; using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.AssemblyBrowser { class AssemblyNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(DomCecilCompilationUnit); } + get { return typeof(Tuple<AssemblyDefinition, IProjectContent>); } } public AssemblyNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -55,20 +54,20 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)dataObject; - return compilationUnit.AssemblyDefinition.Name.Name; + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; + return compilationUnit.Name.Name; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)dataObject; - label = compilationUnit.AssemblyDefinition.Name.Name; + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; + label = compilationUnit.Name.Name; icon = Context.GetIcon (Stock.Reference); } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)dataObject; + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; foreach (var module in compilationUnit.Modules) { ctx.AddChild (module); @@ -77,7 +76,7 @@ namespace MonoDevelop.AssemblyBrowser public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)dataObject; + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; return compilationUnit.Modules.Any (); } @@ -108,23 +107,23 @@ namespace MonoDevelop.AssemblyBrowser string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)navigator.DataItem; + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)navigator.DataItem).Item1; StringBuilder result = new StringBuilder (); - PrintAssemblyHeader (result, compilationUnit.AssemblyDefinition); + PrintAssemblyHeader (result, compilationUnit); result.Append (String.Format (GettextCatalog.GetString ("<b>Name:</b>\t{0}"), - compilationUnit.AssemblyDefinition.Name.FullName)); + compilationUnit.Name.FullName)); result.AppendLine (); result.Append (String.Format (GettextCatalog.GetString ("<b>Type:</b>\t{0}"), - GetTypeString (compilationUnit.AssemblyDefinition.MainModule.Kind))); + GetTypeString (compilationUnit.MainModule.Kind))); result.AppendLine (); return result.ToString (); } public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) { - DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)navigator.DataItem; - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), null, b => b.AddAssembly (compilationUnit.AssemblyDefinition, true)); + var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)navigator.DataItem).Item1; + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), null, b => b.AddAssembly (compilationUnit, true)); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs index c17f6e2389..c23983253b 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs @@ -27,17 +27,19 @@ // using System; -using MonoDevelop.Projects.Dom; +using ICSharpCode.NRefactory.TypeSystem; +using Mono.Cecil; + namespace MonoDevelop.AssemblyBrowser { public class BaseTypeFolder : IDisposable { - public IType Type { + public TypeDefinition Type { get; private set; } - public BaseTypeFolder (IType type) + public BaseTypeFolder (TypeDefinition type) { this.Type = type; } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs index 6bb40589f8..eba8c76c74 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs @@ -32,8 +32,6 @@ using System.Collections.Generic; using Mono.Cecil; using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Pads; using MonoDevelop.Ide.Gui.Components; @@ -63,7 +61,7 @@ namespace MonoDevelop.AssemblyBrowser public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - BaseTypeFolder baseTypeFolder = (BaseTypeFolder)dataObject; + var baseTypeFolder = (BaseTypeFolder)dataObject; if (baseTypeFolder.Type != null && baseTypeFolder.Type.BaseType != null) ctx.AddChild (baseTypeFolder.Type.BaseType); // Todo: show implemented interfaces. diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs index 6c42d7e6f5..fc0abf0bb8 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs @@ -29,8 +29,6 @@ using System; using System.Text; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using ICSharpCode.Decompiler.Ast; @@ -38,13 +36,15 @@ using ICSharpCode.Decompiler; using System.Threading; using Mono.TextEditor; using System.Collections.Generic; +using Mono.Cecil; +using MonoDevelop.TypeSystem; namespace MonoDevelop.AssemblyBrowser { class DomEventNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IEvent); } + get { return typeof(EventDefinition); } } public DomEventNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -53,35 +53,36 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - IEvent evt = (IEvent)dataObject; + var evt = (EventDefinition)dataObject; return evt.FullName; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - IEvent evt = (IEvent)dataObject; - label = Ambience.GetString (evt, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (evt.IsPrivate || evt.IsInternal) - label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (evt.StockIcon, Gtk.IconSize.Menu); + var evt = (EventDefinition)dataObject; +// label = Ambience.GetString (evt, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); + label = evt.Name; +// if (evt.IsPrivate || evt.IsInternal) +// label = DomMethodNodeBuilder.FormatPrivate (label); + icon = ImageService.GetPixbuf (evt.GetStockIcon (), Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) { - if (otherNode.DataItem is IEvent) - return ((IEvent)thisNode.DataItem).Name.CompareTo (((IEvent)otherNode.DataItem).Name); + if (otherNode.DataItem is EventDefinition) + return ((EventDefinition)thisNode.DataItem).Name.CompareTo (((EventDefinition)otherNode.DataItem).Name); return 1; } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - IEvent evt = (IEvent)dataObject; + var evt = (EventDefinition)dataObject; if (evt.AddMethod != null) ctx.AddChild (evt.AddMethod); if (evt.RemoveMethod != null) ctx.AddChild (evt.RemoveMethod); - if (evt.RaiseMethod != null) - ctx.AddChild (evt.RaiseMethod); + if (evt.InvokeMethod != null) + ctx.AddChild (evt.InvokeMethod); } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) @@ -92,10 +93,10 @@ namespace MonoDevelop.AssemblyBrowser #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - IEvent evt = (IEvent)navigator.DataItem; + var evt = (EventDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (evt, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (evt, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -105,32 +106,33 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var evt = (DomCecilEvent)navigator.DataItem; - return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleEvent (evt.EventDefinition)); + var evt = (EventDefinition)navigator.DataItem; + return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleEvent (evt)); } List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var evt = (DomCecilEvent)navigator.DataItem; - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), ((DomCecilType)evt.DeclaringType).TypeDefinition, b => b.AddEvent (evt.EventDefinition)); + var evt = (EventDefinition)navigator.DataItem; + var parent = (TypeDefinition)navigator.GetParentDataItem (typeof(TypeDefinition), false); + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), parent, b => b.AddEvent (evt)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - IEvent evt = (IEvent)navigator.DataItem; + var evt = (EventDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (evt, OutputFlags.AssemblyBrowserDescription)); + // result.Append (Ambience.GetString (evt, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); - AmbienceService.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); - options.MaxLineLength = -1; - options.BigHeadings = true; - options.Ambience = Ambience; +// var.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); +// options.MaxLineLength = -1; +// options.BigHeadings = true; +// options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (evt), options)); + // result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (evt), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs index fb63d8387f..9befb40bdc 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs @@ -29,8 +29,6 @@ using System; using System.Text; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using ICSharpCode.Decompiler.Ast; @@ -38,13 +36,15 @@ using ICSharpCode.Decompiler; using System.Threading; using Mono.TextEditor; using System.Collections.Generic; +using Mono.Cecil; +using MonoDevelop.TypeSystem; namespace MonoDevelop.AssemblyBrowser { class DomFieldNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IField); } + get { return typeof(FieldDefinition); } } public DomFieldNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -54,39 +54,40 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - IField field = (IField)dataObject; + var field = (FieldDefinition)dataObject; return field.FullName; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - IField field = (IField)dataObject; - label = Ambience.GetString (field, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (field.IsPrivate || field.IsInternal) - label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (field.StockIcon, Gtk.IconSize.Menu); + var field = (FieldDefinition)dataObject; + label = field.Name; +// label = Ambience.GetString (field, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); +// if (field.IsPrivate || field.IsInternal) +// label = DomMethodNodeBuilder.FormatPrivate (label); +// icon = ImageService.GetPixbuf (field.StockIcon, Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) { - if (otherNode.DataItem is IMethod) + if (otherNode.DataItem is MethodDefinition) return 1; - if (otherNode.DataItem is IProperty) + if (otherNode.DataItem is PropertyDefinition) return 1; if (otherNode.DataItem is BaseTypeFolder) return 1; - if (otherNode.DataItem is IField) - return ((IField)thisNode.DataItem).Name.CompareTo (((IField)otherNode.DataItem).Name); + if (otherNode.DataItem is FieldDefinition) + return ((FieldDefinition)thisNode.DataItem).Name.CompareTo (((FieldDefinition)otherNode.DataItem).Name); return -1; } #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - IField field = (IField)navigator.DataItem; + var field = (FieldDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (field, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (field, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -96,33 +97,33 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var field = (DomCecilField)navigator.DataItem; - return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleField (field.FieldDefinition)); + var field = (FieldDefinition)navigator.DataItem; + return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleField (field)); } List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var field = (DomCecilField)navigator.DataItem; - - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), ((DomCecilType)field.DeclaringType).TypeDefinition, b => b.AddField (field.FieldDefinition)); + var field = (FieldDefinition)navigator.DataItem; + var parent = (TypeDefinition)navigator.GetParentDataItem (typeof(TypeDefinition), false); + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), parent, b => b.AddField (field)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - IField field = (IField)navigator.DataItem; + var field = (FieldDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (field, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (field, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); - AmbienceService.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); - options.MaxLineLength = -1; - options.BigHeadings = true; - options.Ambience = Ambience; - result.AppendLine (); +// var.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); +// options.MaxLineLength = -1; +// options.BigHeadings = true; +// options.Ambience = Ambience; +// result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (field), options)); +// result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (field), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs index 800a1ffc86..8111fe7b7d 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs @@ -34,8 +34,6 @@ using Mono.Cecil; using Mono.Cecil.Cil; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using ICSharpCode.Decompiler.Ast; @@ -43,13 +41,15 @@ using ICSharpCode.Decompiler; using System.Threading; using ICSharpCode.Decompiler.Disassembler; using Mono.TextEditor; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.AssemblyBrowser { class DomMethodNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IMethod); } + get { return typeof(MethodDefinition); } } public DomMethodNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -59,7 +59,7 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - IMethod method = (IMethod)dataObject; + var method = (MethodDefinition)dataObject; return method.FullName; } @@ -67,24 +67,24 @@ namespace MonoDevelop.AssemblyBrowser { return "<span foreground= \"#666666\">" + label + "</span>"; } - public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - IMethod method = (IMethod)dataObject; - - label = Ambience.GetString (method, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (method.IsPrivate || method.IsInternal) - label = DomMethodNodeBuilder.FormatPrivate (label); + var method = (MethodDefinition)dataObject; + var ctx = GetContent (treeBuilder); + label = method.Name; +// label = Ambience.GetString (ctx, method, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); +// if (method.IsPrivate || method.IsInternal) +// label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (method.StockIcon, Gtk.IconSize.Menu); + icon = ImageService.GetPixbuf (method.GetStockIcon (), Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) { - if (otherNode.DataItem is BaseTypeFolder) + if (otherNode.DataItem is MethodDefinition) return 1; if (otherNode.DataItem is IMethod) - return ((IMethod)thisNode.DataItem).Name.CompareTo (((IMethod)otherNode.DataItem).Name); + return ((MethodDefinition)thisNode.DataItem).Name.CompareTo (((MethodDefinition)otherNode.DataItem).Name); return -1; } @@ -102,10 +102,10 @@ namespace MonoDevelop.AssemblyBrowser string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - IMethod method = (IMethod)navigator.DataItem; + var method = (MethodDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (method, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (method, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); PrintDeclaringType (result, navigator); @@ -121,14 +121,14 @@ namespace MonoDevelop.AssemblyBrowser public static ModuleDefinition GetModule (ITreeNavigator navigator) { var nav = navigator.Clone (); - while (!(nav.DataItem is DomCecilCompilationUnit.Module) && !(nav.DataItem is DomCecilCompilationUnit)) { + while (!(nav.DataItem is ModuleDefinition) && !(nav.DataItem is Tuple<AssemblyDefinition, IProjectContent>)) { if (!nav.MoveToParent ()) - return ModuleDefinition.CreateModule ("", ModuleKind.Console); + return ModuleDefinition.CreateModule ("empty", ModuleKind.Console); } - if (nav.DataItem is DomCecilCompilationUnit) - return ((DomCecilCompilationUnit)nav.DataItem).AssemblyDefinition.MainModule; + if (nav.DataItem is Tuple<AssemblyDefinition, IProjectContent>) + return ((Tuple<AssemblyDefinition, IProjectContent>)nav.DataItem).Item1.MainModule; - return ((DomCecilCompilationUnit.Module)nav.DataItem).ModuleDefinition; + return (ModuleDefinition)nav.DataItem; } public static List<ReferenceSegment> Decompile (TextEditorData data, ModuleDefinition module, TypeDefinition currentType, Action<AstBuilder> setData) @@ -170,10 +170,10 @@ namespace MonoDevelop.AssemblyBrowser internal static string GetAttributes (Ambience ambience, IEnumerable<IAttribute> attributes) { StringBuilder result = new StringBuilder (); - foreach (IAttribute attr in attributes) { + foreach (var attr in attributes) { if (result.Length > 0) result.AppendLine (); - result.Append (ambience.GetString (attr, OutputFlags.AssemblyBrowserDescription)); + // result.Append (ambience.GetString (attr, OutputFlags.AssemblyBrowserDescription)); } if (result.Length > 0) result.AppendLine (); @@ -182,10 +182,9 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) { - DomCecilMethod method = navigator.DataItem as DomCecilMethod; - if (method == null) - return null; - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), ((DomCecilType)method.DeclaringType).TypeDefinition, b => b.AddMethod (method.MethodDefinition)); + var method = (MethodDefinition)navigator.DataItem; + var parent = (TypeDefinition)navigator.GetParentDataItem (typeof(TypeDefinition), false); + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), parent, b => b.AddMethod (method)); } static void AppendLink (StringBuilder sb, string link, string text) @@ -209,18 +208,18 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - DomCecilMethod method = navigator.DataItem as DomCecilMethod; + var method = (MethodDefinition)navigator.DataItem; if (method == null) return null; - return Disassemble (data, rd => rd.DisassembleMethod (method.MethodDefinition)); + return Disassemble (data, rd => rd.DisassembleMethod (method)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - DomCecilMethod method = navigator.DataItem as DomCecilMethod; + var method = (MethodDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (method, OutputFlags.AssemblyBrowserDescription | OutputFlags.IncludeConstraints)); +// result.Append (Ambience.GetString (method, OutputFlags.AssemblyBrowserDescription | OutputFlags.IncludeConstraints)); result.Append ("</big>"); result.AppendLine (); @@ -230,7 +229,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (method), options)); +// result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (method), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs index 663a70432e..d53cf4df73 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs @@ -29,8 +29,6 @@ using System; using System.Text; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using MonoDevelop.Projects.Text; @@ -39,13 +37,14 @@ using ICSharpCode.Decompiler; using System.Threading; using Mono.TextEditor; using System.Collections.Generic; +using Mono.Cecil; namespace MonoDevelop.AssemblyBrowser { class DomPropertyNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IProperty); } + get { return typeof(PropertyDefinition); } } public DomPropertyNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -55,52 +54,53 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - IProperty property = (IProperty)dataObject; + var property = (PropertyDefinition)dataObject; return property.Name; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - IProperty property = (IProperty)dataObject; - label = Ambience.GetString (property, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (property.IsPrivate || property.IsInternal) - label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (property.StockIcon, Gtk.IconSize.Menu); + var property = (PropertyDefinition)dataObject; + label = property.Name; +// label = Ambience.GetString (property, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); +// if (property.IsPrivate || property.IsInternal) +// label = DomMethodNodeBuilder.FormatPrivate (label); +// icon = ImageService.GetPixbuf (property.StockIcon, Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) { - if (otherNode.DataItem is IMethod) + if (otherNode.DataItem is MethodDefinition) return 1; if (otherNode.DataItem is BaseTypeFolder) return 1; - if (otherNode.DataItem is IProperty) - return ((IProperty)thisNode.DataItem).Name.CompareTo (((IProperty)otherNode.DataItem).Name); + if (otherNode.DataItem is PropertyDefinition) + return ((PropertyDefinition)thisNode.DataItem).Name.CompareTo (((PropertyDefinition)otherNode.DataItem).Name); return -1; } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - DomCecilProperty property = (DomCecilProperty)dataObject; - if (property.HasGet && property.GetMethod != null) + var property = (PropertyDefinition)dataObject; + if (property.GetMethod != null) ctx.AddChild (property.GetMethod); - if (property.HasSet && property.SetMethod != null) + if (property.SetMethod != null) ctx.AddChild (property.SetMethod); } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { - IProperty property = (IProperty)dataObject; - return property.HasGet || property.HasSet; + var property = (PropertyDefinition)dataObject; + return property.GetMethod != null || property.SetMethod != null; } #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - IProperty property = (IProperty)navigator.DataItem; + var property = (PropertyDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (property, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (property, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -110,8 +110,8 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var property = (DomCecilProperty)navigator.DataItem; - return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleProperty (property.PropertyDefinition)); + var property = (PropertyDefinition)navigator.DataItem; + return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleProperty (property)); } static string GetBody (string text) @@ -129,26 +129,27 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var property = (DomCecilProperty)navigator.DataItem; - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), ((DomCecilType)property.DeclaringType).TypeDefinition, b => b.AddProperty (property.PropertyDefinition)); + var property = (PropertyDefinition)navigator.DataItem; + var parent = (TypeDefinition)navigator.GetParentDataItem (typeof(TypeDefinition), false); + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), parent, b => b.AddProperty (property)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - IProperty property = (IProperty)navigator.DataItem; + var property = (PropertyDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (property, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (property, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); - AmbienceService.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); - options.MaxLineLength = -1; - options.BigHeadings = true; - options.Ambience = Ambience; +// AmbienceService.DocumentationFormatOptions options = new AmbienceService.DocumentationFormatOptions (); +// options.MaxLineLength = -1; +// options.BigHeadings = true; +// options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (property), options)); +// result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (property), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomReturnTypeNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomReturnTypeNodeBuilder.cs deleted file mode 100644 index 0cbee84299..0000000000 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomReturnTypeNodeBuilder.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// DomReturnTypeNodeBuilder.cs -// -// Author: -// Mike Krüger <mkrueger@novell.com> -// -// Copyright (C) 2008 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.Dom; -using MonoDevelop.Projects.Dom.Output; -using MonoDevelop.Ide.Gui.Components; - -namespace MonoDevelop.AssemblyBrowser -{ - class DomReturnTypeNodeBuilder : AssemblyBrowserTypeNodeBuilder - { - public override Type NodeDataType { - get { return typeof(IReturnType); } - } - - public override Type CommandHandlerType { - get { return typeof(DomReturnTypeNodeCommandHandler); } - } - - public DomReturnTypeNodeBuilder (AssemblyBrowserWidget widget) : base (widget) - { - } - - public override string GetNodeName (ITreeNavigator thisNode, object dataObject) - { - IReturnType returnType = (IReturnType)dataObject; - return returnType.FullName; - } - - public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) - { - IReturnType returnType = (IReturnType)dataObject; - label = Ambience.GetString (returnType, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - icon = Context.GetIcon (MonoDevelop.Ide.Gui.Stock.Class); - } - } - - public class DomReturnTypeNodeCommandHandler : NodeCommandHandler - { - public override void ActivateItem () - { - DomReturnTypeNodeBuilder nodeBuilder = CurrentNode.TypeNodeBuilder as DomReturnTypeNodeBuilder; - IReturnType returnType = CurrentNode.DataItem as IReturnType; - if (nodeBuilder != null && returnType != null) - nodeBuilder.Widget.Open ("T:" + returnType.DecoratedFullName); - } - } -} diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs index 473b384f83..04e4bbd68f 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs @@ -32,8 +32,6 @@ using System.Linq; using Mono.Cecil; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using Mono.TextEditor.Highlighting; using MonoDevelop.Ide; @@ -42,13 +40,15 @@ using ICSharpCode.Decompiler; using System.Threading; using Mono.TextEditor; using System.Collections.Generic; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.AssemblyBrowser { class DomTypeNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IType); } + get { return typeof(TypeDefinition); } } public override string ContextMenuAddinPath { @@ -94,41 +94,54 @@ namespace MonoDevelop.AssemblyBrowser DomTypeNodeBuilder.settings.EmitKeywordCallback = delegate (string text) { return MarkupKeyword (text); }; - DomTypeNodeBuilder.settings.EmitNameCallback = delegate (INode domVisitable, ref string outString) { - if (domVisitable is IType) { - outString = "<span style=\"text.link\"><u><a ref=\"" + ((IType)domVisitable).HelpUrl + "\">" + outString + "</a></u></span>"; - } else { - outString = "<span style=\"text\">" + outString + "</span>"; - } - }; - DomTypeNodeBuilder.settings.PostProcessCallback = delegate (INode domVisitable, ref string outString) { - if (domVisitable is IReturnType) { - outString = "<span style=\"text.link\"><u><a ref=\"" + ((IReturnType)domVisitable).HelpUrl + "\">" + outString + "</a></u></span>"; - } - }; +// DomTypeNodeBuilder.settings.EmitNameCallback = delegate (IEntity domVisitable, ref string outString) { +// if (domVisitable is IType) { +// outString = "<span style=\"text.link\"><u><a ref=\"" + ((IType)domVisitable).HelpUrl + "\">" + outString + "</a></u></span>"; +// } else { +// outString = "<span style=\"text\">" + outString + "</span>"; +// } +// }; +// DomTypeNodeBuilder.settings.PostProcessCallback = delegate (IEntity domVisitable, ref string outString) { +// if (domVisitable is IReturnType) { +// outString = "<span style=\"text.link\"><u><a ref=\"" + ((IReturnType)domVisitable).HelpUrl + "\">" + outString + "</a></u></span>"; +// } +// }; } public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - IType type = (IType)dataObject; + var type = (TypeDefinition)dataObject; return type.Name; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - IType type = (IType)dataObject; - label = Ambience.GetString (type, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (type.IsPrivate || type.IsInternal) - label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (type.StockIcon, Gtk.IconSize.Menu); + var type = (TypeDefinition)dataObject; +// label = Ambience.GetString (GetContent (treeBuilder), type, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); + label = type.Name; +// if (type.IsPrivate || type.IsInternal) +// label = DomMethodNodeBuilder.FormatPrivate (label); + + icon = ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu); } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - IType type = (IType)dataObject; - ctx.AddChild (new BaseTypeFolder (type)); + var type = (TypeDefinition)dataObject; + var list = new System.Collections.ArrayList (); + list.Add (new BaseTypeFolder (type)); bool publicOnly = ctx.Options ["PublicApiOnly"]; - ctx.AddChildren (type.Members.Where (member => !(member.IsSpecialName && !(member is IMethod && ((IMethod)member).IsConstructor)) && !(publicOnly && !(member.IsPublic || member.IsProtected)))); + foreach (var t in type.NestedTypes.Where (m => !m.IsSpecialName && !(publicOnly && (m.IsPublic)))) + list.Add (t); + foreach (var m in type.Methods.Where (m => !m.IsSpecialName && !(publicOnly && !(m.IsPublic || m.IsFamily)))) + list.Add (m); + foreach (var p in type.Properties) + list.Add (p); + foreach (var f in type.Fields.Where (m => !m.IsSpecialName && !(publicOnly && !(m.IsPublic || m.IsFamily)))) + list.Add (f); + foreach (var e in type.Events) + list.Add (e); + ctx.AddChildren (list); } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) @@ -139,7 +152,7 @@ namespace MonoDevelop.AssemblyBrowser #region IAssemblyBrowserNodeBuilder internal static void PrintAssembly (StringBuilder result, ITreeNavigator navigator) { - AssemblyDefinition assemblyDefinition = (AssemblyDefinition)navigator.GetParentDataItem (typeof (AssemblyDefinition), false); + var assemblyDefinition = (AssemblyDefinition)navigator.GetParentDataItem (typeof (AssemblyDefinition), false); if (assemblyDefinition == null) return; @@ -151,14 +164,13 @@ namespace MonoDevelop.AssemblyBrowser public string GetDescription (ITreeNavigator navigator) { - IType type = (IType)navigator.DataItem; + var type = (TypeDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (type, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (type, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); - result.Append (String.Format (GettextCatalog.GetString ("<b>Name:</b>\t{0}"), - type.FullName)); + result.Append (String.Format (GettextCatalog.GetString ("<b>Name:</b>\t{0}"), type.FullName)); result.AppendLine (); PrintAssembly (result, navigator); return result.ToString (); @@ -166,22 +178,22 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) { - var type = (DomCecilType)navigator.DataItem; - return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleType (type.TypeDefinition)); + var type = (TypeDefinition)navigator.DataItem; + return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleType (type)); } public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) { - var type = (DomCecilType)navigator.DataItem; - return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), type.TypeDefinition, b => b.AddType (type.TypeDefinition)); + var type = (TypeDefinition)navigator.DataItem; + return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), type, b => b.AddType (type)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - IType type = (IType)navigator.DataItem; + var type = (TypeDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (type, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (type, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); @@ -191,7 +203,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (type), options)); +// result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (type), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ErrorNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ErrorNodeBuilder.cs index 30968a380d..275c42eaca 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ErrorNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ErrorNodeBuilder.cs @@ -32,7 +32,6 @@ using System.Collections.Generic; using Mono.Cecil; using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Pads; using MonoDevelop.Ide.Gui.Components; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs index debb733755..852338db4e 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs @@ -31,18 +31,17 @@ using System.Text; using System.Collections.Generic; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Components; using Mono.TextEditor; +using Mono.Cecil; namespace MonoDevelop.AssemblyBrowser { class ModuleDefinitionNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(DomCecilCompilationUnit.Module); } + get { return typeof(ModuleDefinition); } } public ModuleDefinitionNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -57,27 +56,27 @@ namespace MonoDevelop.AssemblyBrowser public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - DomCecilCompilationUnit.Module module = (DomCecilCompilationUnit.Module)dataObject; - label = module.ModuleDefinition.Name; + var module = (ModuleDefinition)dataObject; + label = module.Name; icon = Context.GetIcon (Stock.OpenFolder); closedIcon = Context.GetIcon (Stock.ClosedFolder); } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - DomCecilCompilationUnit.Module module = (DomCecilCompilationUnit.Module)dataObject; + var module = (ModuleDefinition)dataObject; Dictionary<string, Namespace> namespaces = new Dictionary<string, Namespace> (); bool publicOnly = ctx.Options ["PublicApiOnly"]; - foreach (IType type in module.Types) { + foreach (var type in module.Types) { if (publicOnly && !type.IsPublic) continue; if (!namespaces.ContainsKey (type.Namespace)) namespaces [type.Namespace] = new Namespace (type.Namespace); namespaces [type.Namespace].Types.Add (type); } - ctx.AddChild (new ReferenceFolder (module.ModuleDefinition)); - if (module.ModuleDefinition.Resources.Count > 0) - ctx.AddChild (new ResourceFolder (module.ModuleDefinition)); + ctx.AddChild (new ReferenceFolder (module)); + if (module.Resources.Count > 0) + ctx.AddChild (new ResourceFolder (module)); foreach (Namespace ns in namespaces.Values) { ctx.AddChild (ns); } @@ -89,22 +88,22 @@ namespace MonoDevelop.AssemblyBrowser } #region IAssemblyBrowserNodeBuilder - void PrintModuleHeader (StringBuilder result, DomCecilCompilationUnit.Module module) + void PrintModuleHeader (StringBuilder result, ModuleDefinition module) { result.Append (Ambience.SingleLineComment ( String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), - module.ModuleDefinition.Name))); + module.Name))); result.AppendLine (); } string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - DomCecilCompilationUnit.Module module = (DomCecilCompilationUnit.Module)navigator.DataItem; + var module = (ModuleDefinition)navigator.DataItem; StringBuilder result = new StringBuilder (); PrintModuleHeader (result, module); result.Append (String.Format (GettextCatalog.GetString ("<b>Version:</b>\t{0}"), - module.ModuleDefinition.Mvid)); + module.Mvid)); result.AppendLine (); return result.ToString (); @@ -112,13 +111,13 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) { - DomCecilCompilationUnit.Module module = (DomCecilCompilationUnit.Module)navigator.DataItem; - StringBuilder result = new StringBuilder (); + var module = (ModuleDefinition)navigator.DataItem; + var result = new StringBuilder (); PrintModuleHeader (result, module); HashSet<string> namespaces = new HashSet<string> (); - foreach (IType type in module.Types) { + foreach (var type in module.Types) { /* if ((type.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate) continue;*/ if (String.IsNullOrEmpty (type.Namespace)) @@ -135,14 +134,16 @@ namespace MonoDevelop.AssemblyBrowser data.Text = result.ToString (); return null; } + public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) { return Disassemble (data, navigator); } + public string GetDocumentationMarkup (ITreeNavigator navigator) { - DomCecilCompilationUnit.Module module = (DomCecilCompilationUnit.Module)navigator.DataItem; - return "<big>" + String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), module.ModuleDefinition.Name) + "</big>"; + var module = (ModuleDefinition)navigator.DataItem; + return "<big>" + String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), module.Name) + "</big>"; } #endregion } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleReferenceNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleReferenceNodeBuilder.cs index 7440fc42bc..79e7385256 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleReferenceNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleReferenceNodeBuilder.cs @@ -29,7 +29,6 @@ using System; using Mono.Cecil; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Gui; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs index e885c3cdca..7402e22597 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs @@ -28,21 +28,21 @@ using System; using System.Collections.Generic; - -using MonoDevelop.Projects.Dom; +using ICSharpCode.NRefactory.TypeSystem; +using Mono.Cecil; namespace MonoDevelop.AssemblyBrowser { public class Namespace : IDisposable { - List<IType> types = new List<IType> (); + List<TypeDefinition> types = new List<TypeDefinition> (); public string Name { get; private set; } - public List<IType> Types { + public List<TypeDefinition> Types { get { return types; } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NamespaceBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NamespaceBuilder.cs index 08ff08be9b..c2c5913e65 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NamespaceBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NamespaceBuilder.cs @@ -30,8 +30,6 @@ using System; using System.Text; using System.Linq; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Ide.Gui.Components; using Mono.TextEditor; using System.Collections.Generic; @@ -82,7 +80,7 @@ namespace MonoDevelop.AssemblyBrowser StringBuilder result = new StringBuilder (); if (!String.IsNullOrEmpty (ns.Name)) { result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (ns.Name, OutputFlags.AssemblyBrowserDescription)); +// result.Append (Ambience.GetString (ns.Name, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceFolderNodeBuilder.cs index 6a18a4645b..ac2a9b6354 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceFolderNodeBuilder.cs @@ -30,7 +30,6 @@ using System; using Mono.Cecil; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Gui; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceNodeBuilder.cs index 5218821eb8..c3bbd828b2 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ReferenceNodeBuilder.cs @@ -1,4 +1,4 @@ -//
+// // ReferenceNodeBuilder.cs // // Author: @@ -29,9 +29,8 @@ using System; using System.IO; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Components; -using MonoDevelop.Ide.Gui;
+using MonoDevelop.Ide.Gui; namespace MonoDevelop.AssemblyBrowser { @@ -44,33 +43,33 @@ namespace MonoDevelop.AssemblyBrowser public override Type NodeDataType { get { return typeof(Reference); } } -
+ public override Type CommandHandlerType { get { return typeof(ReferenceNodeCommandHandler); } } public override string GetNodeName (ITreeNavigator thisNode, object dataObject) - {
+ { Reference reference = (Reference)dataObject; return reference.FileName; - }
-
+ } + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) - {
- Reference reference = (Reference)dataObject;
+ { + Reference reference = (Reference)dataObject; label = Path.GetFileNameWithoutExtension (reference.FileName); icon = Context.GetIcon (Stock.Reference); } - }
-
+ } + public class ReferenceNodeCommandHandler : NodeCommandHandler { public override void ActivateItem () - {
- ReferenceNodeBuilder nodeBuilder = CurrentNode.TypeNodeBuilder as ReferenceNodeBuilder;
- Reference reference = (Reference)CurrentNode.DataItem;
-// AssemblyDefinition definition =
- nodeBuilder.Widget.AddReference (reference.FileName);
+ { + ReferenceNodeBuilder nodeBuilder = CurrentNode.TypeNodeBuilder as ReferenceNodeBuilder; + Reference reference = (Reference)CurrentNode.DataItem; +// AssemblyDefinition definition = + nodeBuilder.Widget.AddReference (reference.FileName); nodeBuilder.Widget.SelectAssembly (reference.FileName); } } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceFolderNodeBuilder.cs index 0636ca58f0..10dc049675 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceFolderNodeBuilder.cs @@ -28,7 +28,6 @@ using System; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Gui; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceNodeBuilder.cs index e5b57dfe05..736b73c23e 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ResourceNodeBuilder.cs @@ -29,7 +29,6 @@ using System; using Mono.Cecil; -using MonoDevelop.Projects.Dom; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Gui; |