Skip to content

Commit

Permalink
Merge pull request #1025 from OmniSharp/fix-options-capabilities
Browse files Browse the repository at this point in the history
Fix RegistrationOptions and Capabilities
  • Loading branch information
JoeRobich authored Sep 20, 2023
2 parents 381075f + 0cba5ef commit 3c64096
Show file tree
Hide file tree
Showing 31 changed files with 112 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,20 @@ public interface ITextDocumentClientCapabilities : ICapabilitiesBase
///
/// @since 3.17.0
/// </summary>
Supports<InlineValueWorkspaceClientCapabilities?> InlineValue { get; set; }
Supports<InlineValueClientCapabilities?> InlineValue { get; set; }

/// <summary>
/// Capability specific to the `textDocument/inlayHint` request.
///
/// @since 3.17.0
/// </summary>
Supports<InlayHintWorkspaceClientCapabilities?> InlayHint { get; set; }
Supports<InlayHintClientCapabilities?> InlayHint { get; set; }

/// <summary>
/// Capability specific to the diagnostic pull model.
///
/// @since 3.17.0
/// </summary>
Supports<DiagnosticWorkspaceClientCapabilities?> Diagnostic { get; set; }
Supports<DiagnosticClientCapabilities?> Diagnostic { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,20 @@ public class TextDocumentClientCapabilities : CapabilitiesBase, ITextDocumentCli
///
/// @since 3.17.0
/// </summary>
public Supports<InlineValueWorkspaceClientCapabilities?> InlineValue { get; set; }
public Supports<InlineValueClientCapabilities?> InlineValue { get; set; }

/// <summary>
/// Capability specific to the `textDocument/inlayHint` request.
///
/// @since 3.17.0
/// </summary>
public Supports<InlayHintWorkspaceClientCapabilities?> InlayHint { get; set; }
public Supports<InlayHintClientCapabilities?> InlayHint { get; set; }

/// <summary>
/// Capability specific to the diagnostic pull model.
///
/// @since 3.17.0
/// </summary>
public Supports<DiagnosticWorkspaceClientCapabilities?> Diagnostic { get; set; }
public Supports<DiagnosticClientCapabilities?> Diagnostic { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.WorkspaceEdit))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.WorkspaceEdit))]
public class WorkspaceEditCapability : ICapability
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Features/Document/CompletionFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public override void WriteJson(JsonWriter writer, CompletionList? value, JsonSer
var items = result["items"].ToObject<IEnumerable<CompletionItem>>(serializer);
return new CompletionList(items, result["isIncomplete"]?.Value<bool>() ?? false)
{
ItemDefaults = result["itemDefaults"]?.ToObject<CompletionListItemDefaults>()
ItemDefaults = result["itemDefaults"]?.ToObject<CompletionListItemDefaults>(serializer)
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Features/Document/DiagnosticsFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ internal WorkspaceDiagnosticReportPartialResult(WorkspaceDiagnosticReport partia

[GenerateRegistrationOptions(nameof(ServerCapabilities.DiagnosticProvider))]
[RegistrationName(TextDocumentNames.Diagnostics)]
public partial class DiagnosticsRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions
public partial class DiagnosticsRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions, IStaticRegistrationOptions
{
/// <summary>
/// An optional identifier under which the diagnostics are
Expand Down
40 changes: 35 additions & 5 deletions src/Protocol/Features/Document/InlayHintFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;

// ReSharper disable once CheckNamespace
Expand All @@ -26,7 +27,7 @@ namespace Models
GenerateHandlerMethods,
GenerateRequestMethods(typeof(ITextDocumentLanguageClient), typeof(ILanguageClient))
]
[RegistrationOptions(typeof(InlayHintRegistrationOptions)), Capability(typeof(InlayHintWorkspaceClientCapabilities))]
[RegistrationOptions(typeof(InlayHintRegistrationOptions)), Capability(typeof(InlayHintClientCapabilities))]
[Resolver(typeof(InlayHint))]
public partial record InlayHintParams : ITextDocumentIdentifierParams, IWorkDoneProgressParams,
IRequest<InlayHintContainer?>
Expand Down Expand Up @@ -55,7 +56,7 @@ public partial record InlayHintParams : ITextDocumentIdentifierParams, IWorkDone
[GenerateRequestMethods(typeof(ITextDocumentLanguageClient), typeof(ILanguageClient))]
[GenerateTypedData]
[GenerateContainer]
[Capability(typeof(InlayHintWorkspaceClientCapabilities))]
[Capability(typeof(InlayHintClientCapabilities))]
public partial record InlayHint : ICanBeResolved, IRequest<InlayHint>, IDoesNotParticipateInRegistration
{
/// <summary>
Expand Down Expand Up @@ -231,7 +232,7 @@ public override StringOrInlayHintLabelParts ReadJson(
if (reader.TokenType == JsonToken.StartArray)
{
var result = JArray.Load(reader);
return new StringOrInlayHintLabelParts(result.ToObject<Container<InlayHintLabelPart>>());
return new StringOrInlayHintLabelParts(result.ToObject<Container<InlayHintLabelPart>>(serializer));
}

if (reader.TokenType == JsonToken.String)
Expand Down Expand Up @@ -265,10 +266,18 @@ public enum InlayHintKind
Parameter = 2
}

[Parallel]
[Method(WorkspaceNames.InlayHintRefresh, Direction.ServerToClient)]
[GenerateHandler("OmniSharp.Extensions.LanguageServer.Protocol.Workspace")]
[GenerateHandlerMethods]
[GenerateRequestMethods(typeof(IWorkspaceLanguageServer), typeof(ILanguageServer))]
[Capability(typeof(InlayHintWorkspaceClientCapabilities))]
public partial record InlayHintRefreshParams : IRequest;

[GenerateRegistrationOptions(nameof(ServerCapabilities.InlayHintProvider))]
[RegistrationOptionsConverter(typeof(InlayHintRegistrationOptionsConverter))]
[RegistrationName(TextDocumentNames.InlayHint)]
public partial class InlayHintRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions
public partial class InlayHintRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions, IStaticRegistrationOptions
{
/// <summary>
/// The server provides support to resolve additional
Expand Down Expand Up @@ -301,7 +310,7 @@ public override StaticOptions Convert(InlayHintRegistrationOptions source)
namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(TextDocumentClientCapabilities.InlayHint))]
public partial class InlayHintWorkspaceClientCapabilities : DynamicCapability
public partial class InlayHintClientCapabilities : DynamicCapability
{
/// <summary>
/// Indicates which properties a client can resolve lazily on a inlay
Expand All @@ -322,6 +331,27 @@ public class InlayHintCapabilityResolveSupport
/// </summary>
public Container<string> Properties { get; set; }
}

/// <summary>
/// Client workspace capabilities specific to inlay hints.
///
/// @since 3.17.0.
/// </summary>
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.SemanticTokens))]
public class InlayHintWorkspaceClientCapabilities : ICapability
{
/// <summary>
/// Whether the client implementation supports a refresh request sent from
/// the server to the client.
///
/// Note that this event is global and will force the client to refresh all
/// inlay hints currently shown. It should be used with absolute care and
/// is useful for situation where a server for example detects a project wide
/// change that requires such a calculation.
/// </summary>
[Optional]
public bool RefreshSupport { get; set; }
}
}

