Skip to content

Commit

Permalink
Update spec details, added helper init functions (#18)
Browse files Browse the repository at this point in the history
* Update spec details, added helper init functions

* Removing LSPRange changes for now

---------

Co-authored-by: Matt <85322+mattmassicotte@users.noreply.github.com>
  • Loading branch information
FastestMolasses and mattmassicotte authored Apr 1, 2024
1 parent 646477f commit ac76fcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/LanguageServerProtocol/General.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextEdit, InsertReplaceEdit>?
public let additionalTextEdits: [TextEdit]?
public let commitCharacters: [String]?
public let command: Command?
Expand All @@ -184,7 +184,7 @@ public struct CompletionItem: Codable, Hashable, Sendable {
filterText: String? = nil,
insertText: String? = nil,
insertTextFormat: InsertTextFormat? = nil,
textEdit: TextEdit? = nil,
textEdit: TwoTypeOption<TextEdit, InsertReplaceEdit>? = nil,
additionalTextEdits: [TextEdit]? = nil,
commitCharacters: [String]? = nil,
command: Command? = nil,
Expand Down
9 changes: 9 additions & 0 deletions Sources/LanguageServerProtocol/TextSynchronization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac76fcc

Please sign in to comment.