From 28cdd633c045a4b86f5003e635369e014e55212c Mon Sep 17 00:00:00 2001 From: Dimitar Tsenev Date: Mon, 19 Aug 2024 13:41:05 +0300 Subject: [PATCH] [Updated] Resharper SDK to 2024.2.0 --- CHANGELOG.md | 3 + .../IdentifierTooltipContentProvider.cs | 5 +- .../TextStyleHighlighterManager.cs | 1 + .../GammaJul.ReSharper.EnhancedTooltip.csproj | 2 +- .../Presentation/CSharpColorizer.cs | 1442 ++++++++--------- .../RoslynDiagnosticHighlightingEnhancer.cs | 2 +- .../Presentation/ParamContent.cs | 5 +- .../Presentation/UIResources.xaml | 8 +- .../Properties/AssemblyInfo.cs | 4 +- .../VisualStudio/MainQuickInfoSource.cs | 4 +- .../VisualStudio/XmlDocRichTextPresenterEx.cs | 1 + 11 files changed, 744 insertions(+), 733 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2190bae..ffa38aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.26.2.4 +- [Updated] Updated ReSharper SDK to 2024.2.0. + ## 3.25.0.0 - [Updated] Updated ReSharper SDK to 2024.1.0. diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/IdentifierTooltipContentProvider.cs b/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/IdentifierTooltipContentProvider.cs index b134d4d..70779e5 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/IdentifierTooltipContentProvider.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/IdentifierTooltipContentProvider.cs @@ -473,8 +473,11 @@ private static IEnumerable GetParams( var paramNodesList = new LocalList(); if (typeParamNodes != null) { foreach (XmlNode paramNode in typeParamNodes) { - if (TryExtractParams(paramNode as XmlElement, languageType, psiModule, settings, highlighterIdProviderFactory, colorizerPresenter, textStyleHighlighterManager, codeAnnotationsConfiguration) is { } typeparam) + if (TryExtractParams(paramNode as XmlElement, languageType, psiModule, settings, highlighterIdProviderFactory, colorizerPresenter, + textStyleHighlighterManager, codeAnnotationsConfiguration) is { } typeparam) { + typeparam.IsTypeParameter = true; paramNodesList.Add(typeparam); + } } } diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/TextStyleHighlighterManager.cs b/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/TextStyleHighlighterManager.cs index 35cdf70..dc68191 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/TextStyleHighlighterManager.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/DocumentMarkup/TextStyleHighlighterManager.cs @@ -11,6 +11,7 @@ using JetBrains.UI.RichText; using JetBrains.Util; using JetBrains.Util.Media; +using JetBrains.Util.NetFX.Media.Colors; using Microsoft.VisualStudio.Text.Classification; using Microsoft.VisualStudio.Text.Formatting; using Color = System.Drawing.Color; diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/GammaJul.ReSharper.EnhancedTooltip.csproj b/source/GammaJul.ReSharper.EnhancedTooltip/GammaJul.ReSharper.EnhancedTooltip.csproj index 800dca7..c35dc23 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/GammaJul.ReSharper.EnhancedTooltip.csproj +++ b/source/GammaJul.ReSharper.EnhancedTooltip/GammaJul.ReSharper.EnhancedTooltip.csproj @@ -21,7 +21,7 @@ - + diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/CSharpColorizer.cs b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/CSharpColorizer.cs index dcea715..51da203 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/CSharpColorizer.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/CSharpColorizer.cs @@ -25,1094 +25,1090 @@ using JetBrains.UI.RichText; using JetBrains.Util; using JetBrains.Util.Media; +using JetBrains.Util.NetFX.Media.Colors; namespace GammaJul.ReSharper.EnhancedTooltip.Presentation { - /// - /// Implementation of for C#. - /// - /// - /// This class mimics a lot of functionality from ReSharper's . - /// Originally, I wanted to reuse the presenter and use the returned to colorize the needed parts. - /// However, there isn't enough information in the marking to do this correctly: rewriting it completely provides more flexibility. - /// Plus, we can provide additional options. - /// - internal sealed class CSharpColorizer : IColorizer { + /// + /// Implementation of for C#. + /// + /// + /// This class mimics a lot of functionality from ReSharper's . + /// Originally, I wanted to reuse the presenter and use the returned to colorize the needed parts. + /// However, there isn't enough information in the marking to do this correctly: rewriting it completely provides more flexibility. + /// Plus, we can provide additional options. + /// + internal sealed class CSharpColorizer : IColorizer { - private readonly struct Context { + private readonly struct Context { - internal readonly PresenterOptions Options; - internal readonly PresentedInfo? PresentedInfo; - internal readonly ITreeNode? ContextualNode; + internal readonly PresenterOptions Options; + internal readonly PresentedInfo? PresentedInfo; + internal readonly ITreeNode? ContextualNode; - public Context(PresenterOptions options, PresentedInfo? presentedInfo, ITreeNode? contextualNode) { + public Context(PresenterOptions options, PresentedInfo? presentedInfo, ITreeNode? contextualNode) { this.Options = options; this.PresentedInfo = presentedInfo; this.ContextualNode = contextualNode; - } + } - } + } - private static readonly DeclaredElementPresenterStyle _specialTypeStyle = new() { - ShowTypeParameters = TypeParameterStyle.NONE, - ShowName = NameStyle.SHORT - }; + private static readonly DeclaredElementPresenterStyle _specialTypeStyle = new() { + ShowTypeParameters = TypeParameterStyle.NONE, + ShowName = NameStyle.SHORT + }; - private readonly RichText _richText; - private readonly TextStyleHighlighterManager _textStyleHighlighterManager; - private readonly CodeAnnotationsConfiguration _codeAnnotationsConfiguration; - private readonly HighlighterIdProvider _highlighterIdProvider; + private readonly RichText _richText; + private readonly TextStyleHighlighterManager _textStyleHighlighterManager; + private readonly CodeAnnotationsConfiguration _codeAnnotationsConfiguration; + private readonly HighlighterIdProvider _highlighterIdProvider; - public HighlighterIdProvider HighlighterIdProvider - => this._highlighterIdProvider; + public HighlighterIdProvider HighlighterIdProvider + => this._highlighterIdProvider; - public PresentedInfo AppendDeclaredElement(IDeclaredElement element, ISubstitution substitution, PresenterOptions options, ITreeNode? contextualNode) { - var context = new Context(options, new PresentedInfo(), contextualNode); + public PresentedInfo AppendDeclaredElement(IDeclaredElement element, ISubstitution substitution, PresenterOptions options, ITreeNode? contextualNode) { + var context = new Context(options, new PresentedInfo(), contextualNode); - if (!IsClrPresentableElement(element)) - return context.PresentedInfo!; + if (!IsClrPresentableElement(element)) + return context.PresentedInfo!; - if (options.ShowElementKind != ElementKindDisplay.None) + if (options.ShowElementKind != ElementKindDisplay.None) this.AppendElementKind(element, context, options.ShowElementKind == ElementKindDisplay.Stylized); - if (options.ShowAccessRights) + if (options.ShowAccessRights) this.AppendAccessRights(element, true); - if (options.ShowModifiers) + if (options.ShowModifiers) this.AppendModifiers(element); - if (element is IAttributesSet attributesSet) + if (element is IAttributesSet attributesSet) this.AppendAttributes(attributesSet, options.ShowElementAttributes, options.ShowElementAttributesArguments, options.AttributesFormattingMode, context); - if (options.ShowElementType == ElementTypeDisplay.Before) + if (options.ShowElementType == ElementTypeDisplay.Before) this.AppendElementType(element, substitution, QualifierDisplays.ElementType, null, " ", context); - if (options.ShowName) + if (options.ShowName) this.AppendNameWithContainer(element, substitution, context); - if (options.ShowTypeParameters) { - if (element is ITypeParametersOwner typeParametersOwner) + if (options.ShowTypeParameters) { + if (element is ITypeParametersOwner typeParametersOwner) this.AppendTypeParameters(typeParametersOwner, substitution, true, true, context); - } + } - if (options.ShowParametersType || options.ShowParametersName) + if (options.ShowParametersType || options.ShowParametersName) this.AppendParameters(element, substitution, true, context); - if (options.ShowAccessors) { - if (element is IProperty property) + if (options.ShowAccessors) { + if (element is IProperty property) this.AppendAccessors(property, context); - } + } - if (options.ShowElementType == ElementTypeDisplay.After) + if (options.ShowElementType == ElementTypeDisplay.After) this.AppendElementType(element, substitution, QualifierDisplays.ElementType, ":", null, context); - if (options.ShowConstantValue) { - if (element is IConstantValueOwner constantValueOwner) + if (options.ShowConstantValue) { + if (element is IConstantValueOwner constantValueOwner) this.AppendConstantValueOwner(constantValueOwner); - } + } - return context.PresentedInfo!; - } + return context.PresentedInfo!; + } - private static bool IsClrPresentableElement(IDeclaredElement element) - => element.IsValid() - && element is IClrDeclaredElement - && element.GetElementType().IsPresentable(CSharpLanguage.Instance); + private static bool IsClrPresentableElement(IDeclaredElement element) + => element.IsValid() + && element is IClrDeclaredElement + && element.GetElementType().IsPresentable(CSharpLanguage.Instance); - public void AppendText(string? text, string? highlighterAttributeId) { - if (text.IsEmpty()) - return; + public void AppendText(string? text, string? highlighterAttributeId) { + if (text.IsEmpty()) + return; - TextStyle textStyle = this._textStyleHighlighterManager.GetHighlighterTextStyle(highlighterAttributeId); + TextStyle textStyle = this._textStyleHighlighterManager.GetHighlighterTextStyle(highlighterAttributeId); this._richText.Append(text, textStyle); - } + } - private void AppendText(string? text, TextStyle textStyle) { - if (!text.IsEmpty()) + private void AppendText(string? text, TextStyle textStyle) { + if (!text.IsEmpty()) this._richText.Append(text, textStyle); - } - - private void AppendElementKind(IDeclaredElement? element, Context context, bool stylized) { - PresenterOptions options = context.Options; - string kind = element.GetElementKindString( - options.UseExtensionMethodKind, - options.UseAttributeClassKind, - options.UseClassModifiersInKind, - options.UseStructModifiersInKind, - options.UseMethodModifiersInKind); + } + + private void AppendElementKind(IDeclaredElement? element, Context context, bool stylized) { + PresenterOptions options = context.Options; + string kind = element.GetElementKindString( + options.UseExtensionMethodKind, + options.UseAttributeClassKind, + options.UseClassModifiersInKind, + options.UseStructModifiersInKind, + options.UseMethodModifiersInKind); this.AppendElementKind(kind, stylized); - } + } - private void AppendElementKind(string kind, bool stylized) { - if (stylized) + private void AppendElementKind(string kind, bool stylized) { + if (stylized) this.AppendText("(" + kind + ") ", new TextStyle(JetFontStyles.Italic)); - else + else this.AppendText(kind + " ", null); - } + } - public void AppendAccessRights(IDeclaredElement element, bool addSpaceAfter) { - if (element is IAccessRightsOwner accessRightsOwner) + public void AppendAccessRights(IDeclaredElement element, bool addSpaceAfter) { + if (element is IAccessRightsOwner accessRightsOwner) this.AppendAccessRights(accessRightsOwner.GetAccessRights(), addSpaceAfter); - } + } - private void AppendAccessRights(AccessRights accessRights, bool addSpaceAfter) { + private void AppendAccessRights(AccessRights accessRights, bool addSpaceAfter) { if (accessRights == AccessRights.NONE) { return; } - var accessRightsString = CSharpDeclaredElementPresenter.Instance.Format(accessRights); - if (accessRightsString.IsNullOrEmpty()) - return; + var accessRightsString = CSharpDeclaredElementPresenter.Instance.Format(accessRights); + if (accessRightsString.IsNullOrEmpty()) + return; this.AppendText(accessRightsString, this._highlighterIdProvider.Keyword); - if (addSpaceAfter) + if (addSpaceAfter) this.AppendText(" ", null); - } - - private void AppendModifiers(IDeclaredElement element) { - if (element is not IModifiersOwner modifiersOwner || modifiersOwner is IAccessor || element.IsDestructor()) - return; - - var builder = new StringBuilder(); - if (element is ITypeElement) { - if (modifiersOwner.IsAbstract && modifiersOwner.IsSealed) - builder.Append("static "); - else { - if (modifiersOwner.IsSealed && !(element is IStruct)) - builder.Append("sealed "); - if (modifiersOwner.IsAbstract && !(element is IInterface)) - builder.Append("abstract "); - } - } - else { - if (modifiersOwner.IsAbstract) - builder.Append("abstract "); - if (modifiersOwner.IsSealed) - builder.Append("sealed "); - if (modifiersOwner.IsStatic) - builder.Append("static "); - } - if (modifiersOwner.IsVirtual) - builder.Append("virtual "); - if (modifiersOwner.IsOverride) - builder.Append("override "); - if (modifiersOwner.IsExtern) - builder.Append("extern "); - if (modifiersOwner.IsReadonly) - builder.Append("readonly "); - if (modifiersOwner.IsUnsafe) - builder.Append("unsafe "); - if (modifiersOwner.IsVolatile) - builder.Append("volatile "); - - if (builder.Length > 0) + } + + private void AppendModifiers(IDeclaredElement element) { + if (element is not IModifiersOwner modifiersOwner || modifiersOwner is IAccessor || element.IsDestructor()) + return; + + var builder = new StringBuilder(); + if (element is ITypeElement) { + if (modifiersOwner.IsAbstract && modifiersOwner.IsSealed) + builder.Append("static "); + else { + if (modifiersOwner.IsSealed && !(element is IStruct)) + builder.Append("sealed "); + if (modifiersOwner.IsAbstract && !(element is IInterface)) + builder.Append("abstract "); + } + } else { + if (modifiersOwner.IsAbstract) + builder.Append("abstract "); + if (modifiersOwner.IsSealed) + builder.Append("sealed "); + if (modifiersOwner.IsStatic) + builder.Append("static "); + } + if (modifiersOwner.IsVirtual) + builder.Append("virtual "); + if (modifiersOwner.IsOverride) + builder.Append("override "); + if (modifiersOwner.IsExtern) + builder.Append("extern "); + if (modifiersOwner.IsReadonly) + builder.Append("readonly "); + if (modifiersOwner.IsUnsafe) + builder.Append("unsafe "); + if (modifiersOwner.IsVolatile) + builder.Append("volatile "); + + if (builder.Length > 0) this.AppendText(builder.ToString(), this._highlighterIdProvider.Keyword); - } - - private void AppendElementType( - IDeclaredElement element, - ISubstitution substitution, - QualifierDisplays expectedQualifierDisplay, - string? before, - string? after, - Context context) { - - // Use the special type first if available (eg Razor helper), colorize it as a keyword - string? specialTypeString = CSharpModificationUtil.GetSpecialElementType(_specialTypeStyle, element, substitution); - if (!specialTypeString.IsEmpty()) { + } + + private void AppendElementType( + IDeclaredElement element, + ISubstitution substitution, + QualifierDisplays expectedQualifierDisplay, + string? before, + string? after, + Context context) { + + // Use the special type first if available (eg Razor helper), colorize it as a keyword + string? specialTypeString = CSharpModificationUtil.GetSpecialElementType(_specialTypeStyle, element, substitution); + if (!specialTypeString.IsEmpty()) { this.AppendText(before, null); this.AppendText(specialTypeString, this._highlighterIdProvider.Keyword); this.AppendText(after, null); - return; - } + return; + } - if (GetElementType(element, substitution) is not { } elementType) - return; + if (GetElementType(element, substitution) is not { } elementType) + return; this.AppendText(before, null); - if ((element.IsRefMember() || (element is ICSharpLocalVariable localVariable && localVariable.ReferenceKind.IsByReference())) && (element as IParameter)?.Kind == ParameterKind.REFERENCE) + if ((element.IsRefMember() || (element is ICSharpLocalVariable localVariable && localVariable.ReferenceKind.IsByReference())) && (element as IParameter)?.Kind == ParameterKind.REFERENCE) this.AppendText("ref ", this._highlighterIdProvider.Keyword); - else if (element is IParameter parameter) { - string? specialModifier = GetParameterSpecialModifier(parameter); - if (!specialModifier.IsEmpty()) + else if (element is IParameter parameter) { + string? specialModifier = GetParameterSpecialModifier(parameter); + if (!specialModifier.IsEmpty()) this.AppendText(specialModifier, this._highlighterIdProvider.Keyword); - string? kindModifier = GetParameterKindModifier(parameter); - if (!kindModifier.IsEmpty()) + string? kindModifier = GetParameterKindModifier(parameter); + if (!kindModifier.IsEmpty()) this.AppendText(kindModifier, this._highlighterIdProvider.Keyword); - } + } this.AppendType(elementType, expectedQualifierDisplay, true, context); this.AppendText(after, null); - } - - private static IType? GetElementType(IDeclaredElement element, ISubstitution substitution) - => element switch { - IConstructor => null, - _ when element.IsDestructor() => null, - ITypeOwner typeOwner => substitution.Apply(typeOwner.Type), - IParametersOwner parametersOwner => substitution.Apply(parametersOwner.ReturnType), - IDelegate deleg => substitution.Apply(deleg.InvokeMethod.ReturnType), - _ => null - }; - - public void AppendExpressionType(IExpressionType? expressionType, bool appendModuleName, PresenterOptions options) { - if (expressionType is null) - return; - - if (expressionType.ToIType() is { } itype) { + } + + private static IType? GetElementType(IDeclaredElement element, ISubstitution substitution) + => element switch { + IConstructor => null, + _ when element.IsDestructor() => null, + ITypeOwner typeOwner => substitution.Apply(typeOwner.Type), + IParametersOwner parametersOwner => substitution.Apply(parametersOwner.ReturnType), + IDelegate deleg => substitution.Apply(deleg.InvokeMethod.ReturnType), + _ => null + }; + + public void AppendExpressionType(IExpressionType? expressionType, bool appendModuleName, PresenterOptions options) { + if (expressionType is null) + return; + + if (expressionType.ToIType() is { } itype) { this.AppendType(itype, QualifierDisplays.Everywhere, true, new Context(options, null, null)); - if (appendModuleName) + if (appendModuleName) this.AppendModuleName(itype); - return; - } + return; + } this.AppendText(expressionType.GetLongPresentableName(CSharpLanguage.Instance!), null); - } + } - private void AppendType(IType type, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { - switch (type) { - case IArrayType arrayType: + private void AppendType(IType type, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { + switch (type) { + case IArrayType arrayType: this.AppendArrayType(arrayType, expectedQualifierDisplay, displayUnknownTypeParameters, context); - return; - case IPointerType pointerType: + return; + case IPointerType pointerType: this.AppendPointerType(pointerType, expectedQualifierDisplay, displayUnknownTypeParameters, context); - return; - case IDeclaredType declaredType: + return; + case IDeclaredType declaredType: this.AppendDeclaredType(declaredType, expectedQualifierDisplay, true, displayUnknownTypeParameters, context); - return; - case IAnonymousType: + return; + case IAnonymousType: this.AppendText("anonymous type", null); - return; - default: + return; + default: this.AppendText(type.GetLongPresentableName(CSharpLanguage.Instance!), null); - return; - } - } + return; + } + } - private void AppendModuleName(IType itype) { + private void AppendModuleName(IType itype) { this.AppendText(" [", null); this.AppendText(GetModuleFullName(itype), null); this.AppendText("]", null); - } + } - private void AppendArrayType(IArrayType arrayType, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { + private void AppendArrayType(IArrayType arrayType, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { this.AppendType(arrayType.ElementType, expectedQualifierDisplay, displayUnknownTypeParameters, context); this.AppendText("[" + new string(',', arrayType.Rank - 1) + "]", null); - } + } - private void AppendPointerType(IPointerType pointerType, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { + private void AppendPointerType(IPointerType pointerType, QualifierDisplays expectedQualifierDisplay, bool displayUnknownTypeParameters, Context context) { this.AppendType(pointerType.ElementType, expectedQualifierDisplay, displayUnknownTypeParameters, context); this.AppendText("*", this._highlighterIdProvider.Operator); - } + } - private static string FormatShortName(string shortName) - => CSharpLexer.IsKeyword(shortName) ? "@" + shortName : shortName; + private static string FormatShortName(string shortName) + => CSharpLexer.IsKeyword(shortName) ? "@" + shortName : shortName; - private void AppendDeclaredType( - IDeclaredType declaredType, - QualifierDisplays expectedQualifierDisplay, - bool appendTypeParameters, - bool displayUnknownTypeParameters, - Context context) { + private void AppendDeclaredType( + IDeclaredType declaredType, + QualifierDisplays expectedQualifierDisplay, + bool appendTypeParameters, + bool displayUnknownTypeParameters, + Context context) { if (declaredType.IsDynamicType()) { this.AppendText("dynamic", this._highlighterIdProvider.Keyword); - return; - } + return; + } - if (declaredType.IsTupleType()) { + if (declaredType.IsTupleType()) { var tupleType = declaredType.AsTupleType(); if (tupleType != null) { this.AppendTupleType(tupleType.Value, expectedQualifierDisplay, displayUnknownTypeParameters, context); } return; - } + } - if (context.Options.UseTypeKeywords) { - if (CSharpTypeFactory.GetTypeKeyword(declaredType.GetTypeElement()) is { } typeKeyword) { + if (context.Options.UseTypeKeywords) { + if (CSharpTypeFactory.GetTypeKeyword(declaredType.GetTypeElement()) is { } typeKeyword) { this.AppendText(typeKeyword, this._highlighterIdProvider.Keyword); - if (declaredType.NullableAnnotation == NullableAnnotation.Annotated) + if (declaredType.NullableAnnotation == NullableAnnotation.Annotated) this.AppendText("?", this._highlighterIdProvider.Operator); - return; - } - } - else if (declaredType.IsVoid()) { + return; + } + } else if (declaredType.IsVoid()) { this.AppendText("void", this._highlighterIdProvider.Keyword); - return; - } + return; + } - if (declaredType.GetTypeElement() is { } typeElement && typeElement.IsValid()) { + if (declaredType.GetTypeElement() is { } typeElement && typeElement.IsValid()) { this.AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedQualifierDisplay, appendTypeParameters, displayUnknownTypeParameters, context); - if (declaredType.NullableAnnotation == NullableAnnotation.Annotated && !Equals(typeElement.GetClrName(), PredefinedType.GENERIC_NULLABLE_FQN)) + if (declaredType.NullableAnnotation == NullableAnnotation.Annotated && !Equals(typeElement.GetClrName(), PredefinedType.GENERIC_NULLABLE_FQN)) this.AppendText("?", this._highlighterIdProvider.Operator); - } - else { + } else { this.AppendText(declaredType.GetPresentableName(CSharpLanguage.Instance!), null); - } - } + } + } - private void AppendTupleType( - DecoratedType tupleType, - QualifierDisplays expectedQualifierDisplay, - bool displayUnknownTypeParameters, - Context context) { + private void AppendTupleType( + DecoratedType tupleType, + QualifierDisplays expectedQualifierDisplay, + bool displayUnknownTypeParameters, + Context context) { this.AppendText("(", null); - IReadOnlyList components = tupleType.GetComponents(); - int componentCount = components.Count; - for (int i = 0; i < componentCount; ++i) { - if (i > 0) + IReadOnlyList components = tupleType.GetComponents(); + int componentCount = components.Count; + for (int i = 0; i < componentCount; ++i) { + if (i > 0) this.AppendText(", ", null); - TupleTypeComponent component = components[i]; + TupleTypeComponent component = components[i]; this.AppendType(component.Type, expectedQualifierDisplay, displayUnknownTypeParameters, context); - if (component.HasExplicitName) { + if (component.HasExplicitName) { this.AppendText(" ", null); this.AppendText(component.ExplicitName, this._highlighterIdProvider.TupleComponentName); - } - } + } + } this.AppendText(")", null); - } - - private void AppendTypeElement( - ITypeElement typeElement, - ISubstitution substitution, - QualifierDisplays expectedQualifierDisplay, - bool appendTypeParameters, - bool displayUnknownTypeParameters, - Context context) { - - if (context.Options.UseShortNullableForm - && Equals(typeElement.GetClrName(), PredefinedType.GENERIC_NULLABLE_FQN) - && typeElement.TypeParameters.Count == 1) { - IType underlyingType = substitution.Apply(typeElement.TypeParameters[0]); + } + + private void AppendTypeElement( + ITypeElement typeElement, + ISubstitution substitution, + QualifierDisplays expectedQualifierDisplay, + bool appendTypeParameters, + bool displayUnknownTypeParameters, + Context context) { + + if (context.Options.UseShortNullableForm + && Equals(typeElement.GetClrName(), PredefinedType.GENERIC_NULLABLE_FQN) + && typeElement.TypeParameters.Count == 1) { + IType underlyingType = substitution.Apply(typeElement.TypeParameters[0]); this.AppendType(underlyingType, expectedQualifierDisplay, displayUnknownTypeParameters, context); this.AppendText("?", this._highlighterIdProvider.Operator); - return; - } + return; + } - if (typeElement is not ITypeParameter && (context.Options.ShowQualifiers & expectedQualifierDisplay) != QualifierDisplays.None) { - if (this.AppendNamespaceParts(GetNamespacePartsToDisplay(typeElement, context))) + if (typeElement is not ITypeParameter && (context.Options.ShowQualifiers & expectedQualifierDisplay) != QualifierDisplays.None) { + if (this.AppendNamespaceParts(GetNamespacePartsToDisplay(typeElement, context))) this.AppendText(".", this._highlighterIdProvider.Operator); - if (typeElement.GetContainingType() is { } containingType && !(typeElement is IDelegate && context.Options.FormatDelegatesAsLambdas)) { + if (typeElement.GetContainingType() is { } containingType && !(typeElement is IDelegate && context.Options.FormatDelegatesAsLambdas)) { this.AppendDeclaredType(TypeFactory.CreateType(containingType, substitution, NullableAnnotation.Unknown), QualifierDisplays.None, true, displayUnknownTypeParameters, context); this.AppendText(".", this._highlighterIdProvider.Operator); - } - } + } + } - if (typeElement is IDelegate deleg && context.Options.FormatDelegatesAsLambdas && expectedQualifierDisplay == QualifierDisplays.Parameters) { + if (typeElement is IDelegate deleg && context.Options.FormatDelegatesAsLambdas && expectedQualifierDisplay == QualifierDisplays.Parameters) { this.AppendParameters(deleg.InvokeMethod, substitution, false, context); this.AppendText(" => ", this._highlighterIdProvider.Operator); this.AppendType(substitution.Apply(deleg.InvokeMethod.ReturnType), expectedQualifierDisplay, displayUnknownTypeParameters, context); - return; - } + return; + } this.AppendText(FormatShortName(typeElement.ShortName), this._highlighterIdProvider.GetForTypeElement(typeElement)); - if (appendTypeParameters) + if (appendTypeParameters) this.AppendTypeParameters(typeElement, substitution, false, displayUnknownTypeParameters, context); - } + } - private static List? GetNamespacePartsToDisplay(ITypeElement typeElement, Context context) { - if (typeElement is ICompiledElement) { - switch (context.Options.ExternalCodeNamespaceDisplayKind) { + private static List? GetNamespacePartsToDisplay(ITypeElement typeElement, Context context) { + if (typeElement is ICompiledElement) { + switch (context.Options.ExternalCodeNamespaceDisplayKind) { - case ExternalCodeNamespaceDisplayKind.Never: - return null; + case ExternalCodeNamespaceDisplayKind.Never: + return null; - case ExternalCodeNamespaceDisplayKind.Always: - return GetNamespaceParts(typeElement.GetContainingNamespace()); + case ExternalCodeNamespaceDisplayKind.Always: + return GetNamespaceParts(typeElement.GetContainingNamespace()); - case ExternalCodeNamespaceDisplayKind.OnlyForNonSystem: - if (typeElement.IsInSystemLikeNamespace()) - goto case ExternalCodeNamespaceDisplayKind.Never; - goto case ExternalCodeNamespaceDisplayKind.Always; + case ExternalCodeNamespaceDisplayKind.OnlyForNonSystem: + if (typeElement.IsInSystemLikeNamespace()) + goto case ExternalCodeNamespaceDisplayKind.Never; + goto case ExternalCodeNamespaceDisplayKind.Always; - default: - goto case ExternalCodeNamespaceDisplayKind.Always; - } - } + default: + goto case ExternalCodeNamespaceDisplayKind.Always; + } + } - switch (context.Options.SolutionCodeNamespaceDisplayKind) { + switch (context.Options.SolutionCodeNamespaceDisplayKind) { - case SolutionCodeNamespaceDisplayKind.Never: - return null; + case SolutionCodeNamespaceDisplayKind.Never: + return null; - case SolutionCodeNamespaceDisplayKind.Always: - return GetNamespaceParts(typeElement.GetContainingNamespace()); + case SolutionCodeNamespaceDisplayKind.Always: + return GetNamespaceParts(typeElement.GetContainingNamespace()); - case SolutionCodeNamespaceDisplayKind.Smart: - if (context.ContextualNode?.GetContainingNode() is { } contextualNamespace) - return GetDifferentNamespaceParts(typeElement.GetContainingNamespace(), contextualNamespace.DeclaredElement); - goto case SolutionCodeNamespaceDisplayKind.Always; + case SolutionCodeNamespaceDisplayKind.Smart: + if (context.ContextualNode?.GetContainingNode() is { } contextualNamespace) + return GetDifferentNamespaceParts(typeElement.GetContainingNamespace(), contextualNamespace.DeclaredElement); + goto case SolutionCodeNamespaceDisplayKind.Always; - default: - goto case SolutionCodeNamespaceDisplayKind.Always; - } - } + default: + goto case SolutionCodeNamespaceDisplayKind.Always; + } + } - private static List GetDifferentNamespaceParts(INamespace? sourceNamespace, INamespace? contextualNamespace) { - List sourceParts = GetNamespaceParts(sourceNamespace); - List contextualParts = GetNamespaceParts(contextualNamespace); + private static List GetDifferentNamespaceParts(INamespace? sourceNamespace, INamespace? contextualNamespace) { + List sourceParts = GetNamespaceParts(sourceNamespace); + List contextualParts = GetNamespaceParts(contextualNamespace); - int length = Math.Min(sourceParts.Count, contextualParts.Count); - int index = 0; - while (index < length && sourceParts[index] == contextualParts[index]) - ++index; + int length = Math.Min(sourceParts.Count, contextualParts.Count); + int index = 0; + while (index < length && sourceParts[index] == contextualParts[index]) + ++index; - if (index > 0) { - sourceParts.RemoveRange(0, index); - if (sourceParts.Count > 0) - sourceParts.Insert(0, "…"); - } + if (index > 0) { + sourceParts.RemoveRange(0, index); + if (sourceParts.Count > 0) + sourceParts.Insert(0, "…"); + } - return sourceParts; - } + return sourceParts; + } - private static string GetModuleFullName(IType type) { - if (type.GetScalarType()?.Assembly is { } assembly) - return assembly.FullName; + private static string GetModuleFullName(IType type) { + if (type.GetScalarType()?.Assembly is { } assembly) + return assembly.FullName; - if ((type.Module as IAssemblyPsiModule)?.Assembly.AssemblyName.FullName is { } name) - return name; + if ((type.Module as IAssemblyPsiModule)?.Assembly.AssemblyName.FullName is { } name) + return name; - return type.Module.DisplayName; - } + return type.Module.DisplayName; + } - private bool AppendNamespaceParts(List? namespaceParts) { - if (namespaceParts is null || namespaceParts.Count == 0) - return false; + private bool AppendNamespaceParts(List? namespaceParts) { + if (namespaceParts is null || namespaceParts.Count == 0) + return false; - string namespaceHighlighterId = this._highlighterIdProvider.Namespace; - string operatorHighlighterId = this._highlighterIdProvider.Operator; + string namespaceHighlighterId = this._highlighterIdProvider.Namespace; + string operatorHighlighterId = this._highlighterIdProvider.Operator; - for (int i = 0; i < namespaceParts.Count; ++i) { - if (i > 0) + for (int i = 0; i < namespaceParts.Count; ++i) { + if (i > 0) this.AppendText(".", operatorHighlighterId); this.AppendText(namespaceParts[i], namespaceHighlighterId); - } - - return true; - } - - private static List GetNamespaceParts(INamespace? ns) { - var parts = new List(); - for (INamespace? iter = ns; iter is { IsRootNamespace: false }; iter = iter.GetContainingNamespace()) - parts.Add(iter.ShortName); - parts.Reverse(); - return parts; - } - - private void AppendTypeParameters( - ITypeParametersOwner typeParametersOwner, - ISubstitution substitution, - bool isTopLevel, - bool displayUnknownTypeParameters, - Context context) { - - IList typeParameters = typeParametersOwner.TypeParameters; - int typeParameterCount = typeParameters.Count; - if (typeParameterCount == 0) - return; + } + + return true; + } + + private static List GetNamespaceParts(INamespace? ns) { + var parts = new List(); + for (INamespace? iter = ns; iter is { IsRootNamespace: false }; iter = iter.GetContainingNamespace()) + parts.Add(iter.ShortName); + parts.Reverse(); + return parts; + } + + private void AppendTypeParameters( + ITypeParametersOwner typeParametersOwner, + ISubstitution substitution, + bool isTopLevel, + bool displayUnknownTypeParameters, + Context context) { + + IList typeParameters = typeParametersOwner.TypeParameters; + int typeParameterCount = typeParameters.Count; + if (typeParameterCount == 0) + return; this.AppendText("<", this._highlighterIdProvider.Operator); - for (int i = 0; i < typeParameterCount; ++i) { - if (i > 0) + for (int i = 0; i < typeParameterCount; ++i) { + if (i > 0) this.AppendText(",", null); - int startOffset = this._richText.Length; - ITypeParameter typeParameter = typeParameters[i]; + int startOffset = this._richText.Length; + ITypeParameter typeParameter = typeParameters[i]; - if (context.Options.ShowTypeParametersVariance) + if (context.Options.ShowTypeParametersVariance) this.AppendVariance(typeParameter.Variance); - IType type = substitution.Apply(typeParameter); - if (displayUnknownTypeParameters || !type.IsUnknown) + IType type = substitution.Apply(typeParameter); + if (displayUnknownTypeParameters || !type.IsUnknown) this.AppendType(type, QualifierDisplays.TypeParameters, displayUnknownTypeParameters, context); - if (isTopLevel) - context.PresentedInfo?.TypeParameters.Add(new TextRange(startOffset, this._richText.Length)); - } + if (isTopLevel) + context.PresentedInfo?.TypeParameters.Add(new TextRange(startOffset, this._richText.Length)); + } this.AppendText(">", this._highlighterIdProvider.Operator); - } + } - private void AppendVariance(TypeParameterVariance variance) { - switch (variance) { - case TypeParameterVariance.IN: + private void AppendVariance(TypeParameterVariance variance) { + switch (variance) { + case TypeParameterVariance.IN: this.AppendText("in ", this._highlighterIdProvider.Keyword); - break; - case TypeParameterVariance.OUT: + break; + case TypeParameterVariance.OUT: this.AppendText("out ", this._highlighterIdProvider.Keyword); - break; - } - } + break; + } + } - private void AppendNameWithContainer(IDeclaredElement element, ISubstitution substitution, Context context) { - if (element is ITypeElement typeElement) { + private void AppendNameWithContainer(IDeclaredElement element, ISubstitution substitution, Context context) { + if (element is ITypeElement typeElement) { this.AppendTypeElement(typeElement, substitution, QualifierDisplays.Member, false, false, context); - return; - } + return; + } - if (element is INamespace ns) { + if (element is INamespace ns) { this.AppendNamespaceParts(GetNamespaceParts(ns)); - return; - } + return; + } - bool appendedExplicitInterface = false; - if (context.Options.ShowExplicitInterface - && element is IOverridableMember { IsExplicitImplementation: true } overridableMember - && CSharpDeclaredElementUtil.InterfaceQualification(overridableMember) is { } declaredType) { + bool appendedExplicitInterface = false; + if (context.Options.ShowExplicitInterface + && element is IOverridableMember { IsExplicitImplementation: true } overridableMember + && CSharpDeclaredElementUtil.InterfaceQualification(overridableMember) is { } declaredType) { this.AppendDeclaredType(declaredType, QualifierDisplays.None, true, true, context); this.AppendText(".", this._highlighterIdProvider.Operator); - appendedExplicitInterface = true; - } + appendedExplicitInterface = true; + } - if (!appendedExplicitInterface && (context.Options.ShowQualifiers & QualifierDisplays.Member) != QualifierDisplays.None - && (element as ITypeMember)?.GetContainingType() is { } containingTypeElement) { + if (!appendedExplicitInterface && (context.Options.ShowQualifiers & QualifierDisplays.Member) != QualifierDisplays.None + && (element as ITypeMember)?.GetContainingType() is { } containingTypeElement) { this.AppendTypeElement(containingTypeElement, substitution, QualifierDisplays.Member, true, true, context); this.AppendText(".", this._highlighterIdProvider.Operator); - } + } this.AppendName(element); - } + } - private void AppendName(IDeclaredElement element) { - string? highlighterId = this._highlighterIdProvider.GetForDeclaredElement(element); + private void AppendName(IDeclaredElement element) { + string? highlighterId = this._highlighterIdProvider.GetForDeclaredElement(element); - switch (element) { + switch (element) { - case var _ when element.IsDestructor(): - if (((IClrDeclaredElement) element).GetContainingType() is { } containingType) { + case var _ when element.IsDestructor(): + if (((IClrDeclaredElement)element).GetContainingType() is { } containingType) { this.AppendText("~", this._highlighterIdProvider.Operator); this.AppendText(containingType.ShortName, highlighterId); - } - return; + } + return; - case var _ when CSharpDeclaredElementUtil.IsIndexer(element): + case var _ when CSharpDeclaredElementUtil.IsIndexer(element): this.AppendText("this", this._highlighterIdProvider.Keyword); - return; + return; - case IAnonymousMethod: + case IAnonymousMethod: this.AppendText("Anonymous method", highlighterId); - return; + return; - case IConversionOperator conversionOperator: - if (conversionOperator.IsImplicitCast) + case IConversionOperator conversionOperator: + if (conversionOperator.IsImplicitCast) this.AppendText("implicit", this._highlighterIdProvider.Keyword); - else if (conversionOperator.IsExplicitCast) + else if (conversionOperator.IsExplicitCast) this.AppendText("explicit", this._highlighterIdProvider.Keyword); - return; + return; - case ISignOperator: + case ISignOperator: this.AppendText(GetSignOperator(element.ShortName), highlighterId); - return; + return; - case INamespace { IsRootNamespace: true }: + case INamespace { IsRootNamespace: true }: this.AppendText("", highlighterId); - return; + return; - case IParameter { IsVarArg: true }: + case IParameter { IsVarArg: true }: this.AppendText("__arglist", this._highlighterIdProvider.Keyword); - return; + return; - case IConstructor constructor: - string shortName = constructor.GetContainingType()?.ShortName ?? constructor.ShortName; + case IConstructor constructor: + string shortName = constructor.GetContainingType()?.ShortName ?? constructor.ShortName; this.AppendText(FormatShortName(shortName), highlighterId); - return; + return; - default: + default: this.AppendText(FormatShortName(element.ShortName), highlighterId); - return; - } - } - - private static string GetSignOperator(string operatorName) - => operatorName switch { - OperatorName.UNARY_PLUS => "+", - OperatorName.UNARY_MINUS => "-", - OperatorName.UNARY_LOGNOT => "!", - OperatorName.UNARY_COMPLEMENT => "~", - OperatorName.UNARY_INCREMENT => "++", - OperatorName.UNARY_DECREMENT => "--", - OperatorName.UNARY_TRUE => "true", - OperatorName.UNARY_FALSE => "false", - OperatorName.BINARY_PLUS => "+", - OperatorName.BINARY_MINUS => "-", - OperatorName.BINARY_MULTIPLY => "*", - OperatorName.BINARY_DIVIDE => "/", - OperatorName.BINARY_MODULUS => "%", - OperatorName.BINARY_BITWISE_AND => "&", - OperatorName.BINARY_BITWISE_OR => "|", - OperatorName.BINARY_EXCLUSIVE_OR => "^", - OperatorName.BINARY_LEFTSHIFT => "<<", - OperatorName.BINARY_RIGHTSHIFT => ">>", - OperatorName.BINARY_EQUALITY => "==", - OperatorName.BINARY_INEQUALITY => "!=", - OperatorName.BINARY_LT => "<", - OperatorName.BINARY_LE => "<=", - OperatorName.BINARY_GT => ">", - OperatorName.BINARY_GE => ">=", - _ => operatorName - }; - - private void AppendParameters(IDeclaredElement element, ISubstitution substitution, bool isTopLevel, Context context) { - if (TryGetParametersOwner(element) is not { } parametersOwner || !ShouldShowParameters(element)) - return; - - bool isIndexer = IsIndexer(element); + return; + } + } + + private static string GetSignOperator(string operatorName) + => operatorName switch { + OperatorName.UNARY_PLUS => "+", + OperatorName.UNARY_MINUS => "-", + OperatorName.UNARY_LOGNOT => "!", + OperatorName.UNARY_COMPLEMENT => "~", + OperatorName.UNARY_INCREMENT => "++", + OperatorName.UNARY_DECREMENT => "--", + OperatorName.UNARY_TRUE => "true", + OperatorName.UNARY_FALSE => "false", + OperatorName.BINARY_PLUS => "+", + OperatorName.BINARY_MINUS => "-", + OperatorName.BINARY_MULTIPLY => "*", + OperatorName.BINARY_DIVIDE => "/", + OperatorName.BINARY_MODULUS => "%", + OperatorName.BINARY_BITWISE_AND => "&", + OperatorName.BINARY_BITWISE_OR => "|", + OperatorName.BINARY_EXCLUSIVE_OR => "^", + OperatorName.BINARY_LEFTSHIFT => "<<", + OperatorName.BINARY_RIGHTSHIFT => ">>", + OperatorName.BINARY_EQUALITY => "==", + OperatorName.BINARY_INEQUALITY => "!=", + OperatorName.BINARY_LT => "<", + OperatorName.BINARY_LE => "<=", + OperatorName.BINARY_GT => ">", + OperatorName.BINARY_GE => ">=", + _ => operatorName + }; + + private void AppendParameters(IDeclaredElement element, ISubstitution substitution, bool isTopLevel, Context context) { + if (TryGetParametersOwner(element) is not { } parametersOwner || !ShouldShowParameters(element)) + return; + + bool isIndexer = IsIndexer(element); this.AppendText(isIndexer ? "[" : "(", null); - IList parameters = parametersOwner.Parameters; + IList parameters = parametersOwner.Parameters; - int parameterCount = parameters.Count; - if (parameterCount == 0) { - if (isTopLevel && context.Options.ShowEmptyParametersText) + int parameterCount = parameters.Count; + if (parameterCount == 0) { + if (isTopLevel && context.Options.ShowEmptyParametersText) this.AppendText("", new TextStyle(JetFontStyles.Regular, Color.Gray.ToJetRgbaColor())); - } + } else { + ParametersFormattingMode formattingMode = context.Options.ParametersFormattingMode; + bool addNewLineAroundParameters = isTopLevel && formattingMode == ParametersFormattingMode.AllOnNewLine; + bool addNewLineBeforeEachParameter = isTopLevel && ShouldAddNewLineBeforeEachParameter(formattingMode, parameterCount); - else { - ParametersFormattingMode formattingMode = context.Options.ParametersFormattingMode; - bool addNewLineAroundParameters = isTopLevel && formattingMode == ParametersFormattingMode.AllOnNewLine; - bool addNewLineBeforeEachParameter = isTopLevel && ShouldAddNewLineBeforeEachParameter(formattingMode, parameterCount); - - if (addNewLineAroundParameters) + if (addNewLineAroundParameters) this.AppendText("\r\n ", null); - for (int i = 0; i < parameterCount; i++) { - if (i > 0) + for (int i = 0; i < parameterCount; i++) { + if (i > 0) this.AppendText(", ", null); - if (addNewLineBeforeEachParameter) + if (addNewLineBeforeEachParameter) this.AppendText("\r\n ", null); - int startOffset = this._richText.Length; + int startOffset = this._richText.Length; - IParameter parameter = parameters[i]; + IParameter parameter = parameters[i]; this.AppendParameter(parameter, substitution, context); - if (isTopLevel && context.PresentedInfo is not null) { - context.PresentedInfo.Parameters.Add(new TextRange(startOffset, this._richText.Length)); - if (parameter.IsExtensionFirstParameter()) - context.PresentedInfo.IsExtensionMethod = true; - } - } + if (isTopLevel && context.PresentedInfo is not null) { + context.PresentedInfo.Parameters.Add(new TextRange(startOffset, this._richText.Length)); + if (parameter.IsExtensionFirstParameter()) + context.PresentedInfo.IsExtensionMethod = true; + } + } - if (addNewLineAroundParameters || addNewLineBeforeEachParameter) + if (addNewLineAroundParameters || addNewLineBeforeEachParameter) this.AppendText("\r\n", null); - } + } this.AppendText(isIndexer ? "]" : ")", null); - } - - [Pure] - private static bool ShouldAddNewLineBeforeEachParameter(ParametersFormattingMode formattingMode, int parameterCount) - => formattingMode switch { - ParametersFormattingMode.AllOnCurrentLine => false, - ParametersFormattingMode.AllOnNewLine => false, - ParametersFormattingMode.OnePerLine => true, - ParametersFormattingMode.OnePerLineIfMultiple => parameterCount > 1, - _ => false - }; - - private static IParametersOwner? TryGetParametersOwner(IDeclaredElement declaredElement) { - if (declaredElement is IParametersOwner parametersOwner) - return parametersOwner; - - return (declaredElement as IDelegate)?.InvokeMethod; - } - - private void AppendParameter(IParameter parameter, ISubstitution substitution, Context context) { - if (parameter.IsVarArg) { + } + + [Pure] + private static bool ShouldAddNewLineBeforeEachParameter(ParametersFormattingMode formattingMode, int parameterCount) + => formattingMode switch { + ParametersFormattingMode.AllOnCurrentLine => false, + ParametersFormattingMode.AllOnNewLine => false, + ParametersFormattingMode.OnePerLine => true, + ParametersFormattingMode.OnePerLineIfMultiple => parameterCount > 1, + _ => false + }; + + private static IParametersOwner? TryGetParametersOwner(IDeclaredElement declaredElement) { + if (declaredElement is IParametersOwner parametersOwner) + return parametersOwner; + + return (declaredElement as IDelegate)?.InvokeMethod; + } + + private void AppendParameter(IParameter parameter, ISubstitution substitution, Context context) { + if (parameter.IsVarArg) { this.AppendText("__arglist", this._highlighterIdProvider.Keyword); - return; - } + return; + } - PresenterOptions options = context.Options; + PresenterOptions options = context.Options; this.AppendAttributes(parameter, options.ShowParametersAttributes, options.ShowParametersAttributesArguments, AttributesFormattingMode.AllOnCurrentLine, context); - if (options.ShowParametersType) + if (options.ShowParametersType) this.AppendElementType(parameter, substitution, QualifierDisplays.Parameters, null, options.ShowParametersName ? " " : null, context); - if (options.ShowParametersName) + if (options.ShowParametersName) this.AppendText(FormatShortName(parameter.ShortName), this._highlighterIdProvider.Parameter); - if (options.ShowDefaultValues) + if (options.ShowDefaultValues) this.AppendDefaultValue(parameter, substitution, context); - } + } - private void AppendAttributes( - IAttributesSet attributesSet, - AttributesDisplayKind displayKind, - bool showArguments, - AttributesFormattingMode formattingMode, - Context context) { + private void AppendAttributes( + IAttributesSet attributesSet, + AttributesDisplayKind displayKind, + bool showArguments, + AttributesFormattingMode formattingMode, + Context context) { - if (displayKind == AttributesDisplayKind.Never) - return; + if (displayKind == AttributesDisplayKind.Never) + return; - IList attributes = attributesSet.GetAttributeInstances(false); - if (attributes.Count == 0) - return; + IList attributes = attributesSet.GetAttributeInstances(false); + if (attributes.Count == 0) + return; - var filteredAttributes = new LocalList(); - foreach (IAttributeInstance attribute in attributes) { - if (this.MatchesAttributesDisplayKind(attribute, displayKind)) - filteredAttributes.Add(attribute); - } + var filteredAttributes = new LocalList(); + foreach (IAttributeInstance attribute in attributes) { + if (this.MatchesAttributesDisplayKind(attribute, displayKind)) + filteredAttributes.Add(attribute); + } - if (filteredAttributes.Count == 0) - return; + if (filteredAttributes.Count == 0) + return; - bool addNewLineAroundAttributes = formattingMode == AttributesFormattingMode.AllOnNewLine; - bool addNewLineBeforeEachAttribute = ShouldAddNewLineBeforeEachAttribute(formattingMode, filteredAttributes.Count); + bool addNewLineAroundAttributes = formattingMode == AttributesFormattingMode.AllOnNewLine; + bool addNewLineBeforeEachAttribute = ShouldAddNewLineBeforeEachAttribute(formattingMode, filteredAttributes.Count); - if (addNewLineAroundAttributes) + if (addNewLineAroundAttributes) this.AppendText("\r\n", null); - foreach (IAttributeInstance attribute in filteredAttributes) { - if (addNewLineBeforeEachAttribute) + foreach (IAttributeInstance attribute in filteredAttributes) { + if (addNewLineBeforeEachAttribute) this.AppendText("\r\n", null); this.AppendAttribute(attribute, showArguments, context); - } + } - if (addNewLineAroundAttributes || addNewLineBeforeEachAttribute) + if (addNewLineAroundAttributes || addNewLineBeforeEachAttribute) this.AppendText("\r\n", null); - } - - private bool MatchesAttributesDisplayKind(IAttributeInstance? attribute, AttributesDisplayKind displayKind) { - if (attribute is null) - return false; - - return displayKind switch { - AttributesDisplayKind.Never - => false, - AttributesDisplayKind.NullnessAnnotations - => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.NotNullAttributeShortName) - || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.CanBeNullAttributeShortName), - AttributesDisplayKind.NullnessAndItemNullnessAnnotations - => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.NotNullAttributeShortName) - || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.CanBeNullAttributeShortName) - || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, ContainerElementNullnessProvider.ItemNotNullAttributeShortName) - || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, ContainerElementNullnessProvider.ItemCanBeNullAttributeShortName), - AttributesDisplayKind.AllAnnotations - => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, attribute.GetClrName().ShortName), - AttributesDisplayKind.Always - => true, - _ - => false - }; - } - - [Pure] - private static bool ShouldAddNewLineBeforeEachAttribute(AttributesFormattingMode formattingMode, int attributeCount) - => formattingMode switch { - AttributesFormattingMode.AllOnCurrentLine => false, - AttributesFormattingMode.AllOnNewLine => false, - AttributesFormattingMode.OnePerLine => true, - AttributesFormattingMode.OnePerLineIfMultiple => attributeCount > 1, - _ => false - }; - - private void AppendAttribute(IAttributeInstance attribute, bool showArguments, Context context) { + } + + private bool MatchesAttributesDisplayKind(IAttributeInstance? attribute, AttributesDisplayKind displayKind) { + if (attribute is null) + return false; + + return displayKind switch { + AttributesDisplayKind.Never + => false, + AttributesDisplayKind.NullnessAnnotations + => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.NotNullAttributeShortName) + || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.CanBeNullAttributeShortName), + AttributesDisplayKind.NullnessAndItemNullnessAnnotations + => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.NotNullAttributeShortName) + || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, NullnessProvider.CanBeNullAttributeShortName) + || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, ContainerElementNullnessProvider.ItemNotNullAttributeShortName) + || this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, ContainerElementNullnessProvider.ItemCanBeNullAttributeShortName), + AttributesDisplayKind.AllAnnotations + => this._codeAnnotationsConfiguration.IsAnnotationAttribute(attribute, attribute.GetClrName().ShortName), + AttributesDisplayKind.Always + => true, + _ + => false + }; + } + + [Pure] + private static bool ShouldAddNewLineBeforeEachAttribute(AttributesFormattingMode formattingMode, int attributeCount) + => formattingMode switch { + AttributesFormattingMode.AllOnCurrentLine => false, + AttributesFormattingMode.AllOnNewLine => false, + AttributesFormattingMode.OnePerLine => true, + AttributesFormattingMode.OnePerLineIfMultiple => attributeCount > 1, + _ => false + }; + + private void AppendAttribute(IAttributeInstance attribute, bool showArguments, Context context) { this.AppendText("[", null); this.AppendText(attribute.GetClrName().ShortName.TrimFromEnd(AttributeInstanceExtensions.ATTRIBUTE_SUFFIX, StringComparison.Ordinal), this._highlighterIdProvider.Class); - if (showArguments) { + if (showArguments) { - bool hasParenthesis = false; - foreach (AttributeValue attributeValue in attribute.PositionParameters()) { - if (hasParenthesis) + bool hasParenthesis = false; + foreach (AttributeValue attributeValue in attribute.PositionParameters()) { + if (hasParenthesis) this.AppendText(", ", null); - else { + else { this.AppendText("(", null); - hasParenthesis = true; - } + hasParenthesis = true; + } this.AppendAttributeValue(attributeValue, context); - } + } - foreach (Pair pair in attribute.NamedParameters()) { - if (hasParenthesis) + foreach (Pair pair in attribute.NamedParameters()) { + if (hasParenthesis) this.AppendText(", ", null); - else { + else { this.AppendText("(", null); - hasParenthesis = true; - } + hasParenthesis = true; + } this.AppendText(pair.First, this._highlighterIdProvider.Property); this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendAttributeValue(pair.Second, context); - } + } - if (hasParenthesis) + if (hasParenthesis) this.AppendText(")", null); - } + } this.AppendText("] ", null); - } + } - private void AppendAttributeValue(AttributeValue attributeValue, Context context) { - if (attributeValue.IsArray) { + private void AppendAttributeValue(AttributeValue attributeValue, Context context) { + if (attributeValue.IsArray) { this.AppendText("new", this._highlighterIdProvider.Keyword); this.AppendText(" { ", null); - if (attributeValue.ArrayValue is { } arrayValue) { - for (int i = 0; i < arrayValue.Length; ++i) { - if (i > 0) + if (attributeValue.ArrayValue is { } arrayValue) { + for (int i = 0; i < arrayValue.Length; ++i) { + if (i > 0) this.AppendText(", ", null); this.AppendAttributeValue(arrayValue[i], context); - } - } + } + } this.AppendText(" }", null); - return; - } + return; + } - if (attributeValue.IsType) { + if (attributeValue.IsType) { this.AppendText("typeof", this._highlighterIdProvider.Keyword); this.AppendText("(", null); - if (attributeValue.TypeValue is { } typeValue) + if (attributeValue.TypeValue is { } typeValue) this.AppendType(typeValue, QualifierDisplays.None, false, context); this.AppendText(")", null); - return; - } + return; + } this.AppendConstantValue(attributeValue.ConstantValue, false); - } - - private static bool ShouldShowParameters(IDeclaredElement element) { - if (element.IsDestructor() || CSharpDeclaredElementUtil.IsProperty(element)) - return false; - - return element is not IAccessor { Kind: AccessorKind.GETTER } accessor - || !CSharpDeclaredElementUtil.IsProperty(accessor.OwnerMember); - } - - private static bool IsIndexer(IDeclaredElement? element) { - if (element is IAccessor accessor) - element = accessor.OwnerMember; - - return element.IsCSharpIndexer() || element.IsCSharpIndexedProperty(); - } - - private static string? GetParameterSpecialModifier(IParameter parameter) { - if (parameter.IsParameterArray) - return "params "; - if (parameter.IsExtensionFirstParameter()) - return "this "; - return null; - } - - private static string? GetParameterKindModifier(IParameter parameter) - => parameter.Kind switch { - ParameterKind.REFERENCE => "ref ", - ParameterKind.OUTPUT => "out ", - ParameterKind.INPUT => "in ", - _ => null - }; - - private void AppendDefaultValue(IParameter parameter, ISubstitution substitution, Context context) { - if (!parameter.IsOptional) - return; - - DefaultValue defaultValue = parameter.GetDefaultValue().Substitute(substitution).Normalize(); - if (defaultValue.IsBadValue) { + } + + private static bool ShouldShowParameters(IDeclaredElement element) { + if (element.IsDestructor() || CSharpDeclaredElementUtil.IsProperty(element)) + return false; + + return element is not IAccessor { Kind: AccessorKind.GETTER } accessor + || !CSharpDeclaredElementUtil.IsProperty(accessor.OwnerMember); + } + + private static bool IsIndexer(IDeclaredElement? element) { + if (element is IAccessor accessor) + element = accessor.OwnerMember; + + return element.IsCSharpIndexer() || element.IsCSharpIndexedProperty(); + } + + private static string? GetParameterSpecialModifier(IParameter parameter) { + if (parameter.IsParameterArray) + return "params "; + if (parameter.IsExtensionFirstParameter()) + return "this "; + return null; + } + + private static string? GetParameterKindModifier(IParameter parameter) + => parameter.Kind switch { + ParameterKind.REFERENCE => "ref ", + ParameterKind.OUTPUT => "out ", + ParameterKind.INPUT => "in ", + _ => null + }; + + private void AppendDefaultValue(IParameter parameter, ISubstitution substitution, Context context) { + if (!parameter.IsOptional) + return; + + DefaultValue defaultValue = parameter.GetDefaultValue().Substitute(substitution).Normalize(); + if (defaultValue.IsBadValue) { this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendText("bad value", null); - return; - } + return; + } - if (defaultValue.IsConstant) { + if (defaultValue.IsConstant) { this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendConstantValue(defaultValue.ConstantValue, false); - return; - } + return; + } - if (defaultValue.DefaultTypeValue is not { } defaultType) - return; + if (defaultValue.DefaultTypeValue is not { } defaultType) + return; - if (defaultType.IsNullable() || defaultType.IsReferenceType()) { + if (defaultType.IsNullable() || defaultType.IsReferenceType()) { this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendText("null", this._highlighterIdProvider.Keyword); - return; - } + return; + } this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendText("default", this._highlighterIdProvider.Keyword); this.AppendText("(", null); this.AppendType(defaultType, QualifierDisplays.Parameters, true, context); this.AppendText(")", null); - } + } - private void AppendConstantValueOwner(IConstantValueOwner constantValueOwner) { - ConstantValue constantValue = constantValueOwner.ConstantValue; - if (constantValue.IsBadValue()) - return; + private void AppendConstantValueOwner(IConstantValueOwner constantValueOwner) { + ConstantValue constantValue = constantValueOwner.ConstantValue; + if (constantValue.IsBadValue()) + return; this.AppendText(" = ", this._highlighterIdProvider.Operator); this.AppendConstantValue(constantValue, true); - } + } - private void AppendConstantValue(ConstantValue constantValue, bool treatEnumAsIntegral) { - if (constantValue.IsBadValue()) { + private void AppendConstantValue(ConstantValue constantValue, bool treatEnumAsIntegral) { + if (constantValue.IsBadValue()) { this.AppendText("bad value", null); - return; - } + return; + } - if (constantValue.Type.GetEnumType() is { } enumType) { - if (treatEnumAsIntegral) { + if (constantValue.Type.GetEnumType() is { } enumType) { + if (treatEnumAsIntegral) { this.AppendText(constantValue.IsEnum() ? constantValue.ToIntUnchecked().ToString() : constantValue.StringValue ?? String.Empty, this._highlighterIdProvider.Number); - return; - } - if (this.AppendEnumValue(constantValue, enumType)) - return; - } - - string presentation = constantValue.GetPresentation(CSharpLanguage.Instance, TypePresentationStyle.Default).Text; - if (CSharpLexer.IsKeyword(presentation)) { + return; + } + if (this.AppendEnumValue(constantValue, enumType)) + return; + } + + string presentation = constantValue.GetPresentation(CSharpLanguage.Instance, TypePresentationStyle.Default).Text; + if (CSharpLexer.IsKeyword(presentation)) { this.AppendText(presentation, this._highlighterIdProvider.Keyword); - return; - } + return; + } - IType? type = constantValue.Type; - if (type.IsNullable()) - type = type.GetNullableUnderlyingType(); + IType? type = constantValue.Type; + if (type.IsNullable()) + type = type.GetNullableUnderlyingType(); - if (type is null) { + if (type is null) { this.AppendText(presentation, null); - return; - } + return; + } - if (type.IsString()) + if (type.IsString()) this.AppendText(presentation, this._highlighterIdProvider.String); - else if (type.IsChar()) + else if (type.IsChar()) this.AppendText(presentation, this._highlighterIdProvider.String); - else if (type.IsPredefinedNumeric()) + else if (type.IsPredefinedNumeric()) this.AppendText(presentation, this._highlighterIdProvider.Number); - else + else this.AppendText(presentation, null); - } + } - private bool AppendEnumValue(ConstantValue constantValue, IEnum enumType) { - IList fields = CSharpEnumUtil.CalculateEnumMembers(constantValue, enumType); - if (fields.Count == 0) - return false; + private bool AppendEnumValue(ConstantValue constantValue, IEnum enumType) { + IList fields = CSharpEnumUtil.CalculateEnumMembers(constantValue, enumType); + if (fields.Count == 0) + return false; - string typeHighlighterId = this._highlighterIdProvider.Enum; - string valueHighlighterId = this._highlighterIdProvider.Constant; + string typeHighlighterId = this._highlighterIdProvider.Enum; + string valueHighlighterId = this._highlighterIdProvider.Constant; - var orderedFields = fields.OrderBy(f => f.ShortName); - bool addSeparator = false; + var orderedFields = fields.OrderBy(f => f.ShortName); + bool addSeparator = false; - foreach (IField orderedField in orderedFields) { - if (addSeparator) + foreach (IField orderedField in orderedFields) { + if (addSeparator) this.AppendText(" | ", this._highlighterIdProvider.Operator); this.AppendText(enumType.ShortName, typeHighlighterId); this.AppendText(".", this._highlighterIdProvider.Operator); this.AppendText(orderedField.ShortName, valueHighlighterId); - addSeparator = true; - } - return true; - } + addSeparator = true; + } + return true; + } - private void AppendAccessors(IProperty property, Context context) { - IAccessor? getter = property.Getter; - IAccessor? setter = property.Setter; - if (getter is null && setter is null) - return; + private void AppendAccessors(IProperty property, Context context) { + IAccessor? getter = property.Getter; + IAccessor? setter = property.Setter; + if (getter is null && setter is null) + return; this.AppendText(" { ", null); - AccessRights propertyAccessRights = property.GetAccessRights(); - if (getter is not null) + AccessRights propertyAccessRights = property.GetAccessRights(); + if (getter is not null) this.AppendAccessor(getter, "get", propertyAccessRights, context); - if (setter is not null) + if (setter is not null) this.AppendAccessor(setter, setter.IsInitOnly ? "init" : "set", propertyAccessRights, context); this.AppendText("}", null); - } + } - private void AppendAccessor(IAccessor accessor, string accessorName, AccessRights propertyAccessRights, Context context) { - if (context.Options.ShowAccessRights) { - AccessRights accessorAccessRights = accessor.GetAccessRights(); - if (accessorAccessRights != propertyAccessRights) + private void AppendAccessor(IAccessor accessor, string accessorName, AccessRights propertyAccessRights, Context context) { + if (context.Options.ShowAccessRights) { + AccessRights accessorAccessRights = accessor.GetAccessRights(); + if (accessorAccessRights != propertyAccessRights) this.AppendAccessRights(accessorAccessRights, true); - } + } this.AppendText(accessorName, this._highlighterIdProvider.Accessor); this.AppendText("; ", null); - } + } - public void AppendPresentableNode(ITreeNode treeNode, PresenterOptions options) { - if (treeNode is ILiteralExpression literalExpression) + public void AppendPresentableNode(ITreeNode treeNode, PresenterOptions options) { + if (treeNode is ILiteralExpression literalExpression) this.AppendLiteralExpression(literalExpression, options); - else if (treeNode is ITupleTypeComponent tupleTypeComponent) + else if (treeNode is ITupleTypeComponent tupleTypeComponent) this.AppendTupleTypeComponent(tupleTypeComponent, options); - } + } - private void AppendLiteralExpression(ILiteralExpression literalExpression, PresenterOptions options) { - var context = new Context(options, null, literalExpression); + private void AppendLiteralExpression(ILiteralExpression literalExpression, PresenterOptions options) { + var context = new Context(options, null, literalExpression); - if (options.ShowElementKind != ElementKindDisplay.None) + if (options.ShowElementKind != ElementKindDisplay.None) this.AppendElementKind("literal", options.ShowElementKind == ElementKindDisplay.Stylized); - if (options.ShowElementType != ElementTypeDisplay.None) + if (options.ShowElementType != ElementTypeDisplay.None) this.AppendType(literalExpression.Type(), QualifierDisplays.ElementType, true, context); - if (options.ShowConstantValue) + if (options.ShowConstantValue) this.AppendConstantValueOwner(literalExpression); - } + } - private void AppendTupleTypeComponent(ITupleTypeComponent tupleTypeComponent, PresenterOptions options) { - if (tupleTypeComponent.Parent is not ITupleTypeComponentList tupleComponentList) - return; + private void AppendTupleTypeComponent(ITupleTypeComponent tupleTypeComponent, PresenterOptions options) { + if (tupleTypeComponent.Parent is not ITupleTypeComponentList tupleComponentList) + return; this.AppendElementKind("tuple component", options.ShowElementKind == ElementKindDisplay.Stylized); this.AppendText("(", null); - var context = new Context(options, null, tupleTypeComponent); - var components = tupleComponentList.Components; - int componentCount = components.Count; - for (int i = 0; i < componentCount; ++i) { - if (i > 0) + var context = new Context(options, null, tupleTypeComponent); + var components = tupleComponentList.Components; + int componentCount = components.Count; + for (int i = 0; i < componentCount; ++i) { + if (i > 0) this.AppendText(", ", null); - ITupleTypeComponent component = components[i]; - if (component is not null) { + ITupleTypeComponent component = components[i]; + if (component is not null) { this.AppendType(CSharpTypeFactory.CreateType(component.TypeUsage), QualifierDisplays.None, true, context); - if (component.NameIdentifier is { } nameIdentifier) { + if (component.NameIdentifier is { } nameIdentifier) { this.AppendText(" ", null); this.AppendText(nameIdentifier.Name, this._highlighterIdProvider.TupleComponentName); - } - } - } + } + } + } this.AppendText(")", null); - if (tupleTypeComponent.NameIdentifier is { } componentNameIdentifier) { + if (tupleTypeComponent.NameIdentifier is { } componentNameIdentifier) { this.AppendText(".", this._highlighterIdProvider.Operator); this.AppendText(componentNameIdentifier.Name, this._highlighterIdProvider.TupleComponentName); - } - } - - public CSharpColorizer( - RichText richText, - TextStyleHighlighterManager textStyleHighlighterManager, - CodeAnnotationsConfiguration codeAnnotationsConfiguration, - HighlighterIdProvider highlighterIdProvider) { + } + } + + public CSharpColorizer( + RichText richText, + TextStyleHighlighterManager textStyleHighlighterManager, + CodeAnnotationsConfiguration codeAnnotationsConfiguration, + HighlighterIdProvider highlighterIdProvider) { this._richText = richText; this._textStyleHighlighterManager = textStyleHighlighterManager; this._codeAnnotationsConfiguration = codeAnnotationsConfiguration; this._highlighterIdProvider = highlighterIdProvider; - } + } - } + } } \ No newline at end of file diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/Highlightings/CSharp/RoslynDiagnosticHighlightingEnhancer.cs b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/Highlightings/CSharp/RoslynDiagnosticHighlightingEnhancer.cs index 46c59dd..3166e0e 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/Highlightings/CSharp/RoslynDiagnosticHighlightingEnhancer.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/Highlightings/CSharp/RoslynDiagnosticHighlightingEnhancer.cs @@ -13,7 +13,7 @@ namespace GammaJul.ReSharper.EnhancedTooltip.Presentation.Highlightings.CSharp { internal sealed class RoslynDiagnosticHighlightingEnhancer : CSharpHighlightingEnhancer { protected override void AppendTooltip(RoslynDiagnosticsDaemonProcess.RoslynDiagnosticHighlighting highlighting, CSharpColorizer colorizer) { - var originalTooltip = highlighting.GetDynamicFieldOrProperty("ToolTip").ToString(); + var originalTooltip = highlighting.GetDynamicFieldOrProperty("ToolTip")?.ToString() ?? highlighting.GetDynamicFieldOrProperty("ErrorStripeToolTip")?.ToString() ?? String.Empty; var destinationTooltip = originalTooltip.Replace(highlighting.CompilerId + ": ", String.Empty); colorizer.AppendPlainText(destinationTooltip); colorizer.AppendPlainText(" [Roslyn Rule: "); diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/ParamContent.cs b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/ParamContent.cs index 485e4d6..47b5f31 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/ParamContent.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/ParamContent.cs @@ -1,3 +1,4 @@ +using System; using JetBrains.UI.RichText; namespace GammaJul.ReSharper.EnhancedTooltip.Presentation { @@ -8,8 +9,10 @@ public sealed class ParamContent { public RichText? Description { get; set; } + public Boolean IsTypeParameter { get; set; } + public ParamContent(RichText name) { - Name = name; + this.Name = name; } } diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/UIResources.xaml b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/UIResources.xaml index 4f30c1d..9362669 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/UIResources.xaml +++ b/source/GammaJul.ReSharper.EnhancedTooltip/Presentation/UIResources.xaml @@ -160,7 +160,7 @@ - - + + + + + diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/Properties/AssemblyInfo.cs b/source/GammaJul.ReSharper.EnhancedTooltip/Properties/AssemblyInfo.cs index 1d940dd..a396bda 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/Properties/AssemblyInfo.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/Properties/AssemblyInfo.cs @@ -5,8 +5,8 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Julien Lebosquain, Gainedge org")] [assembly: AssemblyProduct("GammaJul.ReSharper.EnhancedTooltip")] -[assembly: AssemblyCopyright("Copyright © 2013-2023 Julien Lebosquain, Gainedge org")] +[assembly: AssemblyCopyright("Copyright © 2013-2024 Julien Lebosquain, Gainedge org")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("3.25.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.26.2.4")] \ No newline at end of file diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/MainQuickInfoSource.cs b/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/MainQuickInfoSource.cs index 38e1e13..5c19ef6 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/MainQuickInfoSource.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/MainQuickInfoSource.cs @@ -250,7 +250,7 @@ private static IEnumerable GetTooltipContents( IPsiSourceFile? sourceFile = solution is null ? null : document.GetPsiSourceFile(solution); Severity severity = HighlightingSettingsManager.Instance.GetSeverity(highlighting, highlighting.GetType(), sourceFile, settings); - if (MainQuickInfoSource.TryCreateIssueContent(highlighting, range, highlighter.TryGetTooltip(HighlighterTooltipKind.TextEditor), severity, settings, solution) is { } issueContent) { + if (MainQuickInfoSource.TryCreateIssueContent(highlighting, range, highlighter.TryGetTooltip(HighlighterTooltipKind.TextEditor) ?? highlighter.TryGetTooltip(HighlighterTooltipKind.ErrorStripe), severity, settings, solution) is { } issueContent) { yield return issueContent; yield break; } @@ -269,7 +269,7 @@ private static IEnumerable GetTooltipContents( } } - if (MainQuickInfoSource.TryCreateMiscContent(highlighter.TryGetTooltip(HighlighterTooltipKind.TextEditor), range) is { } miscContent) + if (MainQuickInfoSource.TryCreateMiscContent(highlighter.TryGetTooltip(HighlighterTooltipKind.TextEditor) ?? highlighter.TryGetTooltip(HighlighterTooltipKind.ErrorStripe), range) is { } miscContent) yield return miscContent; } diff --git a/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/XmlDocRichTextPresenterEx.cs b/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/XmlDocRichTextPresenterEx.cs index 7033710..a1e2798 100644 --- a/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/XmlDocRichTextPresenterEx.cs +++ b/source/GammaJul.ReSharper.EnhancedTooltip/VisualStudio/XmlDocRichTextPresenterEx.cs @@ -12,6 +12,7 @@ using JetBrains.UI.RichText; using JetBrains.Util; using JetBrains.Util.Media; +using JetBrains.Util.NetFX.Media.Colors; namespace GammaJul.ReSharper.EnhancedTooltip.VisualStudio {