Skip to content

Unify request naming #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 58 additions & 52 deletions Sources/LanguageServerProtocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,72 @@
add_library(LanguageServerProtocol
ApplyEdit.swift
CancelRequest.swift
Cancellation.swift
ClientCapabilities.swift
CodeAction.swift
CodeActionKind.swift
ColorPresentationRequest.swift
Command.swift
Completion.swift
CompletionItem.swift
CompletionItemKind.swift
Configuration.swift
Connection.swift
CustomCodable.swift
DefinitionRequest.swift
Diagnostic.swift
DocumentColor.swift
DocumentHighlight.swift
DocumentSymbol.swift
DocumentURI.swift
Error.swift
ExecuteCommand.swift
FoldingRange.swift
FoldingRangeKind.swift
Formatting.swift
Hover.swift
ImplementationRequest.swift
InitializeRequest.swift
LSPAny.swift
Language.swift
Location.swift
LogMessage.swift
MarkupContent.swift
Message.swift
MessageRegistry.swift
Messages.swift
PollIndex.swift
Position.swift
PositionRange.swift
PublishDiagnostics.swift
ReferencesRequest.swift
Request.swift
RequestID.swift
ServerCapabilities.swift
ShowMessageRequest.swift
Shutdown.swift
SymbolInfo.swift
SymbolKind.swift
TextDocumentContentChangeEvent.swift
TextDocumentEdit.swift
TextDocumentIdentifier.swift
TextDocumentItem.swift
TextDocumentSaveReason.swift
TextEdit.swift
TextSynchronization.swift
VersionedTextDocumentIdentifier.swift
WindowMessageType.swift
WorkspaceEdit.swift
WorkspaceFolder.swift
WorkspaceFolders.swift
WorkspaceSettings.swift
WorkspaceSymbols.swift)
Notifications/CancelRequestNotification.swift
Notifications/ConfigurationNotification.swift
Notifications/DidChangeWorkspaceFoldersNotification.swift
Notifications/ExitNotification.swift
Notifications/InitializedNotification.swift
Notifications/LogMessageNotification.swift
Notifications/PublishDiagnosticsNotification.swift
Notifications/ShowMessageNotification.swift
Notifications/TextSynchronizationNotifications.swift
Requests/ApplyEditRequest.swift
Requests/CodeActionRequest.swift
Requests/ColorPresentationRequest.swift
Requests/CompletionRequest.swift
Requests/DefinitionRequest.swift
Requests/DocumentColorRequest.swift
Requests/DocumentHighlightRequest.swift
Requests/DocumentSymbolRequest.swift
Requests/ExecuteCommandRequest.swift
Requests/FoldingRangeRequest.swift
Requests/FormattingRequests.swift
Requests/HoverRequest.swift
Requests/ImplementationRequest.swift
Requests/InitializeRequest.swift
Requests/PollIndexRequest.swift
Requests/ReferencesRequest.swift
Requests/ShowMessageRequest.swift
Requests/ShutdownRequest.swift
Requests/SymbolInfoRequest.swift
Requests/WorkspaceFoldersRequest.swift
Requests/WorkspaceSymbolsRequest.swift
SupportTypes/ClientCapabilities.swift
SupportTypes/CodeActionKind.swift
SupportTypes/Command.swift
SupportTypes/CompletionItem.swift
SupportTypes/CompletionItemKind.swift
SupportTypes/Diagnostic.swift
SupportTypes/DocumentURI.swift
SupportTypes/FoldingRangeKind.swift
SupportTypes/Language.swift
SupportTypes/Location.swift
SupportTypes/LocationLink.swift
SupportTypes/LocationsOrLocationLinksResponse.swift
SupportTypes/LSPAny.swift
SupportTypes/MarkupContent.swift
SupportTypes/Position.swift
SupportTypes/ServerCapabilities.swift
SupportTypes/SymbolKind.swift
SupportTypes/TextDocumentContentChangeEvent.swift
SupportTypes/TextDocumentEdit.swift
SupportTypes/TextDocumentIdentifier.swift
SupportTypes/TextDocumentItem.swift
SupportTypes/TextDocumentSaveReason.swift
SupportTypes/TextEdit.swift
SupportTypes/VersionedTextDocumentIdentifier.swift
SupportTypes/WindowMessageType.swift
SupportTypes/WorkspaceEdit.swift
SupportTypes/WorkspaceFolder.swift
SupportTypes/WorkspaceSettings.swift)
set_target_properties(LanguageServerProtocol PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
Expand Down
30 changes: 15 additions & 15 deletions Sources/LanguageServerProtocol/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public let builtinRequests: [_RequestType.Type] = [
ImplementationRequest.self,
ReferencesRequest.self,
DocumentHighlightRequest.self,
DocumentFormatting.self,
DocumentRangeFormatting.self,
DocumentOnTypeFormatting.self,
DocumentFormattingRequest.self,
DocumentRangeFormattingRequest.self,
DocumentOnTypeFormattingRequest.self,
FoldingRangeRequest.self,
DocumentSymbolRequest.self,
DocumentColorRequest.self,
Expand All @@ -39,7 +39,7 @@ public let builtinRequests: [_RequestType.Type] = [
// MARK: LSP Extension Requests

SymbolInfoRequest.self,
PollIndex.self,
PollIndexRequest.self,
]

/// The set of known notifications.
Expand All @@ -49,17 +49,17 @@ public let builtinRequests: [_RequestType.Type] = [
/// `MessageRegistry._register()` which allows you to avoid bloating the real server implementation.
public let builtinNotifications: [NotificationType.Type] = [
InitializedNotification.self,
Exit.self,
CancelRequest.self,
LogMessage.self,
DidChangeConfiguration.self,
DidChangeWorkspaceFolders.self,
DidOpenTextDocument.self,
DidCloseTextDocument.self,
DidChangeTextDocument.self,
DidSaveTextDocument.self,
WillSaveTextDocument.self,
PublishDiagnostics.self,
ExitNotification.self,
CancelRequestNotification.self,
LogMessageNotification.self,
DidChangeConfigurationNotification.self,
DidChangeWorkspaceFoldersNotification.self,
DidOpenTextDocumentNotification.self,
DidCloseTextDocumentNotification.self,
DidChangeTextDocumentNotification.self,
DidSaveTextDocumentNotification.self,
WillSaveTextDocumentNotification.self,
PublishDiagnosticsNotification.self,
]

// MARK: Miscellaneous Message Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/// As with any `$` requests, the server is free to ignore this notification.
///
/// - Parameter id: The request to cancel.
public struct CancelRequest: NotificationType, Hashable {
public struct CancelRequestNotification: NotificationType, Hashable {
public static let method: String = "$/cancelRequest"

/// The request to cancel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Note: the format of the settings is implementation-defined.
///
/// - Parameter settings: The changed workspace settings.
public struct DidChangeConfiguration: NotificationType {
public struct DidChangeConfigurationNotification: NotificationType {
public static let method: String = "workspace/didChangeConfiguration"

/// The changed workspace settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,12 @@
//
//===----------------------------------------------------------------------===//

/// Request from the server for the set of currently open workspace folders.
///
///
/// Clients that support workspace folders should set the `workspaceFolders` client capability.
///
/// - Returns: The set of currently open workspace folders. Returns nil if only a single file is
/// open. Returns an empty array if a workspace is open but no folders are configured.
public struct WorkspaceFoldersRequest: RequestType, Hashable {
public static let method: String = "workspace/workspaceFolders"
public typealias Response = [WorkspaceFolder]?
}

/// Notification from the client that the set of open workspace folders has changed.
///
/// - Parameter event: The set of changes.
///
/// Requires the `workspaceFolders` capability on both the client and server.
public struct DidChangeWorkspaceFolders: NotificationType {
public struct DidChangeWorkspaceFoldersNotification: NotificationType {
public static let method: String = "workspace/didChangeWorkspaceFolders"

/// The set of changes.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Notification that the server process should exit.
///
/// This notification will come after the shutdown request finishes.
public struct ExitNotification: NotificationType, Hashable {
public static let method: String = "exit"
public init() { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Notification from the client that its own initialization of the language server has finished.
public struct InitializedNotification: NotificationType, Hashable {
public static let method: String = "initialized"

public init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Parameters:
/// - type: The kind of log message.
/// - message: The contents of the message.
public struct LogMessage: NotificationType, Hashable {
public struct LogMessageNotification: NotificationType, Hashable {
public static let method: String = "window/logMessage"

/// The kind of log message.
Expand All @@ -28,4 +28,4 @@ public struct LogMessage: NotificationType, Hashable {
self.type = type
self.message = message
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/// - Parameters:
/// - uri: The document in which the diagnostics should be shown.
/// - diagnostics: The complete list of diagnostics in the document, if any.
public struct PublishDiagnostics: NotificationType, Hashable, Codable {
public struct PublishDiagnosticsNotification: NotificationType, Hashable, Codable {
public static let method: String = "textDocument/publishDiagnostics"

/// The document in which the diagnostics should be shown.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Notification from the server containing a message for the client to display.
///
/// - Parameters:
/// - type: The kind of message.
/// - message: The contents of the message.
public struct ShowMessageNotification: NotificationType, Hashable {
public static let method: String = "window/showMessage"

/// The kind of message.
public var type: WindowMessageType

/// The contents of the message.
public var message: String

public init(type: WindowMessageType, message: String) {
self.type = type
self.message = message
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/// capability.
///
/// - Parameter textDocument: The document identifier and initial contents.
public struct DidOpenTextDocument: NotificationType, Hashable {
public struct DidOpenTextDocumentNotification: NotificationType, Hashable {
public static let method: String = "textDocument/didOpen"

/// The document identifier and initial contents.
Expand All @@ -44,7 +44,7 @@ public struct DidOpenTextDocument: NotificationType, Hashable {
/// management of the document contents to disk, if appropriate.
///
/// - Parameter textDocument: The document to close, which must be currently open.
public struct DidCloseTextDocument: NotificationType, Hashable {
public struct DidCloseTextDocumentNotification: NotificationType, Hashable {
public static let method: String = "textDocument/didClose"

/// The document to close, which must be currently open.
Expand All @@ -65,7 +65,7 @@ public struct DidCloseTextDocument: NotificationType, Hashable {
/// - Parameters:
/// - textDocument: The document to change and its current version identifier.
/// - contentChanges: Edits to the document.
public struct DidChangeTextDocument: NotificationType, Hashable {
public struct DidChangeTextDocumentNotification: NotificationType, Hashable {
public static let method: String = "textDocument/didChange"

/// The document to change and its current version identifier.
Expand All @@ -90,7 +90,7 @@ public struct DidChangeTextDocument: NotificationType, Hashable {
/// - reason: Whether this was user-initiated, auto-saved, etc.
///
/// Servers that support willSave should set the `willSave` text document sync option.
public struct WillSaveTextDocument: NotificationType, Hashable {
public struct WillSaveTextDocumentNotification: NotificationType, Hashable {
public static let method: String = "textDocument/willSave"

/// The document that will be saved.
Expand All @@ -107,7 +107,7 @@ public struct WillSaveTextDocument: NotificationType, Hashable {
/// - text: The content of the document at the time of save.
///
/// Servers that support didSave should set the `save` text document sync option.
public struct DidSaveTextDocument: NotificationType, Hashable {
public struct DidSaveTextDocumentNotification: NotificationType, Hashable {
public static let method: String = "textDocument/didSave"

/// The document that was saved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public struct CodeActionContext: Codable, Hashable {
}
}

public struct CodeAction: Codable, Equatable, ResponseType {
public struct CodeAction: Codable, Equatable {

/// A short, human-readable, title for this code action.
public var title: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public enum DocumentSymbolResponse: ResponseType, Hashable {
/// Represents programming constructs like variables, classes, interfaces etc. that appear
/// in a document. Document symbols can be hierarchical and they have two ranges: one that encloses
/// its definition and one that points to its most interesting range, e.g. the range of an identifier.
public struct DocumentSymbol: Hashable, Codable, ResponseType {
public struct DocumentSymbol: Hashable, Codable {

/// The name of this symbol. Will be displayed in the user interface and therefore must not be
/// an empty string or a string only consisting of white spaces.
Expand Down
Loading