Skip to content

Request/Notification types should be discoverable with implict-member-expression #14

@rintaro

Description

@rintaro

Requests should be constructible with implicit member expressions when the expected type is RequestType.

func handle<Request: RequestType>(request: Request) async -> Request.Response { .... }

func test() {
  handle(.<COMPLETE>)
}

To do that,

  • Introduce LSPRequestType that inherits RequestType
  • Every LSP request should inherit LSPRequestType
  • All LSP request handling function should accept LSPRequestType instead of RequestType
  • For every request type, declare extension LSPRequestType where Self == XXXRequest to declare a static factory func

I.e.

public protocol LSPRequestType: RequestType {}
public struct ApplyEditRequest: LSPRequestType, Hashable { ... }

extension LSPRequestType where Self == ApplyEditRequest {
  public static func applyEdit(label: String? = nil, edit: WorkspaceEdit) -> Self {
    .init(label: label, edit: edit)
  }
}

This applies to LSP requests and notifications, and BSP requests and notifications

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions