Skip to content

Commit

Permalink
Merge pull request #2570 from OmniSharp/jorobich/add-inlayhint-type
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Oct 5, 2023
2 parents 22d97e0 + 914ec87 commit 8fa31b6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 42 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,18 @@
# Changelog
All changes to the project will be documented in this file.

## [1.39.9] - 2023-10-04
* Add Kind parameter to InlayHint (PR: [#2570](https://github.dev/OmniSharp/omnisharp-roslyn/pull/2570))
* Do not include commit characters if the typed span is empty (PR: [#2569](https://github.com/OmniSharp/omnisharp-roslyn/pull/2569))
* Update Roslyn to version 4.9.0-1.23504.3 (PR: [#2567](https://github.com/OmniSharp/omnisharp-roslyn/pull/2567))
* Async diagnostics analyzer work queue (PR: [#2351](https://github.com/OmniSharp/omnisharp-roslyn/pull/2351))
* Add InlayHint implementation to OmniSharp.LSP (PR: [#2566](https://github.com/OmniSharp/omnisharp-roslyn/pull/2566))
* Include the project file name when invoking `dotnet build` (PR: [#2565](https://github.com/OmniSharp/omnisharp-roslyn/pull/2565))
* feat: ignore diagnostics for generated code (PR: [#2509](https://github.com/OmniSharp/omnisharp-roslyn/pull/2509))
* Update documentation to reflect --stdio flag deprecation (#2439) (PR: [#2554](https://github.com/OmniSharp/omnisharp-roslyn/pull/2554))
* Update Roslyn to version 4.8.0-1.23374.10 (PR: [#2555](https://github.com/OmniSharp/omnisharp-roslyn/pull/2555))
* Use double quote when quoting un script path (PR: [#2553](https://github.com/OmniSharp/omnisharp-roslyn/pull/2553))

## [1.39.8] - 2023-07-17
* Use core LSP TokenTypes where possible and validate token names (PR: [#2548](https://github.com/OmniSharp/omnisharp-roslyn/pull/2548))

Expand Down
6 changes: 6 additions & 0 deletions src/OmniSharp.Abstractions/Models/v1/InlayHints/InlayHint.cs
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
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
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

0 comments on commit 8fa31b6

Please sign in to comment.