Skip to content

Commit e2d7eed

Browse files
committed
Unify the naming of request and notification types
Request types should always have the suffix Request and notifications should end with Notification. Also moved all request and notification types into separate folders to reduce the number of files in the LanguageServerProtocol folder.
1 parent 79e312b commit e2d7eed

File tree

75 files changed

+290
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+290
-240
lines changed

Sources/LanguageServerProtocol/CMakeLists.txt

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,72 @@
11
add_library(LanguageServerProtocol
2-
ApplyEdit.swift
3-
CancelRequest.swift
42
Cancellation.swift
5-
ClientCapabilities.swift
6-
CodeAction.swift
7-
CodeActionKind.swift
8-
ColorPresentationRequest.swift
9-
Command.swift
10-
Completion.swift
11-
CompletionItem.swift
12-
CompletionItemKind.swift
13-
Configuration.swift
143
Connection.swift
154
CustomCodable.swift
16-
DefinitionRequest.swift
17-
Diagnostic.swift
18-
DocumentColor.swift
19-
DocumentHighlight.swift
20-
DocumentSymbol.swift
21-
DocumentURI.swift
225
Error.swift
23-
ExecuteCommand.swift
24-
FoldingRange.swift
25-
FoldingRangeKind.swift
26-
Formatting.swift
27-
Hover.swift
28-
ImplementationRequest.swift
29-
InitializeRequest.swift
30-
LSPAny.swift
31-
Language.swift
32-
Location.swift
33-
LogMessage.swift
34-
MarkupContent.swift
356
Message.swift
367
MessageRegistry.swift
378
Messages.swift
38-
PollIndex.swift
39-
Position.swift
409
PositionRange.swift
41-
PublishDiagnostics.swift
42-
ReferencesRequest.swift
4310
Request.swift
4411
RequestID.swift
45-
ServerCapabilities.swift
46-
ShowMessageRequest.swift
47-
Shutdown.swift
48-
SymbolInfo.swift
49-
SymbolKind.swift
50-
TextDocumentContentChangeEvent.swift
51-
TextDocumentEdit.swift
52-
TextDocumentIdentifier.swift
53-
TextDocumentItem.swift
54-
TextDocumentSaveReason.swift
55-
TextEdit.swift
56-
TextSynchronization.swift
57-
VersionedTextDocumentIdentifier.swift
58-
WindowMessageType.swift
59-
WorkspaceEdit.swift
60-
WorkspaceFolder.swift
61-
WorkspaceFolders.swift
62-
WorkspaceSettings.swift
63-
WorkspaceSymbols.swift)
12+
Notifications/CancelRequestNotification.swift
13+
Notifications/ConfigurationNotification.swift
14+
Notifications/DidChangeWorkspaceFoldersNotification.swift
15+
Notifications/ExitNotification.swift
16+
Notifications/InitializedNotification.swift
17+
Notifications/LogMessageNotification.swift
18+
Notifications/PublishDiagnosticsNotification.swift
19+
Notifications/ShowMessageNotification.swift
20+
Notifications/TextSynchronizationNotifications.swift
21+
Requests/ApplyEditRequest.swift
22+
Requests/CodeActionRequest.swift
23+
Requests/ColorPresentationRequest.swift
24+
Requests/CompletionRequest.swift
25+
Requests/DefinitionRequest.swift
26+
Requests/DocumentColorRequest.swift
27+
Requests/DocumentHighlightRequest.swift
28+
Requests/DocumentSymbolRequest.swift
29+
Requests/ExecuteCommandRequest.swift
30+
Requests/FoldingRangeRequest.swift
31+
Requests/FormattingRequests.swift
32+
Requests/HoverRequest.swift
33+
Requests/ImplementationRequest.swift
34+
Requests/InitializeRequest.swift
35+
Requests/PollIndexRequest.swift
36+
Requests/ReferencesRequest.swift
37+
Requests/ShowMessageRequest.swift
38+
Requests/ShutdownRequest.swift
39+
Requests/SymbolInfoRequest.swift
40+
Requests/WorkspaceFoldersRequest.swift
41+
Requests/WorkspaceSymbolsRequest.swift
42+
SupportTypes/ClientCapabilities.swift
43+
SupportTypes/CodeActionKind.swift
44+
SupportTypes/Command.swift
45+
SupportTypes/CompletionItem.swift
46+
SupportTypes/CompletionItemKind.swift
47+
SupportTypes/Diagnostic.swift
48+
SupportTypes/DocumentURI.swift
49+
SupportTypes/FoldingRangeKind.swift
50+
SupportTypes/Language.swift
51+
SupportTypes/Location.swift
52+
SupportTypes/LocationLink.swift
53+
SupportTypes/LocationsOrLocationLinksResponse.swift
54+
SupportTypes/LSPAny.swift
55+
SupportTypes/MarkupContent.swift
56+
SupportTypes/Position.swift
57+
SupportTypes/ServerCapabilities.swift
58+
SupportTypes/SymbolKind.swift
59+
SupportTypes/TextDocumentContentChangeEvent.swift
60+
SupportTypes/TextDocumentEdit.swift
61+
SupportTypes/TextDocumentIdentifier.swift
62+
SupportTypes/TextDocumentItem.swift
63+
SupportTypes/TextDocumentSaveReason.swift
64+
SupportTypes/TextEdit.swift
65+
SupportTypes/VersionedTextDocumentIdentifier.swift
66+
SupportTypes/WindowMessageType.swift
67+
SupportTypes/WorkspaceEdit.swift
68+
SupportTypes/WorkspaceFolder.swift
69+
SupportTypes/WorkspaceSettings.swift)
6470
set_target_properties(LanguageServerProtocol PROPERTIES
6571
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
6672
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)

