From f280c2c38d7c22291d8526018df542ea2e988ebd Mon Sep 17 00:00:00 2001 From: WMJ Date: Thu, 1 Feb 2018 08:42:47 +0800 Subject: [PATCH] + Added reset style button in syntax style option page + Shows property declaration in quick info --- Codist/Config.cs | 11 +- .../Options/SyntaxStyleOptionPage.Designer.cs | 14 ++ Codist/Options/SyntaxStyleOptionPage.cs | 192 ++++++++++-------- Codist/Properties/AssemblyInfo.cs | 2 +- Codist/Views/CSharpTooltip.cs | 161 +++++++++------ Codist/source.extension.vsixmanifest | 2 +- 6 files changed, 224 insertions(+), 158 deletions(-) diff --git a/Codist/Config.cs b/Codist/Config.cs index 8b68daab..4118bbfd 100644 --- a/Codist/Config.cs +++ b/Codist/Config.cs @@ -286,10 +286,17 @@ internal Color BackColor { set { _backColor = value; } } + public abstract string Category { get; } internal StyleBase Clone() { return (StyleBase)MemberwiseClone(); } - public abstract string Category { get; } + internal void Reset() { + Bold = Italic = OverLine = Underline = StrikeThrough = null; + FontSize = 0; + BackgroundEffect = BrushEffect.Solid; + Font = null; + _foreColor = _backColor = default(Color); + } } [DebuggerDisplay("{StyleID} {ForegroundColor} {FontSize}")] @@ -371,7 +378,7 @@ public override string Category { if (f == null) { return _Category = String.Empty; } - var c = f.GetCustomAttribute(false); + var c = f.GetCustomAttribute(false); if (c == null) { return _Category = String.Empty; } diff --git a/Codist/Options/SyntaxStyleOptionPage.Designer.cs b/Codist/Options/SyntaxStyleOptionPage.Designer.cs index a9f8116f..dd94ca9c 100644 --- a/Codist/Options/SyntaxStyleOptionPage.Designer.cs +++ b/Codist/Options/SyntaxStyleOptionPage.Designer.cs @@ -28,6 +28,7 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SyntaxStyleOptionPage)); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this._ResetButton = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this._BackgroundEffectBox = new System.Windows.Forms.ComboBox(); this._FontBox = new System.Windows.Forms.ComboBox(); @@ -71,6 +72,7 @@ private void InitializeComponent() { this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this._ResetButton); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this._BackgroundEffectBox); this.groupBox1.Controls.Add(this._FontBox); @@ -97,6 +99,17 @@ private void InitializeComponent() { this.groupBox1.TabStop = false; this.groupBox1.Text = "Syntax style"; // + // _ResetButton + // + this._ResetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this._ResetButton.Location = new System.Drawing.Point(177, 0); + this._ResetButton.Name = "_ResetButton"; + this._ResetButton.Size = new System.Drawing.Size(75, 23); + this._ResetButton.TabIndex = 20; + this._ResetButton.Text = "Reset"; + this._ResetButton.UseVisualStyleBackColor = true; + this._ResetButton.Click += new System.EventHandler(this.ResetButton_Click); + // // label2 // this.label2.AutoSize = true; @@ -372,5 +385,6 @@ private void InitializeComponent() { private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox _BackgroundEffectBox; + private System.Windows.Forms.Button _ResetButton; } } diff --git a/Codist/Options/SyntaxStyleOptionPage.cs b/Codist/Options/SyntaxStyleOptionPage.cs index 61e960a1..039e54d9 100644 --- a/Codist/Options/SyntaxStyleOptionPage.cs +++ b/Codist/Options/SyntaxStyleOptionPage.cs @@ -13,13 +13,12 @@ namespace Codist.Options [Browsable(false)] public partial class SyntaxStyleOptionPage : UserControl { + readonly Func> _defaultStyleLoader; readonly ConfigPage _service; readonly Func> _styleLoader; - readonly Func> _defaultStyleLoader; StyleBase _activeStyle; - bool _uiLock; bool _loaded; - + bool _uiLock; public SyntaxStyleOptionPage() { InitializeComponent(); _BackgroundEffectBox.Items.AddRange(new[] { "Solid", "Paint bottom", "Paint top", "Paint right", "Paint left" }); @@ -71,6 +70,92 @@ protected override void OnLoad(EventArgs e) { _loaded = true; } + static void RenderPreview(Bitmap bmp, FontInfo fs, StyleBase style) { + var fontSize = (float)(fs.wPointSize + style.FontSize); + if (fontSize < 2) { + return; + } + using (var g = Graphics.FromImage(bmp)) + using (var f = new Font(String.IsNullOrEmpty(style.Font) ? fs.bstrFaceName : style.Font, fontSize, ConfigPage.GetFontStyle(style))) + using (var b = style.ForeColor.A == 0 ? (Brush)Brushes.Black.Clone() : new SolidBrush(style.ForeColor.ToGdiColor())) { + const string t = "Preview 01ioIOlLWM"; + var m = g.MeasureString(t, f, bmp.Size); + g.SmoothingMode = SmoothingMode.HighQuality; + g.TextRenderingHint = TextRenderingHint.AntiAlias; + g.CompositingQuality = CompositingQuality.HighQuality; + using (var bb = ConfigPage.GetPreviewBrush(style.BackgroundEffect, style.BackColor, ref m)) { + g.FillRectangle(bb, new Rectangle(0, 0, (int)m.Width, (int)m.Height)); + } + g.DrawString(t, f, b, new RectangleF(PointF.Empty, bmp.PhysicalDimension)); + } + } + + static bool? ToBool(CheckState state) { + switch (state) { + case CheckState.Unchecked: return false; + case CheckState.Checked: return true; + default: return null; + } + } + + static CheckState ToCheckState(bool? value) { + return value.HasValue == false + ? CheckState.Indeterminate + : value.Value + ? CheckState.Checked + : CheckState.Unchecked; + } + + static Color ToColor(System.Windows.Media.Color color) { + return Color.FromArgb(255, color.R, color.G, color.B); + } + + void _SyntaxListBox_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { + if (e.ItemIndex == -1) { + return; + } + var i = e.Item.Tag as StyleBase; + if (i == null) { + return; + } + _uiLock = true; + _activeStyle = i; + UpdateUIControls(i); + + UpdatePreview(); + _uiLock = false; + } + + void UpdateUIControls(StyleBase style) { + _BoldBox.CheckState = ToCheckState(style.Bold); + _ItalicBox.CheckState = ToCheckState(style.Italic); + _StrikeBox.CheckState = ToCheckState(style.StrikeThrough); + _UnderlineBox.CheckState = ToCheckState(style.Underline); + _BackgroundEffectBox.SelectedIndex = (int)style.BackgroundEffect; + + _FontBox.Text = style.Font; + _FontSizeBox.Value = style.FontSize > 100 ? 100m : style.FontSize < -10 ? -10m : (decimal)style.FontSize; + _ForeColorTransBox.Value = style.ForeColor.A; + _BackColorTransBox.Value = style.BackColor.A; + _ForeColorButton.SelectedColor = ToColor(style.ForeColor); + _BackColorButton.SelectedColor = ToColor(style.BackColor); + } + + private ListViewItem GetListItemForStyle(string category, ListViewItem vi) { + vi.Text = category; + vi.IndentCount = 1; + switch (category) { + case Constants.SyntaxCategory.Comment: vi.BackColor = Color.LightGreen; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.CompilerMarked: vi.BackColor = Color.LightGray; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.Declaration: vi.BackColor = Color.LightCyan; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.Keyword: vi.BackColor = Color.LightBlue; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.Preprocessor: vi.BackColor = Color.Gray; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.Member: vi.BackColor = Color.LightCoral; vi.ForeColor = Color.Black; break; + case Constants.SyntaxCategory.TypeDefinition: vi.BackColor = Color.LightYellow; vi.ForeColor = Color.Black; break; + } + return vi; + } + void LoadStyleList() { _uiLock = true; _SyntaxListBox.Items.Clear(); @@ -96,22 +181,6 @@ void LoadStyleList() { } _uiLock = false; } - - private ListViewItem GetListItemForStyle(string category, ListViewItem vi) { - vi.Text = category; - vi.IndentCount = 1; - switch (category) { - case Constants.SyntaxCategory.Comment: vi.BackColor = Color.LightGreen; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.CompilerMarked: vi.BackColor = Color.LightGray; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.Declaration: vi.BackColor = Color.LightCyan; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.Keyword: vi.BackColor = Color.LightBlue; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.Preprocessor: vi.BackColor = Color.Gray; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.Member: vi.BackColor = Color.LightCoral; vi.ForeColor = Color.Black; break; - case Constants.SyntaxCategory.TypeDefinition: vi.BackColor = Color.LightYellow; vi.ForeColor = Color.Black; break; - } - return vi; - } - void MarkChanged(object sender, EventArgs args) { if (_uiLock || _activeStyle == null) { return; @@ -120,14 +189,16 @@ void MarkChanged(object sender, EventArgs args) { Config.Instance.FireConfigChangedEvent(); } - private void SetForeColor(object sender, EventArgs args) { - if (_uiLock || _activeStyle == null) { + void ResetButton_Click(object sender, EventArgs e) { + if (_activeStyle == null) { return; } - if (sender == _ForeColorButton && _ForeColorTransBox.Value == 0) { - _ForeColorTransBox.Value = 255; - } - _activeStyle.ForeColor = _ForeColorButton.SelectedColor.ChangeTrasparency((byte)_ForeColorTransBox.Value).ToWpfColor(); + _uiLock = true; + _activeStyle.Reset(); + UpdateUIControls(_activeStyle); + UpdatePreview(); + Config.Instance.FireConfigChangedEvent(); + _uiLock = false; } private void SetBackColor(object sender, EventArgs args) { @@ -140,37 +211,15 @@ private void SetBackColor(object sender, EventArgs args) { _activeStyle.BackColor = _BackColorButton.SelectedColor.ChangeTrasparency((byte)_BackColorTransBox.Value).ToWpfColor(); } - void _SyntaxListBox_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { - if (e.ItemIndex == -1) { + private void SetForeColor(object sender, EventArgs args) { + if (_uiLock || _activeStyle == null) { return; } - var i = e.Item.Tag as StyleBase; - if (i == null) { - return; + if (sender == _ForeColorButton && _ForeColorTransBox.Value == 0) { + _ForeColorTransBox.Value = 255; } - _uiLock = true; - _activeStyle = i; - _BoldBox.CheckState = ToCheckState(i.Bold); - _ItalicBox.CheckState = ToCheckState(i.Italic); - _StrikeBox.CheckState = ToCheckState(i.StrikeThrough); - _UnderlineBox.CheckState = ToCheckState(i.Underline); - _BackgroundEffectBox.SelectedIndex = (int)i.BackgroundEffect; - - _FontBox.Text = i.Font; - _FontSizeBox.Value = i.FontSize > 100 ? 100m : i.FontSize < -10 ? -10m : (decimal)i.FontSize; - _ForeColorTransBox.Value = i.ForeColor.A; - _BackColorTransBox.Value = i.BackColor.A; - _ForeColorButton.SelectedColor = ToColor(i.ForeColor); - _BackColorButton.SelectedColor = ToColor(i.BackColor); - - UpdatePreview(); - _uiLock = false; - } - - static Color ToColor(System.Windows.Media.Color color) { - return Color.FromArgb(255, color.R, color.G, color.B); + _activeStyle.ForeColor = _ForeColorButton.SelectedColor.ChangeTrasparency((byte)_ForeColorTransBox.Value).ToWpfColor(); } - void UpdatePreview() { if (_activeStyle == null) { return; @@ -181,47 +230,10 @@ void UpdatePreview() { RenderPreview(bmp, fs, style); _PreviewBox.Image = bmp; } - - static void RenderPreview(Bitmap bmp, FontInfo fs, StyleBase style) { - var fontSize = (float)(fs.wPointSize + style.FontSize); - if (fontSize < 2) { - return; - } - using (var g = Graphics.FromImage(bmp)) - using (var f = new Font(String.IsNullOrEmpty(style.Font) ? fs.bstrFaceName : style.Font, fontSize, ConfigPage.GetFontStyle(style))) - using (var b = style.ForeColor.A == 0 ? (Brush)Brushes.Black.Clone() : new SolidBrush(style.ForeColor.ToGdiColor())) { - const string t = "Preview 01ioIOlLWM"; - var m = g.MeasureString(t, f, bmp.Size); - g.SmoothingMode = SmoothingMode.HighQuality; - g.TextRenderingHint = TextRenderingHint.AntiAlias; - g.CompositingQuality = CompositingQuality.HighQuality; - using (var bb = ConfigPage.GetPreviewBrush(style.BackgroundEffect, style.BackColor, ref m)) { - g.FillRectangle(bb, new Rectangle(0, 0, (int)m.Width, (int)m.Height)); - } - g.DrawString(t, f, b, new RectangleF(PointF.Empty, bmp.PhysicalDimension)); - } - } - - static CheckState ToCheckState(bool? value) { - return value.HasValue == false - ? CheckState.Indeterminate - : value.Value - ? CheckState.Checked - : CheckState.Unchecked; - } - static bool? ToBool(CheckState state) { - switch (state) { - case CheckState.Unchecked: return false; - case CheckState.Checked: return true; - default: return null; - } - } - struct FontFamilyItem { - internal readonly string Name; internal readonly FontFamily FontFamily; - + internal readonly string Name; public FontFamilyItem(FontFamily fontFamily) { Name = fontFamily.GetName(0); FontFamily = fontFamily; diff --git a/Codist/Properties/AssemblyInfo.cs b/Codist/Properties/AssemblyInfo.cs index bd89cfa1..aae5a2b8 100644 --- a/Codist/Properties/AssemblyInfo.cs +++ b/Codist/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("2.4.1.401")] +[assembly: AssemblyFileVersion("2.4.1.406")] diff --git a/Codist/Views/CSharpTooltip.cs b/Codist/Views/CSharpTooltip.cs index 12deb4c8..de02bc20 100644 --- a/Codist/Views/CSharpTooltip.cs +++ b/Codist/Views/CSharpTooltip.cs @@ -36,7 +36,8 @@ public CSharpQuickInfoSource(CSharpQuickInfoSourceProvider provider, ITextBuffer _QuickInfoSourceProvider = provider; _TextBuffer = subjectBuffer; _FormatMapService = formatMapService; - _TextBuffer.Changing += _TextBuffer_Changing; + _TextBuffer.Changing += TextBuffer_Changing; + Config.ConfigUpdated += _ConfigUpdated; } public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiContent, out ITrackingSpan applicableToSpan) { @@ -130,7 +131,7 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiC if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.Declaration) && (method.IsAbstract || method.IsStatic || method.IsVirtual || method.IsOverride || method.IsExtern) && method.ContainingType.TypeKind != TypeKind.Interface) { - ShowMethodDeclaration(qiContent, method); + ShowMethodDeclaration(qiContent, method, node.SpanStart); } if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.ExtensionMethod) && method.IsExtensionMethod) { ShowExtensionMethod(qiContent, method, node.SpanStart); @@ -159,6 +160,14 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiC } } } + goto RETURN; + } + var property = symbol as IPropertySymbol; + if (property != null) { + if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.Declaration) + && (property.IsAbstract || property.IsStatic || property.IsOverride || property.IsVirtual)) { + ShowPropertyDeclaration(qiContent, property, node.SpanStart); + } } RETURN: applicableToSpan = currentSnapshot.CreateTrackingSpan(extent.Span.Start, extent.Span.Length, SpanTrackingMode.EdgeInclusive); @@ -167,65 +176,10 @@ public void AugmentQuickInfoSession(IQuickInfoSession session, IList qiC applicableToSpan = null; } - static void ShowFieldDeclaration(IList qiContent, IFieldSymbol field) { - var info = new StackPanel().MakeHorizontal().AddText("Field declaration: ", true); - if (field.IsVolatile) { - info.AddText("volatile ", _KeywordBrush); - } - if (field.IsStatic) { - info.AddText("static ", _KeywordBrush); - } - if (field.IsReadOnly) { - info.AddText("readonly ", _KeywordBrush); - } - qiContent.Add(info); - } - - static void ShowClassDeclaration(IList qiContent, INamedTypeSymbol typeSymbol) { - var info = new StackPanel().MakeHorizontal().AddText("Class declaration: ", true); - if (typeSymbol.IsAbstract) { - info.AddText("abstract ", _KeywordBrush); - } - else if (typeSymbol.IsStatic) { - info.AddText("static ", _KeywordBrush); - } - else if (typeSymbol.IsSealed) { - info.AddText("sealed ", _KeywordBrush); - } - qiContent.Add(info); - } - - static void ShowMethodDeclaration(IList qiContent, IMethodSymbol method) { - var info = new StackPanel().MakeHorizontal().AddText("Method declaration: ", true); - if (method.IsAbstract) { - info.AddText("abstract ", _KeywordBrush); - } - if (method.IsStatic) { - info.AddText("static ", _KeywordBrush); - } - else if (method.IsVirtual) { - info.AddText("virtual ", _KeywordBrush); - } - else if (method.IsOverride) { - info.AddText("override ", _KeywordBrush); - } - if (method.IsExtern) { - info.AddText("extern ", _KeywordBrush); - } - qiContent.Add(info); - } - - private static StackPanel ShowStringInfo(string sv) { - return new StackPanel() - .Add(new StackPanel().MakeHorizontal().AddReadOnlyTextBox(sv.Length.ToString()).AddText("chars", true)) - //.Add(new StackPanel().MakeHorizontal().AddReadOnlyNumericTextBox(System.Text.Encoding.UTF8.GetByteCount(sv).ToString()).AddText("UTF-8 bytes", true)) - //.Add(new StackPanel().MakeHorizontal().AddReadOnlyNumericTextBox(System.Text.Encoding.Default.GetByteCount(sv).ToString()).AddText("System bytes", true)) - .Add(new StackPanel().MakeHorizontal().AddReadOnlyTextBox(sv.GetHashCode().ToString()).AddText("Hash code", true)); - } - void IDisposable.Dispose() { if (!_IsDisposed) { - _TextBuffer.Changing -= _TextBuffer_Changing; + _TextBuffer.Changing -= TextBuffer_Changing; + Config.ConfigUpdated -= _ConfigUpdated; ; GC.SuppressFinalize(this); _IsDisposed = true; } @@ -256,6 +210,20 @@ static bool IsCommonClassName(string name) { return name == "Object" || name == "ValueType" || name == "Enum" || name == "MulticastDelegate"; } + static void ShowClassDeclaration(IList qiContent, INamedTypeSymbol typeSymbol) { + var info = new StackPanel().MakeHorizontal().AddText("Class declaration: ", true); + if (typeSymbol.IsAbstract) { + info.AddText("abstract ", _KeywordBrush); + } + else if (typeSymbol.IsStatic) { + info.AddText("static ", _KeywordBrush); + } + else if (typeSymbol.IsSealed) { + info.AddText("sealed ", _KeywordBrush); + } + qiContent.Add(info); + } + static void ShowExtensionMethod(IList qiContent, IMethodSymbol method, int position) { var info = ToUIText(method.ContainingType.ToDisplayParts(), "Defined in: ", true); string asmName = method.ContainingAssembly?.Modules?.FirstOrDefault()?.Name @@ -266,6 +234,41 @@ static void ShowExtensionMethod(IList qiContent, IMethodSymbol method, i qiContent.Add(info); } + static void ShowFieldDeclaration(IList qiContent, IFieldSymbol field) { + var info = new StackPanel().MakeHorizontal().AddText("Field declaration: ", true); + if (field.IsVolatile) { + info.AddText("volatile ", _KeywordBrush); + } + if (field.IsStatic) { + info.AddText("static ", _KeywordBrush); + } + if (field.IsReadOnly) { + info.AddText("readonly ", _KeywordBrush); + } + qiContent.Add(info); + } + + void ShowMethodDeclaration(IList qiContent, IMethodSymbol method, int position) { + var info = new StackPanel().MakeHorizontal().AddText("Method declaration: ", true); + if (method.IsAbstract) { + info.AddText("abstract ", _KeywordBrush); + } + if (method.IsStatic) { + info.AddText("static ", _KeywordBrush); + } + else if (method.IsVirtual) { + info.AddText("virtual ", _KeywordBrush); + } + else if (method.IsOverride) { + info.AddText("override ", _KeywordBrush) + .Add(ToUIText(method.OverriddenMethod.ContainingType.ToMinimalDisplayParts(_SemanticModel, position))); + } + if (method.IsExtern) { + info.AddText("extern ", _KeywordBrush); + } + qiContent.Add(info); + } + static StackPanel ShowNumericForm(SyntaxNode node) { return ShowNumericForms(node.GetFirstToken().Value, node.Parent.Kind() == SyntaxKind.UnaryMinusExpression ? NumericForm.Negative : NumericForm.None); } @@ -313,6 +316,32 @@ static StackPanel ShowNumericForms(object value, NumericForm form) { return null; } + void ShowPropertyDeclaration(IList qiContent, IPropertySymbol property, int position) { + var info = new StackPanel().MakeHorizontal().AddText("Property declaration: ", true); + if (property.IsAbstract) { + info.AddText("abstract ", _KeywordBrush); + } + else if (property.IsStatic) { + info.AddText("static ", _KeywordBrush); + } + else if (property.IsOverride) { + info.AddText("override ", _KeywordBrush) + .Add(ToUIText(property.OverriddenProperty.ContainingType.ToMinimalDisplayParts(_SemanticModel, position))); + } + else if (property.IsVirtual) { + info.AddText("virtual ", _KeywordBrush); + } + qiContent.Add(info); + } + + private static StackPanel ShowStringInfo(string sv) { + return new StackPanel() + .Add(new StackPanel().MakeHorizontal().AddReadOnlyTextBox(sv.Length.ToString()).AddText("chars", true)) + //.Add(new StackPanel().MakeHorizontal().AddReadOnlyNumericTextBox(System.Text.Encoding.UTF8.GetByteCount(sv).ToString()).AddText("UTF-8 bytes", true)) + //.Add(new StackPanel().MakeHorizontal().AddReadOnlyNumericTextBox(System.Text.Encoding.Default.GetByteCount(sv).ToString()).AddText("System bytes", true)) + .Add(new StackPanel().MakeHorizontal().AddReadOnlyTextBox(sv.GetHashCode().ToString()).AddText("Hash code", true)); + } + static string ToBinString(byte[] bytes) { using (var sbr = ReusableStringBuilder.AcquireDefault((bytes.Length << 3) + bytes.Length)) { var sb = sbr.Resource; @@ -393,10 +422,9 @@ static void UpdateSyntaxHighlights(IEditorFormatMap formatMap) { _KeywordBrush = GetFormatBrush(Constants.CodeKeyword, formatMap); } - void _TextBuffer_Changing(object sender, TextContentChangingEventArgs e) { - _SemanticModel = null; + private void _ConfigUpdated(object sender, EventArgs e) { + UpdateSyntaxHighlights(_FormatMap); } - StackPanel ShowAttributes(ImmutableArray attrs, int position) { var stack = new StackPanel(); stack.AddText(attrs.Length > 1 ? "Attributes:" : "Attribute:", true); @@ -457,7 +485,7 @@ void ShowEnumInfo(IList qiContent, SyntaxNode node, INamedTypeSymbol typ } var c = 0; object min = null, max = null, bits = null; - ISymbol minName = null, maxName = null; + IFieldSymbol minName = null, maxName = null; var p = 0L; foreach (var m in type.GetMembers()) { var f = m as IFieldSymbol; @@ -504,6 +532,7 @@ void ShowEnumInfo(IList qiContent, SyntaxNode node, INamedTypeSymbol typ } } } + void ShowInterfaces(IList output, ITypeSymbol type, int position) { const string SystemDisposable = "IDisposable"; var showAll = Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.InterfacesInheritence); @@ -534,6 +563,10 @@ void ShowInterfaces(IList output, ITypeSymbol type, int position) { } output.Add(stack); } + + void TextBuffer_Changing(object sender, TextContentChangingEventArgs e) { + _SemanticModel = null; + } void ToUIText(StackPanel attrStack, TypedConstant v, int position) { switch (v.Kind) { case TypedConstantKind.Primitive: @@ -552,7 +585,7 @@ void ToUIText(StackPanel attrStack, TypedConstant v, int position) { var flags = items.ToArray(); for (int i = 0; i < flags.Length; i++) { if (i > 0) { - attrStack.AddText("| "); + attrStack.AddText(" | "); } attrStack.AddText(v.Type.Name + "." + flags[i].Name, _EnumBrush); } diff --git a/Codist/source.extension.vsixmanifest b/Codist/source.extension.vsixmanifest index bab0835d..e42dadef 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 and scrollbar marking.