From edcb94c4497c876a8cef00fe294327495b41322d Mon Sep 17 00:00:00 2001 From: WMJ Date: Sun, 15 Apr 2018 16:31:45 +0800 Subject: [PATCH] Version 2.7 1. Click and Go in Super Quick Info 2. Limit size of Quick Info items 3. Selection Quick Info for all text types 4. Unicode char Quick Info 5. Symbol location in Super Quick Info 6. Syntax highlight parameter parentheses 7. UNDONE comment style 8. Disabling Codist temporarily and more options 9. Many bug fixes --- Codist/Classifiers/ClassifierContext.cs | 71 ---------------------- Codist/Options/GeneralPage.Designer.cs | 19 +++++- Codist/Options/GeneralPage.cs | 2 + Codist/Properties/AssemblyInfo.cs | 4 +- Codist/Views/SelectionQuickInfoProvider.cs | 4 ++ Codist/source.extension.vsixmanifest | 2 +- 6 files changed, 25 insertions(+), 77 deletions(-) delete mode 100644 Codist/Classifiers/ClassifierContext.cs diff --git a/Codist/Classifiers/ClassifierContext.cs b/Codist/Classifiers/ClassifierContext.cs deleted file mode 100644 index c35c2ecd..00000000 --- a/Codist/Classifiers/ClassifierContext.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Classification; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Text.Classification; - -namespace Codist.Classifiers -{ - class ClassifierContext - { - private readonly ITextSnapshot _snapshot; - private readonly Workspace _workspace; - private readonly Document _document; - private readonly SemanticModel _semanticModel; - private readonly SyntaxNode _syntaxRoot; - - private static readonly IDictionary _cachedContexts = new Dictionary(); - private readonly IDictionary> _cachedClassifiedSpans = new Dictionary>(); - - public static ClassifierContext GetContext(ITextSnapshot snapshot) { - if (!_cachedContexts.ContainsKey(snapshot)) { - _cachedContexts[snapshot] = new ClassifierContext(snapshot); - } - - return _cachedContexts[snapshot]; - } - - private ClassifierContext(ITextSnapshot snapshot) { - _snapshot = snapshot; - _workspace = snapshot.TextBuffer.GetWorkspace(); - _document = snapshot.GetOpenDocumentInCurrentContextWithChanges(); - if (_document != null) { - _semanticModel = _document.GetSemanticModelAsync().Result; - _syntaxRoot = _document.GetSyntaxRootAsync().Result; - } - } - - public IEnumerable GetDefaultClassifiedSpans(SnapshotSpan span) { - if (_document == null) { - return Enumerable.Empty(); - } - - if (!_cachedClassifiedSpans.ContainsKey(span)) { - var textSpan = TextSpan.FromBounds(span.Start, span.End); - _cachedClassifiedSpans[span] = Classifier.GetClassifiedSpans(_semanticModel, textSpan, _workspace).ToList(); - } - - return _cachedClassifiedSpans[span]; - } - - public IEnumerable ClassifySpan(IEnumerable spans, IClassificationType classificationType) { - foreach (var span in spans) { - var k = _syntaxRoot.FindNode(span.TextSpan).Kind(); - - yield return new ClassificationSpan(new SnapshotSpan(_snapshot, new Span(span.TextSpan.Start, span.TextSpan.Length)), classificationType); - } - } - public IEnumerable ClassifyTokens(IEnumerable classifiedSpans, IClassificationType classificationType, params SyntaxKind[] syntaxKinds) { - var matchedTokens = classifiedSpans.Select(x => _syntaxRoot.FindToken(x.TextSpan.Start)).Where(x => syntaxKinds.Any(sk => x.IsKind(sk))); - return matchedTokens.Select(x => new ClassificationSpan(new SnapshotSpan(_snapshot, new Span(x.Span.Start, x.Span.Length)), classificationType)); - } - - } -} diff --git a/Codist/Options/GeneralPage.Designer.cs b/Codist/Options/GeneralPage.Designer.cs index 5ba9da1f..0f90032d 100644 --- a/Codist/Options/GeneralPage.Designer.cs +++ b/Codist/Options/GeneralPage.Designer.cs @@ -45,6 +45,7 @@ private void InitializeComponent() { this._LineNumbersBox = new System.Windows.Forms.CheckBox(); this._GlobalFeatureBox = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); + this._SelectionQuickInfoBox = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this._BottomMarginBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this._TopMarginBox)).BeginInit(); this.groupBox1.SuspendLayout(); @@ -94,7 +95,7 @@ private void InitializeComponent() { this.groupBox1.Controls.Add(this.label1); this.groupBox1.Location = new System.Drawing.Point(3, 153); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(407, 84); + this.groupBox1.Size = new System.Drawing.Size(546, 84); this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; this.groupBox1.Text = "Extra line margins"; @@ -134,7 +135,7 @@ private void InitializeComponent() { this.groupBox2.Controls.Add(this._LoadConfigButton); this.groupBox2.Location = new System.Drawing.Point(3, 81); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(407, 66); + this.groupBox2.Size = new System.Drawing.Size(546, 66); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "Super syntax highlight settings"; @@ -180,11 +181,12 @@ private void InitializeComponent() { // // groupBox3 // + this.groupBox3.Controls.Add(this._SelectionQuickInfoBox); this.groupBox3.Controls.Add(this._ControlQuickInfoBox); this.groupBox3.Controls.Add(this._LineNumbersBox); this.groupBox3.Location = new System.Drawing.Point(3, 243); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(407, 82); + this.groupBox3.Size = new System.Drawing.Size(546, 82); this.groupBox3.TabIndex = 4; this.groupBox3.TabStop = false; this.groupBox3.Text = "Misc"; @@ -228,6 +230,16 @@ private void InitializeComponent() { this.label3.TabIndex = 1; this.label3.Text = "(It takes effect on new document windows.\r\nYou can disable Codist to save power w" + "hen running with battery.)"; + // + // _SelectionQuickInfoBox + // + this._SelectionQuickInfoBox.AutoSize = true; + this._SelectionQuickInfoBox.Location = new System.Drawing.Point(348, 49); + this._SelectionQuickInfoBox.Name = "_SelectionQuickInfoBox"; + this._SelectionQuickInfoBox.Size = new System.Drawing.Size(189, 19); + this._SelectionQuickInfoBox.TabIndex = 2; + this._SelectionQuickInfoBox.Text = "Selection Quick Info"; + this._SelectionQuickInfoBox.UseVisualStyleBackColor = true; // // GeneralPage // @@ -275,5 +287,6 @@ private void InitializeComponent() { private System.Windows.Forms.CheckBox _ControlQuickInfoBox; private System.Windows.Forms.CheckBox _GlobalFeatureBox; private System.Windows.Forms.Label label3; + private System.Windows.Forms.CheckBox _SelectionQuickInfoBox; } } diff --git a/Codist/Options/GeneralPage.cs b/Codist/Options/GeneralPage.cs index 948d7c0b..e9cc32e3 100644 --- a/Codist/Options/GeneralPage.cs +++ b/Codist/Options/GeneralPage.cs @@ -39,6 +39,7 @@ private void MiscPage_Load(object sender, EventArgs e) { }); _LineNumbersBox.CheckedChanged += _UI.HandleEvent(() => Config.Instance.Set(MarkerOptions.LineNumber, _LineNumbersBox.Checked)); _ControlQuickInfoBox.CheckedChanged += _UI.HandleEvent(() => Config.Instance.Set(QuickInfoOptions.CtrlQuickInfo, _ControlQuickInfoBox.Checked)); + _SelectionQuickInfoBox.CheckedChanged += _UI.HandleEvent(() => Config.Instance.Set(QuickInfoOptions.Selection, _SelectionQuickInfoBox.Checked)); _SaveConfigButton.Click += (s, args) => { using (var d = new SaveFileDialog { Title = "Save Codist configuration file...", @@ -94,6 +95,7 @@ void LoadConfig(Config config) { _NoSpaceBetweenWrappedLinesBox.Checked = config.NoSpaceBetweenWrappedLines; _LineNumbersBox.Checked = config.MarkerOptions.MatchFlags(MarkerOptions.LineNumber); _ControlQuickInfoBox.Checked = config.QuickInfoOptions.MatchFlags(QuickInfoOptions.CtrlQuickInfo); + _SelectionQuickInfoBox.Checked = config.QuickInfoOptions.MatchFlags(QuickInfoOptions.Selection); }); } } diff --git a/Codist/Properties/AssemblyInfo.cs b/Codist/Properties/AssemblyInfo.cs index a8b8a42b..968753e2 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.6.0.0")] -[assembly: AssemblyFileVersion("2.6.0.838")] +[assembly: AssemblyVersion("2.7.0.0")] +[assembly: AssemblyFileVersion("2.7.0.870")] diff --git a/Codist/Views/SelectionQuickInfoProvider.cs b/Codist/Views/SelectionQuickInfoProvider.cs index e4b52a47..c75171ed 100644 --- a/Codist/Views/SelectionQuickInfoProvider.cs +++ b/Codist/Views/SelectionQuickInfoProvider.cs @@ -29,6 +29,10 @@ public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) { internal sealed class SelectionQuickInfoController : IQuickInfoSource { public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiContent, out ITrackingSpan applicableToSpan) { + if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.Selection) == false) { + applicableToSpan = null; + return; + } var textSnapshot = session.TextView.TextSnapshot; var triggerPoint = session.GetTriggerPoint(textSnapshot).GetValueOrDefault(); if (qiContent.FirstOrDefault(i => (i as TextBlock)?.Name == QuickInfoName) != null) { diff --git a/Codist/source.extension.vsixmanifest b/Codist/source.extension.vsixmanifest index 66dbb905..4dad7982 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.