namespace Document
Expand Down
19 changes: 12 additions & 7 deletions src/Protocol/Features/Document/InlineValueFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Models
GenerateHandlerMethods,
GenerateRequestMethods(typeof(ITextDocumentLanguageClient), typeof(ILanguageClient))
]
[RegistrationOptions(typeof(InlineValueRegistrationOptions)), Capability(typeof(InlineValueWorkspaceClientCapabilities))]
[RegistrationOptions(typeof(InlineValueRegistrationOptions)), Capability(typeof(InlineValueClientCapabilities))]
public partial record InlineValueParams : ITextDocumentIdentifierParams, IWorkDoneProgressParams,
IRequest<Container<InlineValueBase>?>
{
Expand Down Expand Up @@ -69,7 +69,7 @@ public partial record InlineValueContext
[GenerateHandler("OmniSharp.Extensions.LanguageServer.Protocol.Workspace")]
[GenerateHandlerMethods]
[GenerateRequestMethods(typeof(IWorkspaceLanguageServer), typeof(ILanguageServer))]
[Capability(typeof(CodeLensWorkspaceClientCapabilities))]
[Capability(typeof(InlineValueWorkspaceClientCapabilities))]
public partial record InlineValueRefreshParams : IRequest;

[JsonConverter(typeof(Converter))]
Expand Down Expand Up @@ -98,7 +98,7 @@ public override InlineValueBase ReadJson(
{
return new InlineValueText()
{
Range = result["range"]!.ToObject<Range?>()!,
Range = result["range"]!.ToObject<Range?>(serializer)!,
Text = result["text"]!.Value<string>()!
};
}
Expand All @@ -107,15 +107,15 @@ public override InlineValueBase ReadJson(
{
return new InlineValueVariableLookup()
{
Range = result["range"].ToObject<Range>()!,
Range = result["range"].ToObject<Range>(serializer)!,
VariableName = result["variableName"]!.Value<string>()!,
CaseSensitiveLookup = result["caseSensitiveLookup"]?.Value<bool?>() ?? false,
};
}

return new InlineValueEvaluatableExpression()
{
Range = result["range"].ToObject<Range>()!,
Range = result["range"].ToObject<Range>(serializer)!,
Expression = result["expression"]?.Value<string>()
};
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public partial record InlineValueEvaluatableExpression : InlineValueBase

[GenerateRegistrationOptions(nameof(ServerCapabilities.InlineValueProvider))]
[RegistrationName(TextDocumentNames.InlineValue)]
public partial class InlineValueRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions
public partial class InlineValueRegistrationOptions : ITextDocumentRegistrationOptions, IWorkDoneProgressOptions, IStaticRegistrationOptions
{
}
}
Expand All @@ -190,12 +190,17 @@ namespace Server.Capabilities

namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(TextDocumentClientCapabilities.InlineValue))]
public partial class InlineValueClientCapabilities : DynamicCapability
{
}

