diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 17:12:41 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 17:12:41 +0400 |
commit | cae60273e4a57e48a35c61b4ec7d0fec5a611b98 (patch) | |
tree | 2f23a22d4aa368399714f5032b65221eee2d864a /main/src | |
parent | b3f516a03ac1e5bb9ff077477194493ce745a1cc (diff) |
[AssemblyBrowser] Tracked NRefactory API changes.
Diffstat (limited to 'main/src')
14 files changed, 341 insertions, 275 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs index c466bd9be3..648de7c287 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs @@ -349,7 +349,7 @@ namespace MonoDevelop.CSharp return "null"; var type = reference; if (type.Kind == TypeKind.Unknown) - return reference.ToString (); + return ((UnknownType)reference).Name; var sb = new StringBuilder (); if (type is ITypeDefinition && ((ITypeDefinition)type).IsSynthetic&& ((ITypeDefinition)type).Name == "$Anonymous$") { sb.Append ("new {"); @@ -372,6 +372,8 @@ namespace MonoDevelop.CSharp protected override string GetTypeString (IType t, OutputSettings settings) { + if (t is UnknownType) + return ((UnknownType)t).Name; ITypeDefinition type = t.GetDefinition (); if (type == null) return ""; @@ -500,7 +502,7 @@ namespace MonoDevelop.CSharp } if (!settings.IncludeReturnType && settings.UseFullName) { - result.Append (GetTypeReferenceString (method.DeclaringType, new OutputSettings (OutputFlags.UseFullName))); + result.Append (GetTypeReferenceString (method.DeclaringTypeDefinition, new OutputSettings (OutputFlags.UseFullName))); result.Append (settings.Markup (".")); } AppendExplicitInterfaces (result, method, settings); @@ -541,17 +543,17 @@ namespace MonoDevelop.CSharp protected override string GetMethodString (IMethod method, OutputSettings settings) { - return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.EntityType == EntityType.Constructor || method.EntityType == EntityType.Destructor ? method.DeclaringType.Name : method.Name))), true); + return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.EntityType == EntityType.Constructor || method.EntityType == EntityType.Destructor ? method.DeclaringTypeDefinition.Name : method.Name))), true); } protected override string GetConstructorString (IMethod method, OutputSettings settings) { - return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.DeclaringType.Name))), false); + return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.DeclaringTypeDefinition != null ? method.DeclaringTypeDefinition.Name : method.Name))), false); } protected override string GetDestructorString (IMethod method, OutputSettings settings) { - return InternalGetMethodString (method, settings, settings.EmitName (method, settings.Markup ("~") + Format (FilterName (method.DeclaringType.Name))), false); + return InternalGetMethodString (method, settings, settings.EmitName (method, settings.Markup ("~") + Format (FilterName (method.DeclaringTypeDefinition != null ? method.DeclaringTypeDefinition.Name : method.Name))), false); } protected override string GetOperatorString (IMethod method, OutputSettings settings) @@ -564,7 +566,7 @@ namespace MonoDevelop.CSharp if (field == null) return ""; var result = new StringBuilder (); - bool isEnum = field.DeclaringType != null && field.DeclaringType.Kind == TypeKind.Enum; + bool isEnum = field.DeclaringTypeDefinition != null && field.DeclaringTypeDefinition.Kind == TypeKind.Enum; AppendModifiers (result, settings, field); if (!settings.CompletionListFomat && settings.IncludeReturnType && !isEnum) { @@ -573,7 +575,7 @@ namespace MonoDevelop.CSharp } if (!settings.IncludeReturnType && settings.UseFullName) { - result.Append (GetTypeReferenceString (field.DeclaringType, settings)); + result.Append (GetTypeReferenceString (field.DeclaringTypeDefinition, settings)); result.Append (settings.Markup (".")); } result.Append (settings.EmitName (field, FilterName (Format (field.Name)))); @@ -599,7 +601,7 @@ namespace MonoDevelop.CSharp } if (!settings.IncludeReturnType && settings.UseFullName) { - result.Append (GetTypeReferenceString (evt.DeclaringType, new OutputSettings (OutputFlags.UseFullName))); + result.Append (GetTypeReferenceString (evt.DeclaringTypeDefinition, new OutputSettings (OutputFlags.UseFullName))); result.Append (settings.Markup (".")); } @@ -625,7 +627,7 @@ namespace MonoDevelop.CSharp } if (!settings.IncludeReturnType && settings.UseFullName) { - result.Append (GetTypeReferenceString (property.DeclaringType, new OutputSettings (OutputFlags.UseFullName))); + result.Append (GetTypeReferenceString (property.DeclaringTypeDefinition, new OutputSettings (OutputFlags.UseFullName))); result.Append (settings.Markup (".")); } @@ -654,7 +656,7 @@ namespace MonoDevelop.CSharp } if (!settings.IncludeReturnType && settings.UseFullName) { - result.Append (GetTypeReferenceString (property.DeclaringType, new OutputSettings (OutputFlags.UseFullName))); + result.Append (GetTypeReferenceString (property.DeclaringTypeDefinition, new OutputSettings (OutputFlags.UseFullName))); result.Append (settings.Markup (".")); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs index 288fc62f37..d359a5400c 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserTypeNodeBuilder.cs @@ -28,6 +28,7 @@ using MonoDevelop.Ide.Gui.Components; using ICSharpCode.NRefactory.TypeSystem; using System; using Mono.Cecil; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { @@ -55,9 +56,19 @@ namespace MonoDevelop.AssemblyBrowser this.Widget = assemblyBrowserWidget; } - protected IProjectContent GetContent (ITreeNavigator treeBuilder) + protected IMember Resolve (ITreeNavigator treeBuilder, IUnresolvedMember member) { - return ((Tuple<AssemblyDefinition, IProjectContent>)treeBuilder.GetParentDataItem (typeof(Tuple<AssemblyDefinition, IProjectContent>), true)).Item2; + var mainAssembly = (IUnresolvedAssembly)treeBuilder.GetParentDataItem (typeof(IUnresolvedAssembly), true); + if (mainAssembly == null) + throw new NullReferenceException ("mainAssembly not found"); + var simpleCompilation = new SimpleCompilation (mainAssembly); + return member.CreateResolved (new SimpleTypeResolveContext (simpleCompilation)); + } + protected IType Resolve (ITreeNavigator treeBuilder, IUnresolvedTypeDefinition member) + { + var mainAssembly = (IUnresolvedAssembly)treeBuilder.GetParentDataItem (typeof(IUnresolvedAssembly), true); + var simpleCompilation = new SimpleCompilation (mainAssembly); + return member.Resolve (new SimpleTypeResolveContext (simpleCompilation)); } } } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs index e413e6a2e3..6d53633c7a 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyBrowserWidget.cs @@ -76,7 +76,7 @@ namespace MonoDevelop.AssemblyBrowser new ErrorNodeBuilder (), new AssemblyNodeBuilder (this), new ModuleReferenceNodeBuilder (), - new ModuleDefinitionNodeBuilder (this), +// new ModuleDefinitionNodeBuilder (this), new ReferenceFolderNodeBuilder (this), new ResourceFolderNodeBuilder (), new ResourceNodeBuilder (), @@ -297,7 +297,7 @@ namespace MonoDevelop.AssemblyBrowser if (args.Button == 2 || (args.Button == 1 && (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)) { AssemblyBrowserViewContent assemblyBrowserView = new AssemblyBrowserViewContent (); foreach (var cu in definitions) { - assemblyBrowserView.Load (cu.Item1); + assemblyBrowserView.Load (cu.AssemblyName); } IdeApp.Workbench.OpenDocument (assemblyBrowserView, true); ((AssemblyBrowserWidget)assemblyBrowserView.Control).Open (args.Link); @@ -484,17 +484,17 @@ namespace MonoDevelop.AssemblyBrowser string pattern = e.Argument.ToString ().ToUpper (); int types = 0, curType = 0; foreach (var unit in this.definitions) { - types += unit.Item2.GetTypes ().Count (); + types += unit.TopLevelTypeDefinitions.Count (); } - var members = new List<IMember> (); + var members = new List<IUnresolvedMember> (); switch (searchMode) { case SearchMode.Member: foreach (var unit in this.definitions) { - foreach (var type in unit.Item2.GetTypes ()) { + foreach (var type in unit.TopLevelTypeDefinitions) { if (worker.CancellationPending) return; curType++; - foreach (var member in type.GetMembers (unit.Item2)) { + foreach (var member in type.Members) { if (worker.CancellationPending) return; if (member.Name.ToUpper ().Contains (pattern)) { @@ -510,7 +510,7 @@ namespace MonoDevelop.AssemblyBrowser return; memberListStore.AppendValues (ImageService.GetPixbuf (member.GetStockIcon (), Gtk.IconSize.Menu), member.Name, - member.DeclaringType.FullName, + member.DeclaringTypeDefinition.FullName, "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } @@ -521,7 +521,7 @@ namespace MonoDevelop.AssemblyBrowser IdeApp.Workbench.StatusBar.BeginProgress (GettextCatalog.GetString ("Searching string in disassembled code...")); }); foreach (var unit in this.definitions) { - foreach (var type in unit.Item2.GetTypes ()) { + foreach (var type in unit.TopLevelTypeDefinitions) { if (worker.CancellationPending) return; curType++; @@ -541,7 +541,7 @@ namespace MonoDevelop.AssemblyBrowser return; memberListStore.AppendValues ("", //iImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), member.Name, - member.DeclaringType.FullName, + member.DeclaringTypeDefinition.FullName, "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } @@ -549,7 +549,7 @@ namespace MonoDevelop.AssemblyBrowser break; case SearchMode.Decompiler: foreach (var unit in this.definitions) { - foreach (var type in unit.Item2.GetTypes ()) { + foreach (var type in unit.TopLevelTypeDefinitions) { if (worker.CancellationPending) return; curType++; @@ -568,16 +568,16 @@ namespace MonoDevelop.AssemblyBrowser return; memberListStore.AppendValues ("", //ImageService.GetPixbuf (member.StockIcon, Gtk.IconSize.Menu), member.Name, - member.DeclaringType.FullName, + member.DeclaringTypeDefinition.FullName, "", //((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName, member); } }); break; case SearchMode.Type: - var typeList = new List<IType> (); + var typeList = new List<IUnresolvedTypeDefinition> (); foreach (var unit in this.definitions) { - foreach (var type in unit.Item2.GetTypes ()) { + foreach (var type in unit.TopLevelTypeDefinitions) { if (worker.CancellationPending) return; if (type.FullName.ToUpper ().IndexOf (pattern) >= 0) @@ -939,7 +939,7 @@ namespace MonoDevelop.AssemblyBrowser return; if (nav == null) { foreach (var definition in definitions.ToArray ()) { - foreach (var assemblyNameReference in definition.Item3.MainModule.AssemblyReferences) { + foreach (var assemblyNameReference in loader.GetCecilObject (definition).MainModule.AssemblyReferences) { string assemblyFile = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyLocation (assemblyNameReference.FullName, null); if (assemblyFile != null && System.IO.File.Exists (assemblyFile)) AddReference (assemblyFile); @@ -959,8 +959,8 @@ namespace MonoDevelop.AssemblyBrowser { AssemblyDefinition cu = null; foreach (var unit in definitions) { - if (unit.Item1 == fileName) - cu = unit.Item3; + if (unit.AssemblyName == fileName) + cu = loader.GetCecilObject (unit); } if (cu == null) return; @@ -1060,20 +1060,21 @@ namespace MonoDevelop.AssemblyBrowser } } - List<Tuple<string, IProjectContent, AssemblyDefinition>> definitions = new List<Tuple<string, IProjectContent, AssemblyDefinition>> (); - public IProjectContent AddReference (string fileName) + List<IUnresolvedAssembly> definitions = new List<IUnresolvedAssembly> (); + + public IUnresolvedAssembly AddReference (string fileName) { - IProjectContent result; - if (definitions.Any (d => d.Item1 == fileName)) - return definitions.First (d => d.Item1 == fileName).Item2; + IUnresolvedAssembly result; + if (definitions.Any (d => d.AssemblyName == fileName)) + return definitions.First (d => d.AssemblyName == fileName); var assembly = ReadAssembly (fileName); result = loader.LoadAssembly (assembly); - definitions.Add (Tuple.Create (fileName, result, assembly)); + definitions.Add (result); ITreeBuilder builder; if (definitions.Count == 1) { - builder = TreeView.LoadTree (Tuple.Create (assembly, result)); + builder = TreeView.LoadTree (result); } else { - builder = TreeView.AddChild (Tuple.Create (assembly, result)); + builder = TreeView.AddChild (result); } builder.MoveToFirstChild (); builder.Expanded = true; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs index ebc549a641..db55bc307b 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/AssemblyNodeBuilder.cs @@ -45,7 +45,7 @@ namespace MonoDevelop.AssemblyBrowser class AssemblyNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(Tuple<AssemblyDefinition, IProjectContent>); } + get { return typeof(IUnresolvedAssembly); } } public AssemblyNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -54,30 +54,42 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; - return compilationUnit.Name.Name; + var compilationUnit = (IUnresolvedAssembly)dataObject; + return compilationUnit.AssemblyName; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; - label = compilationUnit.Name.Name; + var compilationUnit = (IUnresolvedAssembly)dataObject; + label = compilationUnit.AssemblyName; icon = Context.GetIcon (Stock.Reference); } - public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; + var compilationUnit = (IUnresolvedAssembly)dataObject; - foreach (var module in compilationUnit.Modules) { - ctx.AddChild (module); + var namespaces = new Dictionary<string, Namespace> (); + bool publicOnly = builder.Options ["PublicApiOnly"]; + + foreach (var type in compilationUnit.TopLevelTypeDefinitions) { + if (publicOnly && !type.IsPublic) + continue; + if (!namespaces.ContainsKey (type.Namespace)) + namespaces[type.Namespace] = new Namespace (type.Namespace); + var ns = namespaces[type.Namespace]; + ns.Types.Add (type); + } + + foreach (var ns in namespaces.Values) { + builder.AddChild (ns); } } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)dataObject).Item1; - return compilationUnit.Modules.Any (); + var compilationUnit = (IUnresolvedAssembly)dataObject; + return compilationUnit.TopLevelTypeDefinitions.Any (); } #region IAssemblyBrowserNodeBuilder @@ -107,7 +119,7 @@ namespace MonoDevelop.AssemblyBrowser string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)navigator.DataItem).Item1; + var compilationUnit = Widget.CecilLoader.GetCecilObject ((IUnresolvedAssembly)navigator.DataItem); StringBuilder result = new StringBuilder (); PrintAssemblyHeader (result, compilationUnit); @@ -122,7 +134,7 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) { - var compilationUnit = ((Tuple<AssemblyDefinition, IProjectContent>)navigator.DataItem).Item1; + var compilationUnit = Widget.CecilLoader.GetCecilObject ((IUnresolvedAssembly)navigator.DataItem); 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 e3b23ed97b..e6fa493e51 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolder.cs @@ -34,12 +34,12 @@ namespace MonoDevelop.AssemblyBrowser { public class BaseTypeFolder : IDisposable { - public ITypeDefinition Type { + public IUnresolvedTypeDefinition Type { get; private set; } - public BaseTypeFolder (ITypeDefinition type) + public BaseTypeFolder (IUnresolvedTypeDefinition 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 d738b08413..ced12cb697 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/BaseTypeFolderNodeBuilder.cs @@ -63,9 +63,8 @@ namespace MonoDevelop.AssemblyBrowser public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { var baseTypeFolder = (BaseTypeFolder)dataObject; - var ctx = GetContent (builder); foreach (var type in baseTypeFolder.Type.BaseTypes) { - builder.AddChild (type.Resolve (ctx)); + builder.AddChild (type); } } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs index 01c761976b..284ca4d498 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomEventNodeBuilder.cs @@ -39,13 +39,14 @@ using System.Collections.Generic; using Mono.Cecil; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { class DomEventNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IEvent); } + get { return typeof(IUnresolvedEvent); } } public DomEventNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -54,14 +55,15 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var evt = (IEvent)dataObject; + var evt = (IUnresolvedEvent)dataObject; return evt.FullName; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var evt = (IEvent)dataObject; - label = Ambience.GetString (GetContent (treeBuilder), evt, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); + var evt = (IUnresolvedEvent)dataObject; + var resolved = Resolve (treeBuilder, evt); + label = Ambience.GetString (resolved, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); if (evt.IsPrivate || evt.IsInternal) label = DomMethodNodeBuilder.FormatPrivate (label); icon = ImageService.GetPixbuf (evt.GetStockIcon (), Gtk.IconSize.Menu); @@ -69,14 +71,14 @@ namespace MonoDevelop.AssemblyBrowser 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 IUnresolvedEvent) + return ((IUnresolvedEvent)thisNode.DataItem).Name.CompareTo (((IUnresolvedEvent)otherNode.DataItem).Name); return 1; } public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - var evt = (IEvent)dataObject; + var evt = (IUnresolvedEvent)dataObject; if (evt.CanAdd) ctx.AddChild (evt.AddAccessor); if (evt.CanRemove) @@ -93,10 +95,11 @@ namespace MonoDevelop.AssemblyBrowser #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - var evt = (IEvent)navigator.DataItem; + var evt = (IUnresolvedEvent)navigator.DataItem; + var resolved = Resolve (navigator, evt); StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); -// result.Append (Ambience.GetString (evt, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -106,22 +109,23 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var evt = CecilLoader.GetCecilObject ((IEvent)navigator.DataItem); + var evt = CecilLoader.GetCecilObject ((IUnresolvedEvent)navigator.DataItem); return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleEvent (evt)); } List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var evt = CecilLoader.GetCecilObject ((IEvent)navigator.DataItem); + var evt = CecilLoader.GetCecilObject ((IUnresolvedEvent)navigator.DataItem); return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), evt.DeclaringType, b => b.AddEvent (evt)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - var evt = (IEvent)navigator.DataItem; + var evt = (IUnresolvedEvent)navigator.DataItem; + var resolved = Resolve (navigator, evt); StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (GetContent (navigator), evt, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); @@ -131,7 +135,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (evt), options)); + result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (resolved), 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 d91977843a..351f61472f 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomFieldNodeBuilder.cs @@ -39,13 +39,14 @@ using System.Collections.Generic; using Mono.Cecil; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { class DomFieldNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IField); } + get { return typeof(IUnresolvedField); } } public DomFieldNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -55,17 +56,18 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var field = (IField)dataObject; + var field = (IUnresolvedField)dataObject; return field.FullName; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var field = (IField)dataObject; - label = Ambience.GetString (GetContent (treeBuilder), field, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); + var field = (IUnresolvedField)dataObject; + var resolved = Resolve (treeBuilder, field); + label = Ambience.GetString (resolved, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); if (field.IsPrivate || field.IsInternal) label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (((IEntity)field).GetStockIcon (), Gtk.IconSize.Menu); + icon = ImageService.GetPixbuf (field.GetStockIcon (), Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) @@ -76,18 +78,19 @@ namespace MonoDevelop.AssemblyBrowser 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 IUnresolvedField) + return ((IUnresolvedField)thisNode.DataItem).Name.CompareTo (((IUnresolvedField)otherNode.DataItem).Name); return -1; } #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - var field = (IField)navigator.DataItem; + var field = (IUnresolvedField)navigator.DataItem; + var resolved = Resolve (navigator, field); StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (GetContent (navigator), field, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -97,22 +100,23 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var field = CecilLoader.GetCecilObject ((IField)navigator.DataItem); + var field = CecilLoader.GetCecilObject ((IUnresolvedField)navigator.DataItem); return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleField (field)); } List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var field = CecilLoader.GetCecilObject ((IField)navigator.DataItem); + var field = CecilLoader.GetCecilObject ((IUnresolvedField)navigator.DataItem); return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), field.DeclaringType, b => b.AddField (field)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - var field = (IField)navigator.DataItem; + var field = (IUnresolvedField)navigator.DataItem; + var resolved = Resolve (navigator, field); StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (GetContent (navigator), field, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); @@ -122,7 +126,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (field), options)); + result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (resolved), 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 fb15dbd606..a92e96e0d1 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomMethodNodeBuilder.cs @@ -43,13 +43,14 @@ using ICSharpCode.Decompiler.Disassembler; using Mono.TextEditor; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { class DomMethodNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IMethod); } + get { return typeof(IUnresolvedMethod); } } public DomMethodNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -59,7 +60,7 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var method = (IMethod)dataObject; + var method = (IUnresolvedMethod)dataObject; return method.FullName; } @@ -69,21 +70,21 @@ namespace MonoDevelop.AssemblyBrowser } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var method = (IMethod)dataObject; - var ctx = GetContent (treeBuilder); - label = Ambience.GetString (ctx, method, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); + var method = (IUnresolvedMethod)dataObject; + var resolved = Resolve (treeBuilder, method); + label = Ambience.GetString (resolved, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); if (method.IsPrivate || method.IsInternal) label = DomMethodNodeBuilder.FormatPrivate (label); - icon = ImageService.GetPixbuf (method.GetStockIcon (), Gtk.IconSize.Menu); + icon = ImageService.GetPixbuf (resolved.GetStockIcon (), Gtk.IconSize.Menu); } public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode) { - if (!(otherNode.DataItem is IMethod)) + if (!(otherNode.DataItem is IUnresolvedMethod)) return 1; - if (otherNode.DataItem is IMethod) - return ((IMethod)thisNode.DataItem).Name.CompareTo (((IMethod)otherNode.DataItem).Name); + if (otherNode.DataItem is IUnresolvedMethod) + return ((IUnresolvedMethod)thisNode.DataItem).Name.CompareTo (((IUnresolvedMethod)otherNode.DataItem).Name); return -1; } @@ -101,10 +102,11 @@ namespace MonoDevelop.AssemblyBrowser string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - var method = (IMethod)navigator.DataItem; + var method = (IUnresolvedMethod)navigator.DataItem; + var resolved = Resolve (navigator, method); StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (GetContent (navigator), method, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); PrintDeclaringType (result, navigator); @@ -181,7 +183,7 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) { - var method = CecilLoader.GetCecilObject ((IMethod)navigator.DataItem); + var method = CecilLoader.GetCecilObject ((IUnresolvedMethod)navigator.DataItem); return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), method.DeclaringType, b => b.AddMethod (method)); } @@ -206,7 +208,7 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var method = CecilLoader.GetCecilObject ((IMethod)navigator.DataItem); + var method = CecilLoader.GetCecilObject ((IUnresolvedMethod)navigator.DataItem); if (method == null) return null; return Disassemble (data, rd => rd.DisassembleMethod (method)); @@ -214,10 +216,11 @@ namespace MonoDevelop.AssemblyBrowser string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - var method = (IMethod)navigator.DataItem; + var method = (IUnresolvedMethod)navigator.DataItem; + var resolved = Resolve (navigator, method); StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (GetContent (navigator), method, OutputFlags.AssemblyBrowserDescription | OutputFlags.IncludeConstraints)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription | OutputFlags.IncludeConstraints)); result.Append ("</big>"); result.AppendLine (); @@ -227,7 +230,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (method), options)); + result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (resolved), 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 1fa7cbae6f..4f3aa0a332 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomPropertyNodeBuilder.cs @@ -40,13 +40,14 @@ using System.Collections.Generic; using Mono.Cecil; using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { class DomPropertyNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(IProperty); } + get { return typeof(IUnresolvedProperty); } } public DomPropertyNodeBuilder (AssemblyBrowserWidget widget) : base (widget) @@ -56,14 +57,15 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var property = (IProperty)dataObject; + var property = (IUnresolvedProperty)dataObject; return property.Name; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var property = (IProperty)dataObject; - label = Ambience.GetString (GetContent (treeBuilder), property, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); + var property = (IUnresolvedProperty)dataObject; + var resolved = Resolve (treeBuilder, property); + label = Ambience.GetString (resolved, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.CompletionListFomat); if (property.IsPrivate || property.IsInternal) label = DomMethodNodeBuilder.FormatPrivate (label); icon = ImageService.GetPixbuf (property.GetStockIcon (), Gtk.IconSize.Menu); @@ -82,16 +84,16 @@ namespace MonoDevelop.AssemblyBrowser public override void BuildChildNodes (ITreeBuilder ctx, object dataObject) { - var property = (IProperty)dataObject; + var property = (IUnresolvedProperty)dataObject; if (property.CanGet) ctx.AddChild (property.Getter); - if (property.CanSet != null) + if (property.CanSet) ctx.AddChild (property.Setter); } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { - var property = (IProperty)dataObject; + var property = (IUnresolvedProperty)dataObject; return property.CanGet != null || property.CanSet != null; } @@ -99,10 +101,11 @@ namespace MonoDevelop.AssemblyBrowser #region IAssemblyBrowserNodeBuilder string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) { - var property = (IProperty)navigator.DataItem; + var property = (IUnresolvedProperty)navigator.DataItem; + var resolved = Resolve (navigator, property); StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); - result.Append (Ambience.GetString (GetContent (navigator), property, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); DomMethodNodeBuilder.PrintDeclaringType (result, navigator); @@ -112,7 +115,7 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Disassemble (TextEditorData data, ITreeNavigator navigator) { - var property = CecilLoader.GetCecilObject ((IProperty)navigator.DataItem); + var property = CecilLoader.GetCecilObject ((IUnresolvedProperty)navigator.DataItem); return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleProperty (property)); } @@ -130,16 +133,17 @@ namespace MonoDevelop.AssemblyBrowser List<ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile (TextEditorData data, ITreeNavigator navigator) { - var property = CecilLoader.GetCecilObject ((IProperty)navigator.DataItem); + var property = CecilLoader.GetCecilObject ((IUnresolvedProperty)navigator.DataItem); return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), property.DeclaringType, b => b.AddProperty (property)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - var property = (IProperty)navigator.DataItem; + var property = (IUnresolvedProperty)navigator.DataItem; + var resolved = Resolve (navigator, property); StringBuilder result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (GetContent (navigator), property, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); @@ -149,7 +153,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (property), options)); + result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (resolved), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs index bf99e309bb..048ef46bfa 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/DomTypeNodeBuilder.cs @@ -42,13 +42,14 @@ using Mono.TextEditor; using System.Collections.Generic; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace MonoDevelop.AssemblyBrowser { class DomTypeNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder { public override Type NodeDataType { - get { return typeof(ITypeDefinition); } + get { return typeof(IUnresolvedTypeDefinition); } } public override string ContextMenuAddinPath { @@ -110,15 +111,16 @@ namespace MonoDevelop.AssemblyBrowser public override string GetNodeName (ITreeNavigator thisNode, object dataObject) { - var type = (ITypeDefinition)dataObject; + var type = (IUnresolvedTypeDefinition)dataObject; return type.Name; } public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { - var type = (ITypeDefinition)dataObject; - label = Ambience.GetString (GetContent (treeBuilder), (IType)type, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); - if (type.GetDefinition ().IsPrivate || type.GetDefinition ().IsPrivate) + var type = (IUnresolvedTypeDefinition)dataObject; + var resolved = Resolve (treeBuilder, type); + label = Ambience.GetString (resolved, OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup); + if (type.IsPrivate) label = DomMethodNodeBuilder.FormatPrivate (label); icon = ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu); @@ -126,11 +128,11 @@ namespace MonoDevelop.AssemblyBrowser public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { - var type = (ITypeDefinition)dataObject; + var type = (IUnresolvedTypeDefinition)dataObject; var list = new System.Collections.ArrayList (); list.Add (new BaseTypeFolder (type)); bool publicOnly = builder.Options ["PublicApiOnly"]; - foreach (var t in type.NestedTypes.Where (m => !m.GetDefinition ().IsSynthetic && !(publicOnly && m.GetDefinition ().IsPublic))) + foreach (var t in type.NestedTypes.Where (m => !m.IsSynthetic && !(publicOnly && m.IsPublic))) list.Add (t); foreach (var m in type.Members.Where (m => !m.IsSynthetic && !(publicOnly && !(m.IsPublic || m.IsInternal)))) list.Add (m); @@ -157,10 +159,11 @@ namespace MonoDevelop.AssemblyBrowser public string GetDescription (ITreeNavigator navigator) { - var type = (IType)navigator.DataItem; + var type = (IUnresolvedTypeDefinition)navigator.DataItem; + var resolved = Resolve (navigator, type); StringBuilder result = new StringBuilder (); result.Append ("<span font_family=\"monospace\">"); -// result.Append (Ambience.GetString (type, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</span>"); result.AppendLine (); result.Append (String.Format (GettextCatalog.GetString ("<b>Name:</b>\t{0}"), type.FullName)); @@ -171,22 +174,23 @@ namespace MonoDevelop.AssemblyBrowser public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) { - var type = CecilLoader.GetCecilObject ((ITypeDefinition)navigator.DataItem); + var type = CecilLoader.GetCecilObject ((IUnresolvedTypeDefinition)navigator.DataItem); return DomMethodNodeBuilder.Disassemble (data, rd => rd.DisassembleType (type)); } public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) { - var type = CecilLoader.GetCecilObject ((ITypeDefinition)navigator.DataItem); + var type = CecilLoader.GetCecilObject ((IUnresolvedTypeDefinition)navigator.DataItem); return DomMethodNodeBuilder.Decompile (data, DomMethodNodeBuilder.GetModule (navigator), type, b => b.AddType (type)); } string IAssemblyBrowserNodeBuilder.GetDocumentationMarkup (ITreeNavigator navigator) { - var type = (ITypeDefinition)navigator.DataItem; + var type = (IUnresolvedTypeDefinition)navigator.DataItem; + var resolved = Resolve (navigator, type); var result = new StringBuilder (); result.Append ("<big>"); - result.Append (Ambience.GetString (GetContent (navigator), (IType) type, OutputFlags.AssemblyBrowserDescription)); + result.Append (Ambience.GetString (resolved, OutputFlags.AssemblyBrowserDescription)); result.Append ("</big>"); result.AppendLine (); @@ -196,7 +200,7 @@ namespace MonoDevelop.AssemblyBrowser options.Ambience = Ambience; result.AppendLine (); - result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (type), options)); + result.Append (AmbienceService.GetDocumentationMarkup (AmbienceService.GetDocumentation (resolved.GetDefinition ()), options)); return result.ToString (); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs index 88bb0aa92f..9be18d930b 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/ModuleDefinitionNodeBuilder.cs @@ -1,151 +1,151 @@ +//// +//// ModuleDefinitionNodeBuilder.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. +//// // -// ModuleDefinitionNodeBuilder.cs +//using System; +//using System.Text; +//using System.Collections.Generic; // -// Author: -// Mike Krüger <mkrueger@novell.com> +//using MonoDevelop.Core; +//using MonoDevelop.Ide.Gui; +//using MonoDevelop.Ide.Gui.Components; +//using Mono.TextEditor; +//using Mono.Cecil; +//using System.Linq; // -// 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 System.Text; -using System.Collections.Generic; - -using MonoDevelop.Core; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Ide.Gui.Components; -using Mono.TextEditor; -using Mono.Cecil; -using System.Linq; - -namespace MonoDevelop.AssemblyBrowser -{ - class ModuleDefinitionNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder - { - public override Type NodeDataType { - get { return typeof(ModuleDefinition); } - } - - public ModuleDefinitionNodeBuilder (AssemblyBrowserWidget widget) : base (widget) - { - - } - - public override string GetNodeName (ITreeNavigator thisNode, object dataObject) - { - return dataObject != null ? dataObject.ToString () : "null module"; - } - - public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) - { - var module = (ModuleDefinition)dataObject; - label = module.Name; - icon = Context.GetIcon (Stock.OpenFolder); - closedIcon = Context.GetIcon (Stock.ClosedFolder); - } - - public override void BuildChildNodes (ITreeBuilder builder, object dataObject) - { - var module = (ModuleDefinition)dataObject; - Dictionary<string, Namespace> namespaces = new Dictionary<string, Namespace> (); - bool publicOnly = builder.Options ["PublicApiOnly"]; - var ctx = GetContent (builder); - foreach (var ns in ctx.GetNamespaces ()) { - var newSpace = new Namespace (ns); - newSpace.Types.AddRange (ctx.GetTypes (ns, StringComparer.Ordinal).Where (c => !publicOnly || c.IsPublic )); - if (newSpace.Types.Count > 0) - namespaces [ns] = newSpace; - } - builder.AddChild (new ReferenceFolder (module)); - if (module.Resources.Count > 0) - builder.AddChild (new ResourceFolder (module)); - foreach (Namespace ns in namespaces.Values) { - builder.AddChild (ns); - } - } - - public override bool HasChildNodes (ITreeBuilder builder, object dataObject) - { - return true; - } - - #region IAssemblyBrowserNodeBuilder - void PrintModuleHeader (StringBuilder result, ModuleDefinition module) - { - result.Append (Ambience.SingleLineComment ( - String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), - module.Name))); - result.AppendLine (); - } - - string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) - { - var module = (ModuleDefinition)navigator.DataItem; - StringBuilder result = new StringBuilder (); - PrintModuleHeader (result, module); - - result.Append (String.Format (GettextCatalog.GetString ("<b>Version:</b>\t{0}"), - module.Mvid)); - result.AppendLine (); - - return result.ToString (); - } - - public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) - { - var module = (ModuleDefinition)navigator.DataItem; - var result = new StringBuilder (); - PrintModuleHeader (result, module); - - HashSet<string> namespaces = new HashSet<string> (); - - foreach (var type in module.Types) { -/* if ((type.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate) - continue;*/ - if (String.IsNullOrEmpty (type.Namespace)) - continue; - namespaces.Add (type.Namespace); - } - - foreach (string ns in namespaces) { - result.Append ("namespace "); - result.Append (ns); - result.AppendLine (); - } - - data.Text = result.ToString (); - return null; - } - - public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) - { - return Disassemble (data, navigator); - } - - public string GetDocumentationMarkup (ITreeNavigator navigator) - { - var module = (ModuleDefinition)navigator.DataItem; - return "<big>" + String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), module.Name) + "</big>"; - } - #endregion - } -} +//namespace MonoDevelop.AssemblyBrowser +//{ +// class ModuleDefinitionNodeBuilder : AssemblyBrowserTypeNodeBuilder, IAssemblyBrowserNodeBuilder +// { +// public override Type NodeDataType { +// get { return typeof(ModuleDefinition); } +// } +// +// public ModuleDefinitionNodeBuilder (AssemblyBrowserWidget widget) : base (widget) +// { +// +// } +// +// public override string GetNodeName (ITreeNavigator thisNode, object dataObject) +// { +// return dataObject != null ? dataObject.ToString () : "null module"; +// } +// +// public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) +// { +// var module = (ModuleDefinition)dataObject; +// label = module.Name; +// icon = Context.GetIcon (Stock.OpenFolder); +// closedIcon = Context.GetIcon (Stock.ClosedFolder); +// } +// +// public override void BuildChildNodes (ITreeBuilder builder, object dataObject) +// { +// var module = (ModuleDefinition)dataObject; +// Dictionary<string, Namespace> namespaces = new Dictionary<string, Namespace> (); +// bool publicOnly = builder.Options ["PublicApiOnly"]; +// var ctx = GetContent (builder); +// foreach (var ns in ctx.GetNamespaces ()) { +// var newSpace = new Namespace (ns); +// newSpace.Types.AddRange (ctx.GetTypes (ns, StringComparer.Ordinal).Where (c => !publicOnly || c.IsPublic )); +// if (newSpace.Types.Count > 0) +// namespaces [ns] = newSpace; +// } +// builder.AddChild (new ReferenceFolder (module)); +// if (module.Resources.Count > 0) +// builder.AddChild (new ResourceFolder (module)); +// foreach (Namespace ns in namespaces.Values) { +// builder.AddChild (ns); +// } +// } +// +// public override bool HasChildNodes (ITreeBuilder builder, object dataObject) +// { +// return true; +// } +// +// #region IAssemblyBrowserNodeBuilder +// void PrintModuleHeader (StringBuilder result, ModuleDefinition module) +// { +// result.Append (Ambience.SingleLineComment ( +// String.Format (GettextCatalog.GetString ("Module <b>{0}</b>"), +// module.Name))); +// result.AppendLine (); +// } +// +// string IAssemblyBrowserNodeBuilder.GetDescription (ITreeNavigator navigator) +// { +// var module = (ModuleDefinition)navigator.DataItem; +// StringBuilder result = new StringBuilder (); +// PrintModuleHeader (result, module); +// +// result.Append (String.Format (GettextCatalog.GetString ("<b>Version:</b>\t{0}"), +// module.Mvid)); +// result.AppendLine (); +// +// return result.ToString (); +// } +// +// public List<ReferenceSegment> Disassemble (TextEditorData data, ITreeNavigator navigator) +// { +// var module = (ModuleDefinition)navigator.DataItem; +// var result = new StringBuilder (); +// PrintModuleHeader (result, module); +// +// HashSet<string> namespaces = new HashSet<string> (); +// +// foreach (var type in module.Types) { +///* if ((type.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate) +// continue;*/ +// if (String.IsNullOrEmpty (type.Namespace)) +// continue; +// namespaces.Add (type.Namespace); +// } +// +// foreach (string ns in namespaces) { +// result.Append ("namespace "); +// result.Append (ns); +// result.AppendLine (); +// } +// +// data.Text = result.ToString (); +// return null; +// } +// +// public List<ReferenceSegment> Decompile (TextEditorData data, ITreeNavigator navigator) +// { +// return Disassemble (data, navigator); +// } +// +// public string GetDocumentationMarkup (ITreeNavigator navigator) +// { +// 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/Namespace.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs index d51ea7d2ae..e3863df979 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/Namespace.cs @@ -35,14 +35,14 @@ namespace MonoDevelop.AssemblyBrowser { public class Namespace : IDisposable { - List<ITypeDefinition> types = new List<ITypeDefinition> (); + List<IUnresolvedTypeDefinition> types = new List<IUnresolvedTypeDefinition> (); public string Name { get; private set; } - public List<ITypeDefinition> Types { + public List<IUnresolvedTypeDefinition> Types { get { return types; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/StockIcons.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/StockIcons.cs index 898bfd018f..62e0e1618b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/StockIcons.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/StockIcons.cs @@ -105,6 +105,8 @@ namespace MonoDevelop.TypeSystem return ((IType)element).GetStockIcon (); if (element is ITypeParameter) return ((ITypeParameter)element).GetStockIcon (); + if (element is IUnresolvedEntity) + return ((IUnresolvedEntity)element).GetStockIcon (); return ((IEntity)element).GetStockIcon (); } @@ -194,5 +196,25 @@ namespace MonoDevelop.TypeSystem } return ""; } + public static string GetStockIcon (this IUnresolvedEntity entity) + { + switch (entity.EntityType) { + case EntityType.TypeDefinition: + return GetStockIcon ((IUnresolvedTypeDefinition)entity); + case EntityType.Field: + return fieldIconTable [ModifierToOffset (entity.Accessibility)]; + case EntityType.Method: + case EntityType.Constructor: + case EntityType.Destructor: + case EntityType.Operator: + return methodIconTable [ModifierToOffset (entity.Accessibility)]; + case EntityType.Property: + case EntityType.Indexer: + return propertyIconTable [ModifierToOffset (entity.Accessibility)]; + case EntityType.Event: + return eventIconTable [ModifierToOffset (entity.Accessibility)]; + } + return ""; + } } } |