From ac76fccf0e981c8e30c5ee4de1b15adc1decd697 Mon Sep 17 00:00:00 2001 From: Abe Date: Mon, 1 Apr 2024 12:00:09 -0700 Subject: [PATCH] Update spec details, added helper init functions (#18) * Update spec details, added helper init functions * Removing LSPRange changes for now --------- Co-authored-by: Matt <85322+mattmassicotte@users.noreply.github.com> --- Sources/LanguageServerProtocol/General.swift | 2 +- .../LanguageFeatures/Completion.swift | 4 ++-- Sources/LanguageServerProtocol/TextSynchronization.swift | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Sources/LanguageServerProtocol/General.swift b/Sources/LanguageServerProtocol/General.swift index 11d0e05..00a58e5 100644 --- a/Sources/LanguageServerProtocol/General.swift +++ b/Sources/LanguageServerProtocol/General.swift @@ -28,7 +28,7 @@ public struct InitializeParams: Codable, Hashable, Sendable { public let workspaceFolders: [WorkspaceFolder]? public init( - processId: Int, + processId: Int?, clientInfo: ClientInfo? = nil, locale: String?, rootPath: String?, diff --git a/Sources/LanguageServerProtocol/LanguageFeatures/Completion.swift b/Sources/LanguageServerProtocol/LanguageFeatures/Completion.swift index d07d475..bffdfe3 100644 --- a/Sources/LanguageServerProtocol/LanguageFeatures/Completion.swift +++ b/Sources/LanguageServerProtocol/LanguageFeatures/Completion.swift @@ -167,7 +167,7 @@ public struct CompletionItem: Codable, Hashable, Sendable { public let filterText: String? public let insertText: String? public let insertTextFormat: InsertTextFormat? - public let textEdit: TextEdit? + public let textEdit: TwoTypeOption? public let additionalTextEdits: [TextEdit]? public let commitCharacters: [String]? public let command: Command? @@ -184,7 +184,7 @@ public struct CompletionItem: Codable, Hashable, Sendable { filterText: String? = nil, insertText: String? = nil, insertTextFormat: InsertTextFormat? = nil, - textEdit: TextEdit? = nil, + textEdit: TwoTypeOption? = nil, additionalTextEdits: [TextEdit]? = nil, commitCharacters: [String]? = nil, command: Command? = nil, diff --git a/Sources/LanguageServerProtocol/TextSynchronization.swift b/Sources/LanguageServerProtocol/TextSynchronization.swift index d4100c6..45c8faa 100644 --- a/Sources/LanguageServerProtocol/TextSynchronization.swift +++ b/Sources/LanguageServerProtocol/TextSynchronization.swift @@ -102,6 +102,15 @@ public struct WillSaveTextDocumentParams: Codable, Hashable, Sendable { public typealias WillSaveWaitUntilResponse = [TextEdit]? +/// A special text edit to provide an insert and a replace operation. +/// +/// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#insertReplaceEdit +public struct InsertReplaceEdit: Codable, Hashable, Sendable { + public let newText: String + public let insert: LSPRange + public let replace: LSPRange +} + public struct TextEdit: Codable, Hashable, Sendable { public let range: LSPRange public let newText: String