Sources/LanguageServerProtocol/Messages.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public let builtinRequests: [_RequestType.Type] = [
2626
ImplementationRequest.self,
2727
ReferencesRequest.self,
2828
DocumentHighlightRequest.self,
29-
DocumentFormatting.self,
30-
DocumentRangeFormatting.self,
31-
DocumentOnTypeFormatting.self,
29+
DocumentFormattingRequest.self,
30+
DocumentRangeFormattingRequest.self,
31+
DocumentOnTypeFormattingRequest.self,
3232
FoldingRangeRequest.self,
3333
DocumentSymbolRequest.self,
3434
DocumentColorRequest.self,
@@ -39,7 +39,7 @@ public let builtinRequests: [_RequestType.Type] = [
3939
// MARK: LSP Extension Requests
4040

4141
SymbolInfoRequest.self,
42-
PollIndex.self,
42+
PollIndexRequest.self,
4343
]
4444

4545
/// The set of known notifications.
@@ -49,17 +49,17 @@ public let builtinRequests: [_RequestType.Type] = [
4949
/// `MessageRegistry._register()` which allows you to avoid bloating the real server implementation.
5050
public let builtinNotifications: [NotificationType.Type] = [
5151
InitializedNotification.self,
52-
Exit.self,
53-
CancelRequest.self,
54-
LogMessage.self,
55-
DidChangeConfiguration.self,
56-
DidChangeWorkspaceFolders.self,
57-
DidOpenTextDocument.self,
58-
DidCloseTextDocument.self,
59-
DidChangeTextDocument.self,
60-
DidSaveTextDocument.self,
61-
WillSaveTextDocument.self,
62-
PublishDiagnostics.self,
52+
ExitNotification.self,
53+
CancelRequestNotification.self,
54+
LogMessageNotification.self,
55+
DidChangeConfigurationNotification.self,
56+
DidChangeWorkspaceFoldersNotification.self,
57+
DidOpenTextDocumentNotification.self,
58+
DidCloseTextDocumentNotification.self,
59+
DidChangeTextDocumentNotification.self,
60+
DidSaveTextDocumentNotification.self,
61+
WillSaveTextDocumentNotification.self,
62+
PublishDiagnosticsNotification.self,
6363
]
6464

6565
// MARK: Miscellaneous Message Types

Sources/LanguageServerProtocol/CancelRequest.swift renamed to Sources/LanguageServerProtocol/Notifications/CancelRequestNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// As with any `$` requests, the server is free to ignore this notification.
1919
///
2020
/// - Parameter id: The request to cancel.
21-
public struct CancelRequest: NotificationType, Hashable {
21+
public struct CancelRequestNotification: NotificationType, Hashable {
2222
public static let method: String = "$/cancelRequest"
2323

2424
/// The request to cancel.

Sources/LanguageServerProtocol/Configuration.swift renamed to Sources/LanguageServerProtocol/Notifications/ConfigurationNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// - Note: the format of the settings is implementation-defined.
1616
///
1717
/// - Parameter settings: The changed workspace settings.
18-
public struct DidChangeConfiguration: NotificationType {
18+
public struct DidChangeConfigurationNotification: NotificationType {
1919
public static let method: String = "workspace/didChangeConfiguration"
2020

2121
/// The changed workspace settings.

Sources/LanguageServerProtocol/WorkspaceFolders.swift renamed to Sources/LanguageServerProtocol/Notifications/DidChangeWorkspaceFoldersNotification.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
/// Request from the server for the set of currently open workspace folders.
14-
///
15-
///
16-
/// Clients that support workspace folders should set the `workspaceFolders` client capability.
17-
///
18-
/// - Returns: The set of currently open workspace folders. Returns nil if only a single file is
19-
/// open. Returns an empty array if a workspace is open but no folders are configured.
20-
public struct WorkspaceFoldersRequest: RequestType, Hashable {
21-
public static let method: String = "workspace/workspaceFolders"
22-
public typealias Response = [WorkspaceFolder]?
23-
}
24-
2513
/// Notification from the client that the set of open workspace folders has changed.
2614
///
2715
/// - Parameter event: The set of changes.
2816
///
2917
/// Requires the `workspaceFolders` capability on both the client and server.
30-
public struct DidChangeWorkspaceFolders: NotificationType {
18+
public struct DidChangeWorkspaceFoldersNotification: NotificationType {
3119
public static let method: String = "workspace/didChangeWorkspaceFolders"
3220

3321
/// The set of changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// Notification that the server process should exit.
14+
///
15+
/// This notification will come after the shutdown request finishes.
16+
public struct ExitNotification: NotificationType, Hashable {
17+
public static let method: String = "exit"
18+
public init() { }
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// Notification from the client that its own initialization of the language server has finished.
14+
public struct InitializedNotification: NotificationType, Hashable {
15+
public static let method: String = "initialized"
16+
17+
public init() {}
18+
}

Sources/LanguageServerProtocol/LogMessage.swift renamed to Sources/LanguageServerProtocol/Notifications/LogMessageNotification.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// - Parameters:
1616
/// - type: The kind of log message.
1717
/// - message: The contents of the message.
18-
public struct LogMessage: NotificationType, Hashable {
18+
public struct LogMessageNotification: NotificationType, Hashable {
1919
public static let method: String = "window/logMessage"
2020

2121
/// The kind of log message.
@@ -28,4 +28,4 @@ public struct LogMessage: NotificationType, Hashable {
2828
self.type = type
2929
self.message = message
3030
}
31-
}
31+
}

Sources/LanguageServerProtocol/PublishDiagnostics.swift renamed to Sources/LanguageServerProtocol/Notifications/PublishDiagnosticsNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/// - Parameters:
2525
/// - uri: The document in which the diagnostics should be shown.
2626
/// - diagnostics: The complete list of diagnostics in the document, if any.
27-
public struct PublishDiagnostics: NotificationType, Hashable, Codable {
27+
public struct PublishDiagnosticsNotification: NotificationType, Hashable, Codable {
2828
public static let method: String = "textDocument/publishDiagnostics"
2929

3030
/// The document in which the diagnostics should be shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// Notification from the server containing a message for the client to display.
14+
///
15+
/// - Parameters:
16+
/// - type: The kind of message.
17+
/// - message: The contents of the message.
18+
public struct ShowMessageNotification: NotificationType, Hashable {
19+
public static let method: String = "window/showMessage"
20+
21+
/// The kind of message.
22+
public var type: WindowMessageType
23+
24+
/// The contents of the message.
25+
public var message: String
26+
27+
public init(type: WindowMessageType, message: String) {
28+
self.type = type
29+
self.message = message
30+
}
31+
}

Sources/LanguageServerProtocol/TextSynchronization.swift renamed to Sources/LanguageServerProtocol/Notifications/TextSynchronizationNotifications.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// capability.
2727
///
2828
/// - Parameter textDocument: The document identifier and initial contents.
29-
public struct DidOpenTextDocument: NotificationType, Hashable {
29+
public struct DidOpenTextDocumentNotification: NotificationType, Hashable {
3030
public static let method: String = "textDocument/didOpen"
3131

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

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

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

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

113113
/// The document that was saved.

Sources/LanguageServerProtocol/CodeAction.swift renamed to Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public struct CodeActionContext: Codable, Hashable {
111111
}
112112
}
113113

114-
public struct CodeAction: Codable, Equatable, ResponseType {
114+
public struct CodeAction: Codable, Equatable {
115115

116116
/// A short, human-readable, title for this code action.
117117
public var title: String

Sources/LanguageServerProtocol/DocumentSymbol.swift renamed to Sources/LanguageServerProtocol/Requests/DocumentSymbolRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public enum DocumentSymbolResponse: ResponseType, Hashable {
6262
/// Represents programming constructs like variables, classes, interfaces etc. that appear
6363
/// in a document. Document symbols can be hierarchical and they have two ranges: one that encloses
6464
/// its definition and one that points to its most interesting range, e.g. the range of an identifier.
65-
public struct DocumentSymbol: Hashable, Codable, ResponseType {
65+
public struct DocumentSymbol: Hashable, Codable {
6666

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

0 commit comments

Comments
 (0)