From 51e45a52e22deb561b6269c8846ee3c20955dcee Mon Sep 17 00:00:00 2001 From: WMJ Date: Thu, 18 May 2023 20:27:27 +0800 Subject: [PATCH] + Implementation of #258, but suppressed from release --- Codist/QuickInfo/CSharpQuickInfo.cs | 44 ++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Codist/QuickInfo/CSharpQuickInfo.cs b/Codist/QuickInfo/CSharpQuickInfo.cs index 44682781..f7005400 100644 --- a/Codist/QuickInfo/CSharpQuickInfo.cs +++ b/Codist/QuickInfo/CSharpQuickInfo.cs @@ -1389,18 +1389,42 @@ static void ShowInterfaces(InfoContainer qiContent, ITypeSymbol type) { return; } var info = new ThemedTipDocument().AppendTitle(IconIds.Interface, R.T_Interface); - foreach (var item in declaredInterfaces) { - info.Append(new ThemedTipParagraph(item.IsDisposable() ? IconIds.Disposable : item.GetImageId(), ToUIText(item))); + //ListInterfacesSortedByNamespace(info, declaredInterfaces, inheritedInterfaces); + ListInterfacesInLogicalOrder(info, declaredInterfaces, inheritedInterfaces); + qiContent.Add(info); + + void ListInterfacesSortedByNamespace(ThemedTipDocument d, ImmutableArray.Builder di, ImmutableArray<(INamedTypeSymbol intf, ITypeSymbol baseType)>.Builder ii) { + var allInterfaces = new List<(string, ThemedTipParagraph)>(di.Count + ii.Count); + foreach (var item in di) { + allInterfaces.Add((item.ToDisplayString(CodeAnalysisHelper.QualifiedTypeNameFormat), new ThemedTipParagraph(item.IsDisposable() ? IconIds.Disposable : item.GetImageId(), ToUIText(item)))); + } + foreach (var (intf, baseType) in ii) { + allInterfaces.Add((intf.ToDisplayString(CodeAnalysisHelper.QualifiedTypeNameFormat), new ThemedTipParagraph( + intf.IsDisposable() ? IconIds.Disposable : intf.GetImageId(), + ToUIText(intf) + .Append(" : ", SymbolFormatter.SemiTransparent.PlainText) + .Append(ThemeHelper.GetImage(baseType.GetImageId()).WrapMargin(WpfHelper.GlyphMargin).SetOpacity(SymbolFormatter.TransparentLevel)) + .AddSymbol(baseType, false, SymbolFormatter.SemiTransparent)))); + } + allInterfaces.Sort((x, y) => x.Item1.CompareTo(y.Item1)); + foreach (var item in allInterfaces) { + d.Append(item.Item2); + } } - foreach (var (intf, baseType) in inheritedInterfaces) { - info.Append(new ThemedTipParagraph( - intf.IsDisposable() ? IconIds.Disposable : intf.GetImageId(), - ToUIText(intf) - .Append(" : ", SymbolFormatter.SemiTransparent.PlainText) - .Append(ThemeHelper.GetImage(baseType.GetImageId()).WrapMargin(WpfHelper.GlyphMargin).SetOpacity(SymbolFormatter.TransparentLevel)) - .AddSymbol(baseType, false, SymbolFormatter.SemiTransparent))); + + void ListInterfacesInLogicalOrder(ThemedTipDocument d, ImmutableArray.Builder di, ImmutableArray<(INamedTypeSymbol intf, ITypeSymbol baseType)>.Builder ii) { + foreach (var item in di) { + d.Append(new ThemedTipParagraph(item.IsDisposable() ? IconIds.Disposable : item.GetImageId(), ToUIText(item))); + } + foreach (var (intf, baseType) in ii) { + d.Append(new ThemedTipParagraph( + intf.IsDisposable() ? IconIds.Disposable : intf.GetImageId(), + ToUIText(intf) + .Append(" : ", SymbolFormatter.SemiTransparent.PlainText) + .Append(ThemeHelper.GetImage(baseType.GetImageId()).WrapMargin(WpfHelper.GlyphMargin).SetOpacity(SymbolFormatter.TransparentLevel)) + .AddSymbol(baseType, false, SymbolFormatter.SemiTransparent))); + } } - qiContent.Add(info); } static void FindInterfacesForType(ITypeSymbol type, bool useType, ImmutableArray interfaces, ImmutableArray<(INamedTypeSymbol, ITypeSymbol)>.Builder inheritedInterfaces, HashSet all) {