/// <summary>
/// Client workspace capabilities specific to inline values.
///
/// @since 3.17.0
/// </summary>
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(TextDocumentClientCapabilities.InlineValue))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.InlineValue))]
public partial class InlineValueWorkspaceClientCapabilities : ICapability
{
/// <summary>
Expand Down
13 changes: 8 additions & 5 deletions src/Protocol/Features/Document/SemanticTokensFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,17 @@ public partial class SemanticTokensCapabilityRequestFull
///
/// @since 3.16.0.
/// </summary>
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.SemanticTokens))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.SemanticTokens))]
public class SemanticTokensWorkspaceCapability : ICapability
{
/// <summary>
/// Whether the client implementation supports a refresh request send from
/// the server to the client. This is useful if a server detects a project
/// wide configuration change which requires a re-calculation of all semantic
/// tokens provided by the server issuing the request.
/// Whether the client implementation supports a refresh request sent from
/// the server to the client.
///
/// Note that this event is global and will force the client to refresh all
/// semantic tokens currently shown. It should be used with absolute care
/// and is useful for situation where a server for example detect a project
/// wide change that requires such a calculation.
/// </summary>
[Optional]
public bool RefreshSupport { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial record DidChangeConfigurationParams : IRequest

namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.Configuration))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.Configuration))]
public partial class DidChangeConfigurationCapability : DynamicCapability
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public partial class DidChangeWatchedFilesRegistrationOptions

namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.DidChangeWatchedFiles))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.DidChangeWatchedFiles))]
public partial class DidChangeWatchedFilesCapability : DynamicCapability
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Features/Workspace/ExecuteCommandFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override StaticOptions Convert(ExecuteCommandRegistrationOptions source)

namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.ExecuteCommand))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.ExecuteCommand))]
public class ExecuteCommandCapability : DynamicCapability
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Features/Workspace/WorkspaceSymbolsFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public override StaticOptions Convert(WorkspaceSymbolRegistrationOptions source)

