From 337b5815946e5c0c37db2b6cfb316041bb908497 Mon Sep 17 00:00:00 2001 From: WMJ Date: Sun, 6 May 2018 20:57:53 +0800 Subject: [PATCH] Version 2.8 --- Codist/CodistPackage.cs | 2 +- Codist/Helpers/CodeAnalysisHelper.cs | 46 +++++++++++++++---- Codist/Properties/AssemblyInfo.cs | 4 +- .../CSharpQuickInfoSourceProvider.cs | 7 ++- Codist/source.extension.vsixmanifest | 2 +- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Codist/CodistPackage.cs b/Codist/CodistPackage.cs index 62785289..0d8e7146 100644 --- a/Codist/CodistPackage.cs +++ b/Codist/CodistPackage.cs @@ -22,7 +22,7 @@ namespace Codist /// /// [PackageRegistration(UseManagedResourcesOnly = true)] - [InstalledProductRegistration("#110", "#112", "2.7", IconResourceID = 400)] // Information on this package for Help/About + [InstalledProductRegistration("#110", "#112", "2.8", IconResourceID = 400)] // Information on this package for Help/About [Guid(PackageGuidString)] [ProvideOptionPage(typeof(Options.Misc), Constants.NameOfMe, "General", 0, 0, true)] [ProvideOptionPage(typeof(Options.CSharp), Constants.NameOfMe, "C#", 0, 0, true, Sort = 10)] diff --git a/Codist/Helpers/CodeAnalysisHelper.cs b/Codist/Helpers/CodeAnalysisHelper.cs index 35f5d6a8..9fb5383f 100644 --- a/Codist/Helpers/CodeAnalysisHelper.cs +++ b/Codist/Helpers/CodeAnalysisHelper.cs @@ -231,37 +231,63 @@ public static bool IsType(this CodeMemberType type) { public static bool IsMember(this CodeMemberType type) { return type > CodeMemberType.Member && type < CodeMemberType.Other; } - public static XElement GetBaseTypeDocumentation(this ISymbol symbol, out ISymbol baseType) { - return GetBaseTypeDocumentation(symbol, symbol, out baseType); + public static XElement InheritDocumentation(this ISymbol symbol, out ISymbol baseMember) { + return InheritDocumentation(symbol, symbol, out baseMember); } - static XElement GetBaseTypeDocumentation(ISymbol symbol, ISymbol querySymbol, out ISymbol baseType) { + static XElement InheritDocumentation(ISymbol symbol, ISymbol querySymbol, out ISymbol baseMember) { var t = symbol.Kind == SymbolKind.NamedType ? symbol as INamedTypeSymbol : symbol.ContainingType; if (t == null // go to the base type if not querying interface || t.TypeKind != TypeKind.Interface && (t = t.BaseType) == null ) { - baseType = null; + baseMember = null; return null; } XElement doc; var member = t.GetMembers(querySymbol.Name).FirstOrDefault(i => i.MatchSignature(querySymbol.Kind, querySymbol.GetReturnType(), querySymbol.GetParameters())); if (member != null && (doc = member.GetXmlDoc().GetSummary()) != null) { - baseType = member; + baseMember = member; return doc; } - if (t.TypeKind != TypeKind.Interface && (doc = GetBaseTypeDocumentation(t, querySymbol, out baseType)) != null) { + if (t.TypeKind != TypeKind.Interface && (doc = InheritDocumentation(t, querySymbol, out baseMember)) != null) { return doc; } - else if (symbol.Kind != SymbolKind.NamedType - && symbol == querySymbol + else if (symbol == querySymbol + && symbol.Kind != SymbolKind.NamedType && (t = symbol.ContainingType) != null) { foreach (var item in t.Interfaces) { - if ((doc = GetBaseTypeDocumentation(item, querySymbol, out baseType)) != null) { + if ((doc = InheritDocumentation(item, querySymbol, out baseMember)) != null) { return doc; } } + switch (symbol.Kind) { + case SymbolKind.Method: + foreach (var item in (symbol as IMethodSymbol).ExplicitInterfaceImplementations) { + if ((doc = item.GetXmlDoc().GetSummary()) != null) { + baseMember = item; + return doc; + } + } + break; + case SymbolKind.Property: + foreach (var item in (symbol as IPropertySymbol).ExplicitInterfaceImplementations) { + if ((doc = item.GetXmlDoc().GetSummary()) != null) { + baseMember = item; + return doc; + } + } + break; + case SymbolKind.Event: + foreach (var item in (symbol as IEventSymbol).ExplicitInterfaceImplementations) { + if ((doc = item.GetXmlDoc().GetSummary()) != null) { + baseMember = item; + return doc; + } + } + break; + } } - baseType = null; + baseMember = null; return null; } diff --git a/Codist/Properties/AssemblyInfo.cs b/Codist/Properties/AssemblyInfo.cs index f7c0bea4..b9098247 100644 --- a/Codist/Properties/AssemblyInfo.cs +++ b/Codist/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.7.0.0")] -[assembly: AssemblyFileVersion("2.7.0.989")] +[assembly: AssemblyVersion("2.8.0.0")] +[assembly: AssemblyFileVersion("2.8.0.1003")] diff --git a/Codist/QuickInfo/CSharpQuickInfoSourceProvider.cs b/Codist/QuickInfo/CSharpQuickInfoSourceProvider.cs index acf0cc63..5302e22c 100644 --- a/Codist/QuickInfo/CSharpQuickInfoSourceProvider.cs +++ b/Codist/QuickInfo/CSharpQuickInfoSourceProvider.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Windows; using System.Windows.Controls; -using System.Windows.Media; using System.Xml.Linq; using AppHelpers; using Microsoft.CodeAnalysis; @@ -90,12 +89,10 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiC var unitCompilation = semanticModel.SyntaxTree.GetCompilationUnitRoot(); //look for occurrences of our QuickInfo words in the span - var navigator = _NavigatorService.GetTextStructureNavigator(_TextBuffer); var node = unitCompilation.FindNode(new TextSpan(querySpan.Start, querySpan.Length), true, true); if (node == null || node.Span.Contains(subjectTriggerPoint.Position) == false) { goto EXIT; } - var extent = navigator.GetExtentOfWord(querySpan.Start).Span; if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.Parameter)) { ShowParameterInfo(qiContent, node); } @@ -142,6 +139,8 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiC w.ApplyClickAndGo(symbol); } QuickInfoOverrider.LimitQuickInfoItemSize(qiContent, w); + var navigator = _NavigatorService.GetTextStructureNavigator(_TextBuffer); + var extent = navigator.GetExtentOfWord(querySpan.Start).Span; applicableToSpan = qiContent.Count > 0 && session.TextView.TextSnapshot == currentSnapshot ? currentSnapshot.CreateTrackingSpan(extent.Start, extent.Length, SpanTrackingMode.EdgeInclusive) : null; @@ -163,7 +162,7 @@ void OverrideDocumentation(SyntaxNode node, DefaultQuickInfoPanelWrapper qiWrapp } else if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.DocumentationFromBaseType)) { ISymbol baseMember; - var baseDocs = symbol.GetBaseTypeDocumentation(out baseMember); + var baseDocs = symbol.InheritDocumentation(out baseMember); if (baseDocs != null) { var info = new TextBlock { TextWrapping = TextWrapping.Wrap } .AddText("Documentation from ") diff --git a/Codist/source.extension.vsixmanifest b/Codist/source.extension.vsixmanifest index 4c520ac7..70c863e8 100644 --- a/Codist/source.extension.vsixmanifest +++ b/Codist/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Codist A plugin which enhances coding experience with advanced syntax highlighting, scrollbar marking and Super Quick Info for C# programmers. https://github.com/wmjordan/Codist