Skip to content

Commit

Permalink
Add Kind parameter to InlayHint
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Oct 4, 2023
1 parent 79106f6 commit 27f9c83
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 42 deletions.
6 changes: 6 additions & 0 deletions src/OmniSharp.Abstractions/Models/v1/InlayHints/InlayHint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public sealed record InlayHint
/// </summary>
public string Label { get; set; }

/// <summary>
/// The kind of this hint. Can be omitted in which case the client
/// should fall back to a reasonable default.
/// </summary>
public InlayHintKind? Kind { get; set; }

/// <summary>
/// The tooltip text when you hover over this item.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private static LSPInlayHint ToLSPInlayHint(OmniSharpInlayHint hint)
return new LSPInlayHint()
{
Label = trimmedLabel,
Kind = hint.Kind.HasValue ? ConvertEnum<OmniSharpInlayHintKind, LSPInlayHintKind>(hint.Kind.Value) : null,
Tooltip = hint.Tooltip is not null
? new MarkupContent() { Kind = MarkupKind.Markdown, Value = hint.Tooltip }
: null,
Expand All @@ -93,6 +94,7 @@ private static OmniSharpInlayHint FromLSPInlayHint(LSPInlayHint hint)
return new OmniSharpInlayHint()
{
Label = $"{(hint.PaddingLeft == true ? " " : "")}{hint.Label.String}{(hint.PaddingRight == true ? " " : "")}",
Kind = hint.Kind.HasValue ? ConvertEnum<LSPInlayHintKind, OmniSharpInlayHintKind>(hint.Kind.Value) : null,
Tooltip = hint.Tooltip is not null
? hint.Tooltip.HasMarkupContent
? hint.Tooltip.MarkupContent.Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal class InlayHintService :
private readonly InlineHintCache _cache;
private readonly FormattingOptions _formattingOptions;

private const double ParameterRanking = 0.0;

[ImportingConstructor]
public InlayHintService(OmniSharpWorkspace workspace, FormattingOptions formattingOptions, ILoggerFactory loggerFactory, IOptionsMonitor<OmniSharpOptions> omniSharpOptions)
{
Expand Down Expand Up @@ -140,6 +142,9 @@ public List<InlayHint> MapAndCacheHints(ImmutableArray<OmniSharpInlineHint> rosl
resultList.Add(new InlayHint()
{
Label = string.Concat(hint.DisplayParts),
Kind = hint.Ranking == ParameterRanking
? InlayHintKind.Parameter
: InlayHintKind.Type,
Position = text.GetPointFromPosition(hint.Span.End),
TextEdits = ConvertToTextChanges(hint.ReplacementTextChange, text),
Data = (solutionVersionString, position)
Expand Down
Loading

0 comments on commit 27f9c83

Please sign in to comment.