From d4f9531f874d1e2060f3f87fcf13413f9cb15bcd Mon Sep 17 00:00:00 2001 From: WMJ Date: Tue, 4 Jun 2019 09:26:04 +0800 Subject: [PATCH] - Fixed sort order of multi-location items - Removed broken "Find All References" command from context menu of symbol list --- Codist/Controls/CSharpSymbolContextMenu.cs | 15 ++++++++++----- Codist/SmartBars/CSharpSmartBar.cs | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Codist/Controls/CSharpSymbolContextMenu.cs b/Codist/Controls/CSharpSymbolContextMenu.cs index 52c67636..3e989f00 100644 --- a/Codist/Controls/CSharpSymbolContextMenu.cs +++ b/Codist/Controls/CSharpSymbolContextMenu.cs @@ -80,6 +80,9 @@ public void AddAnalysisCommands() { } //Items.Add(CreateCommandMenu("Find references...", KnownImageIds.ReferencedDimension, _Symbol, "No reference found", FindReferences)); Items.Add(CreateItem(KnownImageIds.FindSymbol, "Find Symbol with Name " + _Symbol.Name + "...", () => FindSymbolWithName(_Symbol, _SemanticContext))); + } + + public void AddFindAllReferencesCommand() { Items.Add(CreateItem(KnownImageIds.ReferencedDimension, "Find All References", FindAllReferences)); } @@ -301,16 +304,18 @@ static void FindSymbolWithName(ISymbol symbol, SemanticContext context) { internal static void ShowLocations(ISymbol symbol, SemanticContext context) { var m = new SymbolMenu(context, SymbolListType.Locations); - var locs = symbol.GetSourceLocations().Sort((x, y) => String.CompareOrdinal(x.SourceTree.FilePath, y.SourceTree.FilePath)); + var locs = new SortedList<(string, string), Location>(); + foreach (var item in symbol.GetSourceLocations()) { + locs.Add((System.IO.Path.GetDirectoryName(item.SourceTree.FilePath), System.IO.Path.GetFileName(item.SourceTree.FilePath)), item); + } m.Title.SetGlyph(ThemeHelper.GetImage(symbol.GetImageId())) .Append(symbol.ToDisplayString(WpfHelper.MemberNameFormat), true) .Append(" source locations: ") - .Append(locs.Length); + .Append(locs.Count); foreach (var loc in locs) { - m.Menu.Add(loc); + m.Menu.Add(loc.Value); } - locs = symbol.Locations.RemoveAll(l => l.IsInMetadata == false).Sort((x, y) => String.CompareOrdinal(x.MetadataModule.Name, y.MetadataModule.Name)); - foreach (var loc in locs) { + foreach (var loc in symbol.Locations.RemoveAll(l => l.IsInMetadata == false).Sort((x, y) => String.CompareOrdinal(x.MetadataModule.Name, y.MetadataModule.Name))) { m.Menu.Add(loc); } m.Show(); diff --git a/Codist/SmartBars/CSharpSmartBar.cs b/Codist/SmartBars/CSharpSmartBar.cs index 096aae0a..59678459 100644 --- a/Codist/SmartBars/CSharpSmartBar.cs +++ b/Codist/SmartBars/CSharpSmartBar.cs @@ -126,6 +126,7 @@ void AddContextualCommands(CancellationToken cancellationToken) { }; m.ItemClicked += (s, args) => HideToolBar(); m.AddAnalysisCommands(); + m.AddFindAllReferencesCommand(); m.AddGoToAnyCommands(); ctx.Sender.ContextMenu = m; m.IsOpen = true;