diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a5bf16cca..e19d6d469 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,3 +28,9 @@ See the [dedicated section][section] on the Swift project website. After you opened your PR, a maintainer will review it and test your changes in CI (*Continuous Integration*) by adding a `@swift-ci Please test` comment on the pull request. Once your PR is approved and CI has passed, the maintainer will merge your pull request. Only contributors with [commit access](https://www.swift.org/contributing/#commit-access) are able to approve pull requests and trigger CI. + +## API Design + +### Public `enum`s + +Enums should generally be marked as `@frozen` or `@nonexhaustive` to allow consistent behavior when switching over them in library-evolution and non-library-evolution builds. The default should be `@frozen` unless we expect to extend the enum without adopting a new LSP or BSP version, eg. because the type is part of an LSP extension. We do not need to anticipate the LSP/BSP specification changing since we plan to release a new major version of swift-tools-protocols when it gets updated to a new LSP or BSP specification version. Custom `CodingKey` enums should always be marked as `@nonexhaustive` because we want to be able to add new members to structs. diff --git a/Sources/BuildServerProtocol/Messages/BuildTargetSourcesRequest.swift b/Sources/BuildServerProtocol/Messages/BuildTargetSourcesRequest.swift index 4342f4719..d8f256efd 100644 --- a/Sources/BuildServerProtocol/Messages/BuildTargetSourcesRequest.swift +++ b/Sources/BuildServerProtocol/Messages/BuildTargetSourcesRequest.swift @@ -94,7 +94,7 @@ public struct SourceItem: Codable, Hashable, Sendable { } } -public enum SourceItemKind: Int, Codable, Hashable, Sendable { +@frozen public enum SourceItemKind: Int, Codable, Hashable, Sendable { /// The source item references a normal file. case file = 1 @@ -120,7 +120,7 @@ public struct SourceItemDataKind: RawRepresentable, Codable, Hashable, Sendable /// **(BSP Extension)** -public enum SourceKitSourceItemKind: String, Codable { +/*@nonexhaustive*/ public enum SourceKitSourceItemKind: String, Codable { /// A source file that belongs to the target case source = "source" diff --git a/Sources/BuildServerProtocol/Messages/OnBuildLogMessageNotification.swift b/Sources/BuildServerProtocol/Messages/OnBuildLogMessageNotification.swift index a3008aae3..94264f4fa 100644 --- a/Sources/BuildServerProtocol/Messages/OnBuildLogMessageNotification.swift +++ b/Sources/BuildServerProtocol/Messages/OnBuildLogMessageNotification.swift @@ -50,7 +50,7 @@ public struct OnBuildLogMessageNotification: BSPNotification { } } -public enum StructuredLogKind: Codable, Hashable, Sendable { +@frozen public enum StructuredLogKind: Codable, Hashable, Sendable { case begin(StructuredLogBegin) case report(StructuredLogReport) case end(StructuredLogEnd) diff --git a/Sources/BuildServerProtocol/Messages/OnBuildTargetDidChangeNotification.swift b/Sources/BuildServerProtocol/Messages/OnBuildTargetDidChangeNotification.swift index 8dc6b3b9a..7737a6dc7 100644 --- a/Sources/BuildServerProtocol/Messages/OnBuildTargetDidChangeNotification.swift +++ b/Sources/BuildServerProtocol/Messages/OnBuildTargetDidChangeNotification.swift @@ -53,7 +53,7 @@ public struct BuildTargetEvent: Codable, Hashable, Sendable { } } -public enum BuildTargetEventKind: Int, Codable, Hashable, Sendable { +@frozen public enum BuildTargetEventKind: Int, Codable, Hashable, Sendable { /// The build target is new. case created = 1 diff --git a/Sources/BuildServerProtocol/Messages/RegisterForChangeNotifications.swift b/Sources/BuildServerProtocol/Messages/RegisterForChangeNotifications.swift index b2d719f28..f8c4d9cfb 100644 --- a/Sources/BuildServerProtocol/Messages/RegisterForChangeNotifications.swift +++ b/Sources/BuildServerProtocol/Messages/RegisterForChangeNotifications.swift @@ -36,7 +36,7 @@ public struct RegisterForChanges: BSPRequest { } } -public enum RegisterAction: String, Hashable, Codable, Sendable { +@frozen public enum RegisterAction: String, Hashable, Codable, Sendable { case register = "register" case unregister = "unregister" } diff --git a/Sources/BuildServerProtocol/Messages/TaskFinishNotification.swift b/Sources/BuildServerProtocol/Messages/TaskFinishNotification.swift index 9504fd137..2ea6c4a91 100644 --- a/Sources/BuildServerProtocol/Messages/TaskFinishNotification.swift +++ b/Sources/BuildServerProtocol/Messages/TaskFinishNotification.swift @@ -165,7 +165,7 @@ public struct TestFinishData: Codable, Hashable, Sendable { } -public enum TestStatus: Int, Codable, Hashable, Sendable { +@frozen public enum TestStatus: Int, Codable, Hashable, Sendable { /// The test passed successfully. case passed = 1 diff --git a/Sources/BuildServerProtocol/SupportTypes/MessageType.swift b/Sources/BuildServerProtocol/SupportTypes/MessageType.swift index 3e18cf2fa..01feca83b 100644 --- a/Sources/BuildServerProtocol/SupportTypes/MessageType.swift +++ b/Sources/BuildServerProtocol/SupportTypes/MessageType.swift @@ -12,7 +12,7 @@ import LanguageServerProtocol -public enum MessageType: Int, Sendable, Codable { +@frozen public enum MessageType: Int, Sendable, Codable { /// An error message. case error = 1 diff --git a/Sources/BuildServerProtocol/SupportTypes/StatusCode.swift b/Sources/BuildServerProtocol/SupportTypes/StatusCode.swift index 109a0be47..b59bee88c 100644 --- a/Sources/BuildServerProtocol/SupportTypes/StatusCode.swift +++ b/Sources/BuildServerProtocol/SupportTypes/StatusCode.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum StatusCode: Int, Codable, Hashable, Sendable { +@frozen public enum StatusCode: Int, Codable, Hashable, Sendable { /// Execution was successful. case ok = 1 diff --git a/Sources/LanguageServerProtocol/Notifications/LogMessageNotification.swift b/Sources/LanguageServerProtocol/Notifications/LogMessageNotification.swift index 32ba39e64..e47a5501a 100644 --- a/Sources/LanguageServerProtocol/Notifications/LogMessageNotification.swift +++ b/Sources/LanguageServerProtocol/Notifications/LogMessageNotification.swift @@ -44,7 +44,7 @@ public struct LogMessageNotification: LSPNotification, Hashable { } } -public enum StructuredLogKind: Codable, Hashable, Sendable { +@frozen public enum StructuredLogKind: Codable, Hashable, Sendable { case begin(StructuredLogBegin) case report(StructuredLogReport) case end(StructuredLogEnd) diff --git a/Sources/LanguageServerProtocol/Notifications/WorkDoneProgress.swift b/Sources/LanguageServerProtocol/Notifications/WorkDoneProgress.swift index c8ae9c297..7102cefb3 100644 --- a/Sources/LanguageServerProtocol/Notifications/WorkDoneProgress.swift +++ b/Sources/LanguageServerProtocol/Notifications/WorkDoneProgress.swift @@ -25,7 +25,7 @@ public struct WorkDoneProgress: LSPNotification, Hashable { } } -public enum WorkDoneProgressKind: Codable, Hashable, Sendable { +@frozen public enum WorkDoneProgressKind: Codable, Hashable, Sendable { case begin(WorkDoneProgressBegin) case report(WorkDoneProgressReport) case end(WorkDoneProgressEnd) diff --git a/Sources/LanguageServerProtocol/RequestID.swift b/Sources/LanguageServerProtocol/RequestID.swift index ddf45cdbe..46c782d27 100644 --- a/Sources/LanguageServerProtocol/RequestID.swift +++ b/Sources/LanguageServerProtocol/RequestID.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum RequestID: Hashable, Sendable { +@frozen public enum RequestID: Hashable, Sendable { case string(String) case number(Int) } diff --git a/Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift b/Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift index 09db58055..12e376357 100644 --- a/Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift @@ -50,7 +50,7 @@ public struct CodeActionRequest: TextDocumentRequest, Hashable { /// Wrapper type for the response of a CodeAction request. /// If the client supports CodeAction literals, the encoded type will be the CodeAction array itself. /// Otherwise, the encoded value will be an array of CodeActions' inner Command structs. -public enum CodeActionRequestResponse: ResponseType, Codable, Equatable { +@frozen public enum CodeActionRequestResponse: ResponseType, Codable, Equatable { case codeActions([CodeAction]) case commands([Command]) diff --git a/Sources/LanguageServerProtocol/Requests/CompletionRequest.swift b/Sources/LanguageServerProtocol/Requests/CompletionRequest.swift index 3d995a728..3c2b83408 100644 --- a/Sources/LanguageServerProtocol/Requests/CompletionRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/CompletionRequest.swift @@ -93,7 +93,7 @@ public struct CompletionList: ResponseType, Hashable { } } - public enum ItemDefaultsEditRange: Codable, Hashable, Sendable { + @frozen public enum ItemDefaultsEditRange: Codable, Hashable, Sendable { case range(Range) case insertReplaceRanges(InsertReplaceRanges) diff --git a/Sources/LanguageServerProtocol/Requests/DocumentDiagnosticsRequest.swift b/Sources/LanguageServerProtocol/Requests/DocumentDiagnosticsRequest.swift index 63ed427af..45e57128f 100644 --- a/Sources/LanguageServerProtocol/Requests/DocumentDiagnosticsRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/DocumentDiagnosticsRequest.swift @@ -35,7 +35,7 @@ public struct DocumentDiagnosticsRequest: TextDocumentRequest { /// requested document or a unchanged report indicating that nothing /// has changed in terms of diagnostics in comparison to the last /// pull request. -public enum DocumentDiagnosticReport: ResponseType, Codable, Hashable { +@frozen public enum DocumentDiagnosticReport: ResponseType, Codable, Hashable { case full(RelatedFullDocumentDiagnosticReport) case unchanged(RelatedUnchangedDocumentDiagnosticReport) diff --git a/Sources/LanguageServerProtocol/Requests/DocumentHighlightRequest.swift b/Sources/LanguageServerProtocol/Requests/DocumentHighlightRequest.swift index 05277b968..9dc1633e2 100644 --- a/Sources/LanguageServerProtocol/Requests/DocumentHighlightRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/DocumentHighlightRequest.swift @@ -41,7 +41,7 @@ public struct DocumentHighlightRequest: TextDocumentRequest, Hashable { } /// The kind of document highlight - read, write, or text (fuzzy). -public enum DocumentHighlightKind: Int, Codable, Hashable, Sendable { +@frozen public enum DocumentHighlightKind: Int, Codable, Hashable, Sendable { /// Textual match. case text = 1 diff --git a/Sources/LanguageServerProtocol/Requests/DocumentSemanticTokensDeltaRequest.swift b/Sources/LanguageServerProtocol/Requests/DocumentSemanticTokensDeltaRequest.swift index 55881c03b..e5a0297d9 100644 --- a/Sources/LanguageServerProtocol/Requests/DocumentSemanticTokensDeltaRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/DocumentSemanticTokensDeltaRequest.swift @@ -28,7 +28,7 @@ public struct DocumentSemanticTokensDeltaRequest: TextDocumentRequest, Hashable } } -public enum DocumentSemanticTokensDeltaResponse: ResponseType, Codable, Equatable { +@frozen public enum DocumentSemanticTokensDeltaResponse: ResponseType, Codable, Equatable { case tokens(DocumentSemanticTokensResponse) case delta(SemanticTokensDelta) diff --git a/Sources/LanguageServerProtocol/Requests/DocumentSymbolRequest.swift b/Sources/LanguageServerProtocol/Requests/DocumentSymbolRequest.swift index 9ec14a5c9..a87697e3d 100644 --- a/Sources/LanguageServerProtocol/Requests/DocumentSymbolRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/DocumentSymbolRequest.swift @@ -34,7 +34,7 @@ public struct DocumentSymbolRequest: TextDocumentRequest, Hashable { } } -public enum DocumentSymbolResponse: ResponseType, Hashable { +@frozen public enum DocumentSymbolResponse: ResponseType, Hashable { case documentSymbols([DocumentSymbol]) case symbolInformation([SymbolInformation]) diff --git a/Sources/LanguageServerProtocol/Requests/HoverRequest.swift b/Sources/LanguageServerProtocol/Requests/HoverRequest.swift index 87c1d407c..946ddbe59 100644 --- a/Sources/LanguageServerProtocol/Requests/HoverRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/HoverRequest.swift @@ -55,12 +55,12 @@ public struct HoverResponse: ResponseType, Hashable { } } -public enum HoverResponseContents: Hashable, Sendable { +@frozen public enum HoverResponseContents: Hashable, Sendable { case markedStrings([MarkedString]) case markupContent(MarkupContent) } -public enum MarkedString: Hashable { +@frozen public enum MarkedString: Hashable { private struct MarkdownCodeBlock: Codable { let language: String let value: String diff --git a/Sources/LanguageServerProtocol/Requests/InlineValueRequest.swift b/Sources/LanguageServerProtocol/Requests/InlineValueRequest.swift index ae0ef4788..9fc79728b 100644 --- a/Sources/LanguageServerProtocol/Requests/InlineValueRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/InlineValueRequest.swift @@ -117,7 +117,7 @@ public struct InlineValueEvaluatableExpression: Codable, Hashable, Sendable { /// - as a name to use for a variable lookup (class InlineValueVariableLookup) /// - as an evaluatable expression (class InlineValueEvaluatableExpression) /// The InlineValue types combines all inline value types into one type. -public enum InlineValue: ResponseType, Hashable, Sendable { +@frozen public enum InlineValue: ResponseType, Hashable, Sendable { case text(InlineValueText) case variableLookup(InlineValueVariableLookup) case evaluatableExpression(InlineValueEvaluatableExpression) diff --git a/Sources/LanguageServerProtocol/Requests/SignatureHelpRequest.swift b/Sources/LanguageServerProtocol/Requests/SignatureHelpRequest.swift index 5abd1e87a..0cddae5de 100644 --- a/Sources/LanguageServerProtocol/Requests/SignatureHelpRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/SignatureHelpRequest.swift @@ -160,7 +160,7 @@ public struct SignatureInformation: Codable, Hashable, Sendable { /// Represents a parameter of a callable-signature. A parameter can /// have a label and a doc-comment. public struct ParameterInformation: Codable, Hashable, Sendable { - public enum Label: Codable, Hashable, Sendable { + @frozen public enum Label: Codable, Hashable, Sendable { case string(String) case offsets(start: Int, end: Int) diff --git a/Sources/LanguageServerProtocol/Requests/WorkspaceDiagnosticsRequest.swift b/Sources/LanguageServerProtocol/Requests/WorkspaceDiagnosticsRequest.swift index 7abc34134..c383a2dbc 100644 --- a/Sources/LanguageServerProtocol/Requests/WorkspaceDiagnosticsRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/WorkspaceDiagnosticsRequest.swift @@ -159,7 +159,7 @@ public struct WorkspaceUnchangedDocumentDiagnosticReport: Codable, Hashable, Sen } /// A workspace diagnostic document report. -public enum WorkspaceDocumentDiagnosticReport: Codable, Hashable, Sendable { +@frozen public enum WorkspaceDocumentDiagnosticReport: Codable, Hashable, Sendable { case full(WorkspaceFullDocumentDiagnosticReport) case unchanged(WorkspaceUnchangedDocumentDiagnosticReport) diff --git a/Sources/LanguageServerProtocol/Requests/WorkspaceSymbolsRequest.swift b/Sources/LanguageServerProtocol/Requests/WorkspaceSymbolsRequest.swift index 27543fc9b..f0f3511ba 100644 --- a/Sources/LanguageServerProtocol/Requests/WorkspaceSymbolsRequest.swift +++ b/Sources/LanguageServerProtocol/Requests/WorkspaceSymbolsRequest.swift @@ -34,7 +34,7 @@ public struct WorkspaceSymbolsRequest: LSPRequest, Hashable { } } -public enum WorkspaceSymbolItem: ResponseType, Hashable { +@frozen public enum WorkspaceSymbolItem: ResponseType, Hashable { case symbolInformation(SymbolInformation) case workspaceSymbol(WorkspaceSymbol) @@ -94,7 +94,7 @@ public struct SymbolInformation: Hashable, ResponseType { /// A special workspace symbol that supports locations without a range public struct WorkspaceSymbol: ResponseType, Hashable { - public enum WorkspaceSymbolLocation: Codable, Hashable, Sendable { + @frozen public enum WorkspaceSymbolLocation: Codable, Hashable, Sendable { public struct URI: Codable, Hashable, Sendable { public var uri: DocumentURI diff --git a/Sources/LanguageServerProtocol/SupportTypes/ClientCapabilities.swift b/Sources/LanguageServerProtocol/SupportTypes/ClientCapabilities.swift index 231b6057b..a82154133 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/ClientCapabilities.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/ClientCapabilities.swift @@ -977,7 +977,7 @@ public struct GeneralClientCapabilities: Hashable, Codable, Sendable { /// A type indicating how positions are encoded, /// specifically what column offsets mean. - public enum PositionEncodingKind: String, Hashable, Codable, Sendable { + @frozen public enum PositionEncodingKind: String, Hashable, Codable, Sendable { /// Character offsets count UTF-8 code units (e.g bytes). case utf8 = "utf-8" diff --git a/Sources/LanguageServerProtocol/SupportTypes/CompletionItem.swift b/Sources/LanguageServerProtocol/SupportTypes/CompletionItem.swift index 4bedc3230..f55808a81 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/CompletionItem.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/CompletionItem.swift @@ -42,7 +42,7 @@ public struct CompletionItemTag: RawRepresentable, Codable, Hashable, Sendable { public static let deprecated = CompletionItemTag(rawValue: 1) } -public enum CompletionItemEdit: Codable, Hashable, Sendable { +@frozen public enum CompletionItemEdit: Codable, Hashable, Sendable { case textEdit(TextEdit) case insertReplaceEdit(InsertReplaceEdit) @@ -205,7 +205,7 @@ public struct CompletionItem: ResponseType, Codable, Hashable, Sendable { } /// The format of the returned insertion text - either literal plain text or a snippet. -public enum InsertTextFormat: Int, Codable, Hashable, Sendable { +@frozen public enum InsertTextFormat: Int, Codable, Hashable, Sendable { /// The text to insert is plain text. case plain = 1 diff --git a/Sources/LanguageServerProtocol/SupportTypes/Diagnostic.swift b/Sources/LanguageServerProtocol/SupportTypes/Diagnostic.swift index 1cef3d57e..18a4002b8 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/Diagnostic.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/Diagnostic.swift @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// /// The severity level of a Diagnostic, between hint and error. -public enum DiagnosticSeverity: Int, Codable, Hashable, Sendable { +@frozen public enum DiagnosticSeverity: Int, Codable, Hashable, Sendable { case error = 1 case warning = 2 case information = 3 @@ -19,7 +19,7 @@ public enum DiagnosticSeverity: Int, Codable, Hashable, Sendable { } /// A unique diagnostic code, which may be used identifier the diagnostic in e.g. documentation. -public enum DiagnosticCode: Hashable, Sendable { +@frozen public enum DiagnosticCode: Hashable, Sendable { case number(Int) case string(String) } diff --git a/Sources/LanguageServerProtocol/SupportTypes/InlayHint.swift b/Sources/LanguageServerProtocol/SupportTypes/InlayHint.swift index d1d520559..1c1a86ca6 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/InlayHint.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/InlayHint.swift @@ -74,7 +74,7 @@ public struct InlayHintKind: RawRepresentable, Codable, Hashable, Sendable { } /// A hint's label, either being a single string or a composition of parts. -public enum InlayHintLabel: Codable, Hashable, Sendable { +@frozen public enum InlayHintLabel: Codable, Hashable, Sendable { case parts([InlayHintLabelPart]) case string(String) diff --git a/Sources/LanguageServerProtocol/SupportTypes/LSPAny.swift b/Sources/LanguageServerProtocol/SupportTypes/LSPAny.swift index 2b16e1cf2..f3d06b82a 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/LSPAny.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/LSPAny.swift @@ -12,7 +12,7 @@ /// Representation of 'any' in the Language Server Protocol, which is equivalent /// to an arbitrary JSON value. -public enum LSPAny: Hashable, Sendable { +@frozen public enum LSPAny: Hashable, Sendable { case null case int(Int) case bool(Bool) diff --git a/Sources/LanguageServerProtocol/SupportTypes/LocationsOrLocationLinksResponse.swift b/Sources/LanguageServerProtocol/SupportTypes/LocationsOrLocationLinksResponse.swift index 6ba402a33..a9b01f4dc 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/LocationsOrLocationLinksResponse.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/LocationsOrLocationLinksResponse.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum LocationsOrLocationLinksResponse: ResponseType, Hashable, Sendable { +@frozen public enum LocationsOrLocationLinksResponse: ResponseType, Hashable, Sendable { case locations([Location]) case locationLinks([LocationLink]) diff --git a/Sources/LanguageServerProtocol/SupportTypes/NotebookCellTextDocumentFilter.swift b/Sources/LanguageServerProtocol/SupportTypes/NotebookCellTextDocumentFilter.swift index f1e2ae240..97c81bca4 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/NotebookCellTextDocumentFilter.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/NotebookCellTextDocumentFilter.swift @@ -31,7 +31,7 @@ public struct NotebookDocumentFilter: Codable, Hashable, Sendable { /// A notebook cell text document filter denotes a cell text /// document by different properties. public struct NotebookCellTextDocumentFilter: Codable, Hashable, Sendable { - public enum NotebookFilter: Codable, Hashable, Sendable { + @frozen public enum NotebookFilter: Codable, Hashable, Sendable { case string(String) case notebookDocumentFilter(NotebookDocumentFilter) diff --git a/Sources/LanguageServerProtocol/SupportTypes/ProgressToken.swift b/Sources/LanguageServerProtocol/SupportTypes/ProgressToken.swift index 189a3c3ba..ffb5a4e4c 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/ProgressToken.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/ProgressToken.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum ProgressToken: Codable, Hashable, Sendable { +@frozen public enum ProgressToken: Codable, Hashable, Sendable { case integer(Int) case string(String) diff --git a/Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift b/Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift index 0425df6e7..5f59e0671 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift @@ -200,7 +200,7 @@ public struct ServerCapabilities: Codable, Hashable, Sendable { } } -public enum ValueOrBool: Codable, Hashable where ValueType: Hashable { +@frozen public enum ValueOrBool: Codable, Hashable where ValueType: Hashable { case bool(Bool) case value(ValueType) @@ -240,7 +240,7 @@ public enum ValueOrBool: Codable, Hashable where ValueType: extension ValueOrBool: Sendable where ValueType: Sendable {} -public enum TextDocumentSync: Codable, Hashable, Sendable { +@frozen public enum TextDocumentSync: Codable, Hashable, Sendable { case options(TextDocumentSyncOptions) case kind(TextDocumentSyncKind) @@ -342,7 +342,7 @@ public struct TextDocumentSyncOptions: Codable, Hashable, Sendable { } } -public enum TextDocumentSyncKind: Int, Codable, Hashable, Sendable { +@frozen public enum TextDocumentSyncKind: Int, Codable, Hashable, Sendable { /// Documents should not be synced at all. case none = 0 @@ -355,7 +355,7 @@ public enum TextDocumentSyncKind: Int, Codable, Hashable, Sendable { case incremental = 2 } -public enum NotebookFilter: Codable, Hashable, Sendable { +@frozen public enum NotebookFilter: Codable, Hashable, Sendable { case string(String) case documentFilter(DocumentFilter) @@ -748,7 +748,7 @@ public struct DocumentOnTypeFormattingOptions: Codable, Hashable, Sendable { /// Wrapper type for a server's CodeActions' capabilities. /// If the client supports CodeAction literals, the server can return specific information about /// how CodeActions will be sent. Otherwise, the server's capabilities are determined by a boolean. -public enum CodeActionServerCapabilities: Codable, Hashable, Sendable { +@frozen public enum CodeActionServerCapabilities: Codable, Hashable, Sendable { case supportsCodeActionRequests(Bool) case supportsCodeActionRequestsWithLiterals(CodeActionOptions) @@ -1157,7 +1157,7 @@ public struct WorkspaceServerCapabilities: Codable, Hashable, Sendable { } } - public enum FileOperationPatternKind: String, Codable, Hashable { + @frozen public enum FileOperationPatternKind: String, Codable, Hashable { /// The pattern matches a file only. case file = "file" /// The pattern matches a folder only. diff --git a/Sources/LanguageServerProtocol/SupportTypes/StringOrMarkupContent.swift b/Sources/LanguageServerProtocol/SupportTypes/StringOrMarkupContent.swift index 90cfd4465..29d0c3ba5 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/StringOrMarkupContent.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/StringOrMarkupContent.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum StringOrMarkupContent: Codable, Hashable, Sendable { +@frozen public enum StringOrMarkupContent: Codable, Hashable, Sendable { case string(String) case markupContent(MarkupContent) diff --git a/Sources/LanguageServerProtocol/SupportTypes/TextDocumentEdit.swift b/Sources/LanguageServerProtocol/SupportTypes/TextDocumentEdit.swift index 60f801151..50a1ba684 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/TextDocumentEdit.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/TextDocumentEdit.swift @@ -14,7 +14,7 @@ /// /// For an edit where the document is implied, use `TextEdit`. public struct TextDocumentEdit: Hashable, Codable, Sendable { - public enum Edit: Codable, Hashable, Sendable { + @frozen public enum Edit: Codable, Hashable, Sendable { case textEdit(TextEdit) case annotatedTextEdit(AnnotatedTextEdit) diff --git a/Sources/LanguageServerProtocol/SupportTypes/TextDocumentSaveReason.swift b/Sources/LanguageServerProtocol/SupportTypes/TextDocumentSaveReason.swift index 23b864893..2d0aa3642 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/TextDocumentSaveReason.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/TextDocumentSaveReason.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum TextDocumentSaveReason: Int, Codable, Hashable, Sendable { +@frozen public enum TextDocumentSaveReason: Int, Codable, Hashable, Sendable { case manual = 1 diff --git a/Sources/LanguageServerProtocol/SupportTypes/Tracing.swift b/Sources/LanguageServerProtocol/SupportTypes/Tracing.swift index d008578d2..ac0219062 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/Tracing.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/Tracing.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -public enum Tracing: String, Codable, Sendable { +@frozen public enum Tracing: String, Codable, Sendable { case off case messages case verbose diff --git a/Sources/LanguageServerProtocol/SupportTypes/WindowMessageType.swift b/Sources/LanguageServerProtocol/SupportTypes/WindowMessageType.swift index e3ae78cee..62673723a 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/WindowMessageType.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/WindowMessageType.swift @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// /// The type of message (error, etc.) for a ShowMessage or LogMessage request. Corresponds to `MessageType` in LSP. -public enum WindowMessageType: Int, Codable, Hashable, Sendable { +@frozen public enum WindowMessageType: Int, Codable, Hashable, Sendable { case error = 1 case warning = 2 diff --git a/Sources/LanguageServerProtocol/SupportTypes/WorkspaceEdit.swift b/Sources/LanguageServerProtocol/SupportTypes/WorkspaceEdit.swift index 9e2793068..76f5b7176 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/WorkspaceEdit.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/WorkspaceEdit.swift @@ -72,7 +72,7 @@ extension WorkspaceEdit: Codable { } } -public enum WorkspaceEditDocumentChange: Codable, Hashable, Sendable { +@frozen public enum WorkspaceEditDocumentChange: Codable, Hashable, Sendable { case textDocumentEdit(TextDocumentEdit) case createFile(CreateFile) case renameFile(RenameFile) @@ -140,7 +140,7 @@ public struct CreateFile: Codable, Hashable, Sendable { // MARK: Codable conformance - public enum CodingKeys: String, CodingKey { + /*@nonexhaustive*/ public enum CodingKeys: String, CodingKey { case kind case uri case options @@ -209,7 +209,7 @@ public struct RenameFile: Codable, Hashable, Sendable { // MARK: Codable conformance - public enum CodingKeys: String, CodingKey { + /*@nonexhaustive*/ public enum CodingKeys: String, CodingKey { case kind case oldUri case newUri @@ -273,7 +273,7 @@ public struct DeleteFile: Codable, Hashable, Sendable { // MARK: Codable conformance - public enum CodingKeys: String, CodingKey { + /*@nonexhaustive*/ public enum CodingKeys: String, CodingKey { case kind case uri case options diff --git a/Sources/LanguageServerProtocol/SupportTypes/WorkspaceSettings.swift b/Sources/LanguageServerProtocol/SupportTypes/WorkspaceSettings.swift index 2f10218c6..6daaeb9b6 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/WorkspaceSettings.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/WorkspaceSettings.swift @@ -13,7 +13,7 @@ /// The `settings` field of a `workspace/didChangeConfiguration`. /// /// This is typed as `Any` in the protocol, and this enum contains the formats we support. -public enum WorkspaceSettingsChange: Codable, Hashable, Sendable { +/*@nonexhaustive*/ public enum WorkspaceSettingsChange: Codable, Hashable, Sendable { case clangd(ClangWorkspaceSettings) case unknown(LSPAny) diff --git a/Sources/LanguageServerProtocolTransport/BuildServerMessageDependencyTracker.swift b/Sources/LanguageServerProtocolTransport/BuildServerMessageDependencyTracker.swift index 0b25cb756..8eb1e5d20 100644 --- a/Sources/LanguageServerProtocolTransport/BuildServerMessageDependencyTracker.swift +++ b/Sources/LanguageServerProtocolTransport/BuildServerMessageDependencyTracker.swift @@ -17,7 +17,7 @@ import ToolsProtocolsSwiftExtensions /// A lightweight way of describing tasks that are created from handling BSP /// requests or notifications for the purpose of dependency tracking. -public enum BuildServerMessageDependencyTracker: QueueBasedMessageHandlerDependencyTracker { +/*@nonexhaustive*/ public enum BuildServerMessageDependencyTracker: QueueBasedMessageHandlerDependencyTracker { /// A task that modifies some state. It is a barrier for all requests that read state. case stateChange diff --git a/Sources/LanguageServerProtocolTransport/JSONRPCConnection.swift b/Sources/LanguageServerProtocolTransport/JSONRPCConnection.swift index 919b1536b..5f07daf0e 100644 --- a/Sources/LanguageServerProtocolTransport/JSONRPCConnection.swift +++ b/Sources/LanguageServerProtocolTransport/JSONRPCConnection.swift @@ -31,7 +31,7 @@ import struct CDispatch.dispatch_fd_t /// For example, inside a language server, the `JSONRPCConnection` takes the language service implementation as its // `receiveHandler` and itself provides the client connection for sending notifications and callbacks. public final class JSONRPCConnection: Connection { - public enum TerminationReason: Sendable, Equatable { + @frozen public enum TerminationReason: Sendable, Equatable { /// The process on the other end of the `JSONRPCConnection` terminated with the given exit code. case exited(exitCode: Int32) diff --git a/Sources/LanguageServerProtocolTransport/MessageCoding.swift b/Sources/LanguageServerProtocolTransport/MessageCoding.swift index 1bfac6bde..03353dbc3 100644 --- a/Sources/LanguageServerProtocolTransport/MessageCoding.swift +++ b/Sources/LanguageServerProtocolTransport/MessageCoding.swift @@ -13,7 +13,7 @@ import Foundation public import LanguageServerProtocol -@_spi(Testing) public enum JSONRPCMessage { +@_spi(Testing) @frozen public enum JSONRPCMessage { case notification(NotificationType) case request(_RequestType, id: RequestID) case response(ResponseType, id: RequestID) diff --git a/Sources/SKLogging/NonDarwinLogging.swift b/Sources/SKLogging/NonDarwinLogging.swift index 9a7f5fd09..f56084ac3 100644 --- a/Sources/SKLogging/NonDarwinLogging.swift +++ b/Sources/SKLogging/NonDarwinLogging.swift @@ -21,7 +21,7 @@ import Foundation // MARK: - Log settings -@_spi(SourceKitLSP) public enum LogConfig { +@_spi(SourceKitLSP) @frozen public enum LogConfig { /// The globally set log level private static let _logLevel = ThreadSafeBox( initialValue: { @@ -80,7 +80,7 @@ import Foundation /// /// For documentation of the different log levels see /// https://developer.apple.com/documentation/os/oslogtype. -@_spi(SourceKitLSP) public enum NonDarwinLogLevel: Comparable, CustomStringConvertible, Sendable { +@_spi(SourceKitLSP) @frozen public enum NonDarwinLogLevel: Comparable, CustomStringConvertible, Sendable { case debug case info case `default` @@ -137,7 +137,7 @@ import Foundation /// /// For documentation of the different privacy levels see /// https://developer.apple.com/documentation/os/oslogprivacy. -@_spi(SourceKitLSP) public enum NonDarwinLogPrivacy: Comparable, Sendable { +@_spi(SourceKitLSP) @frozen public enum NonDarwinLogPrivacy: Comparable, Sendable { case `public` case `private` case sensitive