From 8107eb50a2735303376270f367311c1e22850ef4 Mon Sep 17 00:00:00 2001 From: WMJ Date: Fri, 17 Mar 2023 14:27:02 +0800 Subject: [PATCH] Version 7.2 --- Codist/Config.cs | 2 +- Codist/Constants.cs | 8 +++----- Codist/Helpers/CodeAnalysisHelper.cs | 23 +++++++++++++++++++++++ Codist/Helpers/TextEditorHelper.cs | 6 +++--- Codist/Properties/AssemblyInfo.cs | 4 ++-- Codist/Taggers/TaggerFactories.cs | 4 +++- Codist/source.extension.vsixmanifest | 4 ++-- README.md | 12 ++++++------ 8 files changed, 43 insertions(+), 20 deletions(-) diff --git a/Codist/Config.cs b/Codist/Config.cs index 5c08413a..bb67e9bd 100644 --- a/Codist/Config.cs +++ b/Codist/Config.cs @@ -15,7 +15,7 @@ namespace Codist { sealed class Config { - internal const string CurrentVersion = "7.1.0"; + internal const string CurrentVersion = "7.2.0"; const string ThemePrefix = "res:"; const int DefaultIconSize = 20; internal const string LightTheme = ThemePrefix + "Light", diff --git a/Codist/Constants.cs b/Codist/Constants.cs index 7a5298c7..0184c5cb 100644 --- a/Codist/Constants.cs +++ b/Codist/Constants.cs @@ -102,7 +102,6 @@ public static class EditorProperties public const string CodeSymbolReference = PredefinedClassificationTypeNames.SymbolReference; public const string CodeUrl = "url"; public const string CodeFormalLanguage = PredefinedClassificationTypeNames.FormalLanguage; - #region Format names introduced in VS 2019 public const string CodeOverloadedOperator = "operator - overloaded"; public const string CodeStringEscapeCharacter = "string - escape character"; public const string CodeKeywordControl = "keyword - control"; @@ -120,7 +119,6 @@ public static class EditorProperties public const string CodeStaticSymbol = "static symbol"; public const string CodeLabelName = "label name"; public const string CodeNavigableSymbol = "navigableSymbol"; - #endregion public const string XmlDocAttributeName = "xml doc comment - attribute name"; public const string XmlDocAttributeQuotes = "xml doc comment - attribute quotes"; @@ -131,9 +129,9 @@ public static class EditorProperties public const string XmlDocEntity = "xml doc comment - entity reference"; public const string XmlDocTag = "xml doc comment - name"; - public const string MarkupAttribute = "markup attribute"; - public const string MarkupAttributeValue = "markup attribute value"; - public const string MarkupNode = "markup node"; + public const string MarkupAttribute = PredefinedClassificationTypeNames.MarkupAttribute; + public const string MarkupAttributeValue = PredefinedClassificationTypeNames.MarkupAttributeValue; + public const string MarkupNode = PredefinedClassificationTypeNames.MarkupNode; public const string CSharpLocalVariableName = "C#: Local variable"; public const string CSharpParameterName = "C#: Parameter"; diff --git a/Codist/Helpers/CodeAnalysisHelper.cs b/Codist/Helpers/CodeAnalysisHelper.cs index aabf511b..64fa5651 100644 --- a/Codist/Helpers/CodeAnalysisHelper.cs +++ b/Codist/Helpers/CodeAnalysisHelper.cs @@ -346,11 +346,17 @@ public static bool IsTopmostIf(this IfStatementSyntax ifs) { return ifs?.Parent.IsKind(SyntaxKind.ElseClause) != true; } + /// + /// Returns whether a spans multiple lines. + /// public static bool IsMultiLine(this SyntaxNode node, bool includeTrivia) { var lines = node.SyntaxTree.GetText().Lines; var span = includeTrivia ? node.FullSpan : node.Span; return lines.GetLineFromPosition(span.Start).SpanIncludingLineBreak.Contains(span.End) == false; } + /// + /// Returns whether a spans multiple lines. + /// public static bool IsMultiline(this SyntaxTriviaList triviaList) { foreach (var item in triviaList) { if (item.IsKind(SyntaxKind.EndOfLineTrivia)) { @@ -368,6 +374,23 @@ public static bool IsAssignedToSameTarget(this StatementSyntax statement, Statem && a.OperatorToken.IsKind(ea.OperatorToken.Kind()) && SyntaxFactory.AreEquivalent(a.Left, ea.Left); } + + public static SyntaxTriviaList GetNonDirectiveLeadingTrivia(this SyntaxNode node) { + return node.HasLeadingTrivia == false + ? default + : node.GetLeadingTrivia().GetNonDirectiveTrivia(); + } + + public static SyntaxTriviaList GetNonDirectiveTrivia(this SyntaxTriviaList list) { + int i; + for (i = list.Count - 1; i >= 0; i--) { + if (list[i].IsDirective == false) { + continue; + } + break; + } + return i == 0 ? list : new SyntaxTriviaList(list.Skip(i)); + } #endregion #region Node icon diff --git a/Codist/Helpers/TextEditorHelper.cs b/Codist/Helpers/TextEditorHelper.cs index 71bfc206..85a31907 100644 --- a/Codist/Helpers/TextEditorHelper.cs +++ b/Codist/Helpers/TextEditorHelper.cs @@ -962,12 +962,12 @@ public static void CopySelectionWithoutIndentation(this ITextView view) { ) { goto BUILTIN_COPY; } - var selection = view.FirstSelectionSpan(); - ITextSnapshot snapshot = view.TextBuffer.CurrentSnapshot; - ITextSnapshotLine startLine, endLine; + var snapshot = view.TextBuffer.CurrentSnapshot; + var selection = view.FirstSelectionSpan(); var startOfSelection = selection.Start.Position; var endOfSelection = selection.End.Position; + ITextSnapshotLine startLine, endLine; if (((startLine = snapshot.GetLineFromPosition(startOfSelection)) == null) || (endLine = snapshot.GetLineFromPosition(endOfSelection)) == startLine) { goto BUILTIN_COPY; diff --git a/Codist/Properties/AssemblyInfo.cs b/Codist/Properties/AssemblyInfo.cs index 91982375..28aebb24 100644 --- a/Codist/Properties/AssemblyInfo.cs +++ b/Codist/Properties/AssemblyInfo.cs @@ -10,6 +10,6 @@ [assembly: AssemblyCopyright("Copyright WMJ, 2023")] [assembly: AssemblyTrademark(nameof(Codist))] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("7.1.0.0")] -[assembly: AssemblyFileVersion(Codist.Config.CurrentVersion + ".8100")] +[assembly: AssemblyVersion("7.2.0.0")] +[assembly: AssemblyFileVersion(Codist.Config.CurrentVersion + ".8300")] [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] \ No newline at end of file diff --git a/Codist/Taggers/TaggerFactories.cs b/Codist/Taggers/TaggerFactories.cs index a223c9c7..a94c5807 100644 --- a/Codist/Taggers/TaggerFactories.cs +++ b/Codist/Taggers/TaggerFactories.cs @@ -71,14 +71,16 @@ public ITagger CreateTagger(ITextBuffer buffer) where T : ITag { [TagType(typeof(IClassificationTag))] sealed class CSharpTaggerProvider : IViewTaggerProvider { - readonly Dictionary _Taggers = new Dictionary(); static readonly string[] __TaggableRoles = new[] { PredefinedTextViewRoles.Document, PredefinedTextViewRoles.EmbeddedPeekTextView }; + readonly Dictionary _Taggers = new Dictionary(); + // note: cache the latest used tagger to improve performance // In C# code editor, even displaying the Quick Info will call the CreateTagger method, // thus we cache the last accessed tagger, identified by ITextView and ITextBuffer, // in CSharpTaggerProvider and CSharpTagger respectively, to avoid dictionary lookup CSharpTagger _LastTagger; + // for debug info int _taggerCount; diff --git a/Codist/source.extension.vsixmanifest b/Codist/source.extension.vsixmanifest index 64c7edd8..b7a24644 100644 --- a/Codist/source.extension.vsixmanifest +++ b/Codist/source.extension.vsixmanifest @@ -1,9 +1,9 @@  - + Codist - A C# programmer's productivity booster which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality, automatically updated version numbers, and brings smart tool bar to code editor. + A C# programmer's productivity booster which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality, automatically updated version numbers, and brings smart tool bar with advanced editing commands, code analasis and refactoring to code editor. https://github.com/wmjordan/Codist license.txt https://github.com/wmjordan/Codist/releases diff --git a/README.md b/README.md index 1f25b86c..9f411a53 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,15 @@ Here's a brief but not complete demonstration of *Codist*'s enhancement to Visua Check out this list to see what _Codist_ can do for you. * [Advanced Syntax Highlight](#advanced-c-syntax-highlight) ANY LANGUAGES, and [*Comment Tagger*](#comment-tagger-and-styles) highlights `to-do` style comments - ![](doc/feature-brief-syntax-highlight.png) + ![](doc/feature-brief-syntax-highlight.png) * [Super Quick Info](#super-quick-info) with extended XML Doc, symbol tool-tips, selectable contents, appearance customization, etc. - ![Feature Brief Super Quick Info](doc/feature-brief-super-quick-info.png) + ![Feature Brief Super Quick Info](doc/feature-brief-super-quick-info.png) * [Navigation Bar](#navigation-bar) with a drag-and-drop and filter enabled member list - ![Feature Brief Navigation Bar](doc/feature-brief-navigation-bar.png) + ![Feature Brief Navigation Bar](doc/feature-brief-navigation-bar.png) * [Smart Bar](#smart-bar) with common edit commands, C# code refactoring and symbol reference analyzers - ![Feature Brief Smart Bar](doc/feature-brief-smart-bar.png) + ![Feature Brief Smart Bar](doc/feature-brief-smart-bar.png) * [Scrollbar Marker](#scrollbar-marker) draws a powerful mini code map - ![Feature Brief Scrollbar Marker](doc/feature-brief-scrollbar-marker.png) + ![Feature Brief Scrollbar Marker](doc/feature-brief-scrollbar-marker.png) * [Auto Changing Version Numbers](#auto-changing-version-numbers) * [Display Enhancements](#display-enhancements) * [Jump List Shortcuts](#jump-list-shortcuts) @@ -555,7 +555,7 @@ I have learned a lot from the following extension projects (sorted by the time w * ReviewBoard: code.google.com/p/reviewboardvsx * [Tweaks](https://github.com/madskristensen/Tweakster): VS tweaks * [VsStatus](https://github.com/madskristensen/VsStatus): hacking the status bar -* [Roslynator](https://github.com/JosefPihrt/Roslynator): hundreds of code refactorings and analyses +* [Roslynator](https://github.com/JosefPihrt/Roslynator): hundreds of code refactorings and analyzers * [ShowTheShortcut](https://github.com/madskristensen/ShowTheShortcut): discovering identifiers of executed commands * [Copy Nice](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.CopyNice): copying text without indentation