From bda8abaaa9c54f85de1ee6a8c96139e6a8431045 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 24 Aug 2013 18:09:38 +0200 Subject: [PATCH] implement some more methods in ILSpyUnresolvedFile --- .../ILSpyAddIn/ILSpyUnresolvedFile.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyUnresolvedFile.cs b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyUnresolvedFile.cs index f0268b9cee..3e7d286d13 100644 --- a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyUnresolvedFile.cs +++ b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyUnresolvedFile.cs @@ -65,17 +65,36 @@ namespace ICSharpCode.ILSpyAddIn public IUnresolvedTypeDefinition GetTopLevelTypeDefinition(TextLocation location) { - throw new NotImplementedException(); + return FindEntity(topLevel, location); } public IUnresolvedTypeDefinition GetInnermostTypeDefinition(TextLocation location) { - throw new NotImplementedException(); + IUnresolvedTypeDefinition parent = null; + IUnresolvedTypeDefinition type = GetTopLevelTypeDefinition(location); + while (type != null) { + parent = type; + type = FindEntity(parent.NestedTypes, location); + } + return parent; } public IUnresolvedMember GetMember(TextLocation location) { - throw new NotImplementedException(); + IUnresolvedTypeDefinition type = GetInnermostTypeDefinition(location); + if (type == null) + return null; + return FindEntity(type.Members, location); + } + + static T FindEntity(IList list, TextLocation location) where T : class, IUnresolvedEntity + { + // This could be improved using a binary search + foreach (T entity in list) { + if (entity.Region.IsInside(location.Line, location.Column)) + return entity; + } + return null; } public string FileName { @@ -92,9 +111,7 @@ namespace ICSharpCode.ILSpyAddIn } public IList TopLevelTypeDefinitions { - get { - return topLevel; - } + get { return topLevel; } } public IList AssemblyAttributes {