namespace Client.Capabilities
{
[CapabilityKey(nameof(ClientCapabilities.TextDocument), nameof(WorkspaceClientCapabilities.Symbol))]
[CapabilityKey(nameof(ClientCapabilities.Workspace), nameof(WorkspaceClientCapabilities.Symbol))]
public partial class WorkspaceSymbolCapability : DynamicCapability //
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Protocol/Models/RangeOrEditRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public override RangeOrEditRange ReadJson(
var obj = JObject.Load(reader);
if (obj.ContainsKey("insert"))
{
return new RangeOrEditRange(obj.ToObject<EditRange>());
return new RangeOrEditRange(obj.ToObject<EditRange>(serializer));
}

return new RangeOrEditRange(obj.ToObject<Range>());
return new RangeOrEditRange(obj.ToObject<Range>(serializer));
}

public override bool CanRead => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public override CommandOrCodeAction ReadJson(JsonReader reader, Type objectType,
var command = result["command"];
if (command?.Type == JTokenType.String)
{
return new CommandOrCodeAction(result.ToObject<Command>());
return new CommandOrCodeAction(result.ToObject<Command>(serializer));
}

return new CommandOrCodeAction(result.ToObject<CodeAction>());
return new CommandOrCodeAction(result.ToObject<CodeAction>(serializer));
}

public override bool CanRead => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override GlobPattern ReadJson(

if (reader.TokenType == JsonToken.StartObject)
{
return new GlobPattern(JObject.Load(reader).ToObject<RelativePattern>());
return new GlobPattern(JObject.Load(reader).ToObject<RelativePattern>(serializer));
}

return new GlobPattern("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public override LocationOrFileLocation ReadJson(JsonReader reader, Type objectTy
var obj = JObject.Load(reader);
if (obj.ContainsKey("range"))
{
return new LocationOrFileLocation(obj.ToObject<Location>());
return new LocationOrFileLocation(obj.ToObject<Location>(serializer));
}

return new LocationOrFileLocation(obj.ToObject<FileLocation>());
return new LocationOrFileLocation(obj.ToObject<FileLocation>(serializer));
}

public override bool CanRead => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public override LocationOrLocationLink ReadJson(JsonReader reader, Type objectTy
var obj = JObject.Load(reader);
if (obj.ContainsKey("uri"))
{
return new LocationOrLocationLink(obj.ToObject<Location>());
return new LocationOrLocationLink(obj.ToObject<Location>(serializer));
}

return new LocationOrLocationLink(obj.ToObject<LocationLink>());
return new LocationOrLocationLink(obj.ToObject<LocationLink>(serializer));
}

public override bool CanRead => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public override void WriteJson(JsonWriter writer, RangeOrPlaceholderRange? value
{
var obj = (JToken.ReadFrom(reader) as JObject)!;
return obj.ContainsKey("placeholder")
? new RangeOrPlaceholderRange(obj.ToObject<PlaceholderRange>())
? new RangeOrPlaceholderRange(obj.ToObject<PlaceholderRange>(serializer))
: obj.ContainsKey("defaultBehavior")
? new RangeOrPlaceholderRange(
obj.ToObject<RenameDefaultBehavior>()
obj.ToObject<RenameDefaultBehavior>(serializer)
)
: new RangeOrPlaceholderRange(
obj.ToObject<Range>()
obj.ToObject<Range>(serializer)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public override SemanticTokensFullOrDelta ReadJson(
var obj = JObject.Load(reader);
if (obj.ContainsKey("data"))
{
return new SemanticTokensFullOrDelta(obj.ToObject<SemanticTokens>());
return new SemanticTokensFullOrDelta(obj.ToObject<SemanticTokens>(serializer));
}

return new SemanticTokensFullOrDelta(obj.ToObject<SemanticTokensDelta>());
return new SemanticTokensFullOrDelta(obj.ToObject<SemanticTokensDelta>(serializer));
}

public override bool CanRead => true;
Expand Down
Loading

0 comments on commit 3c64096

Please sign in to comment.