|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2024 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 | +import Foundation |
| 14 | + |
| 15 | +#if compiler(>=6) |
| 16 | +package import LanguageServerProtocol |
| 17 | +package import SKOptions |
| 18 | +package import SwiftSyntax |
| 19 | +package import ToolchainRegistry |
| 20 | +#else |
| 21 | +import LanguageServerProtocol |
| 22 | +import SKOptions |
| 23 | +import SwiftSyntax |
| 24 | +import ToolchainRegistry |
| 25 | +#endif |
| 26 | + |
| 27 | +package actor DocumentationLanguageService: LanguageService, Sendable { |
| 28 | + package init?( |
| 29 | + sourceKitLSPServer: SourceKitLSPServer, |
| 30 | + toolchain: Toolchain, |
| 31 | + options: SourceKitLSPOptions, |
| 32 | + testHooks: TestHooks, |
| 33 | + workspace: Workspace |
| 34 | + ) async throws {} |
| 35 | + |
| 36 | + package nonisolated func canHandle(workspace: Workspace) -> Bool { |
| 37 | + return true |
| 38 | + } |
| 39 | + |
| 40 | + package func initialize( |
| 41 | + _ initialize: InitializeRequest |
| 42 | + ) async throws -> InitializeResult { |
| 43 | + return InitializeResult( |
| 44 | + capabilities: ServerCapabilities() |
| 45 | + ) |
| 46 | + } |
| 47 | + |
| 48 | + package func clientInitialized(_ initialized: InitializedNotification) async { |
| 49 | + // Nothing to set up |
| 50 | + } |
| 51 | + |
| 52 | + package func shutdown() async { |
| 53 | + // Nothing to tear down |
| 54 | + } |
| 55 | + |
| 56 | + package func addStateChangeHandler( |
| 57 | + handler: @escaping @Sendable (LanguageServerState, LanguageServerState) -> Void |
| 58 | + ) async { |
| 59 | + // There is no underlying language server with which to report state |
| 60 | + } |
| 61 | + |
| 62 | + package func openDocument( |
| 63 | + _ notification: DidOpenTextDocumentNotification, |
| 64 | + snapshot: DocumentSnapshot |
| 65 | + ) async { |
| 66 | + // The DocumentationLanguageService does not do anything with document events |
| 67 | + } |
| 68 | + |
| 69 | + package func closeDocument(_ notification: DidCloseTextDocumentNotification) async { |
| 70 | + // The DocumentationLanguageService does not do anything with document events |
| 71 | + } |
| 72 | + |
| 73 | + package func reopenDocument(_ notification: ReopenTextDocumentNotification) async { |
| 74 | + // The DocumentationLanguageService does not do anything with document events |
| 75 | + } |
| 76 | + |
| 77 | + package func changeDocument( |
| 78 | + _ notification: DidChangeTextDocumentNotification, |
| 79 | + preEditSnapshot: DocumentSnapshot, |
| 80 | + postEditSnapshot: DocumentSnapshot, |
| 81 | + edits: [SwiftSyntax.SourceEdit] |
| 82 | + ) async { |
| 83 | + // The DocumentationLanguageService does not do anything with document events |
| 84 | + } |
| 85 | + |
| 86 | + package func willSaveDocument(_ notification: WillSaveTextDocumentNotification) async { |
| 87 | + // The DocumentationLanguageService does not do anything with document events |
| 88 | + } |
| 89 | + |
| 90 | + package func didSaveDocument(_ notification: DidSaveTextDocumentNotification) async { |
| 91 | + // The DocumentationLanguageService does not do anything with document events |
| 92 | + } |
| 93 | + |
| 94 | + package func documentUpdatedBuildSettings(_ uri: DocumentURI) async { |
| 95 | + // The DocumentationLanguageService does not do anything with document events |
| 96 | + } |
| 97 | + |
| 98 | + package func documentDependenciesUpdated(_ uris: Set<DocumentURI>) async { |
| 99 | + // The DocumentationLanguageService does not do anything with document events |
| 100 | + } |
| 101 | + |
| 102 | + package func completion(_ req: CompletionRequest) async throws -> CompletionList { |
| 103 | + CompletionList(isIncomplete: false, items: []) |
| 104 | + } |
| 105 | + |
| 106 | + package func hover(_ req: HoverRequest) async throws -> HoverResponse? { |
| 107 | + nil |
| 108 | + } |
| 109 | + |
| 110 | + package func symbolInfo(_ request: SymbolInfoRequest) async throws -> [SymbolDetails] { |
| 111 | + [] |
| 112 | + } |
| 113 | + |
| 114 | + package func openGeneratedInterface( |
| 115 | + document: DocumentURI, |
| 116 | + moduleName: String, |
| 117 | + groupName: String?, |
| 118 | + symbolUSR symbol: String? |
| 119 | + ) async throws -> GeneratedInterfaceDetails? { |
| 120 | + nil |
| 121 | + } |
| 122 | + |
| 123 | + package func definition(_ request: DefinitionRequest) async throws -> LocationsOrLocationLinksResponse? { |
| 124 | + nil |
| 125 | + } |
| 126 | + |
| 127 | + package func declaration(_ request: DeclarationRequest) async throws -> LocationsOrLocationLinksResponse? { |
| 128 | + nil |
| 129 | + } |
| 130 | + |
| 131 | + package func documentSymbolHighlight(_ req: DocumentHighlightRequest) async throws -> [DocumentHighlight]? { |
| 132 | + nil |
| 133 | + } |
| 134 | + |
| 135 | + package func foldingRange(_ req: FoldingRangeRequest) async throws -> [FoldingRange]? { |
| 136 | + nil |
| 137 | + } |
| 138 | + |
| 139 | + package func documentSymbol(_ req: DocumentSymbolRequest) async throws -> DocumentSymbolResponse? { |
| 140 | + nil |
| 141 | + } |
| 142 | + |
| 143 | + package func documentColor(_ req: DocumentColorRequest) async throws -> [ColorInformation] { |
| 144 | + [] |
| 145 | + } |
| 146 | + |
| 147 | + package func documentSemanticTokens( |
| 148 | + _ req: DocumentSemanticTokensRequest |
| 149 | + ) async throws -> DocumentSemanticTokensResponse? { |
| 150 | + nil |
| 151 | + } |
| 152 | + |
| 153 | + package func documentSemanticTokensDelta( |
| 154 | + _ req: DocumentSemanticTokensDeltaRequest |
| 155 | + ) async throws -> DocumentSemanticTokensDeltaResponse? { |
| 156 | + nil |
| 157 | + } |
| 158 | + |
| 159 | + package func documentSemanticTokensRange( |
| 160 | + _ req: DocumentSemanticTokensRangeRequest |
| 161 | + ) async throws -> DocumentSemanticTokensResponse? { |
| 162 | + nil |
| 163 | + } |
| 164 | + |
| 165 | + package func colorPresentation(_ req: ColorPresentationRequest) async throws -> [ColorPresentation] { |
| 166 | + [] |
| 167 | + } |
| 168 | + |
| 169 | + package func codeAction(_ req: CodeActionRequest) async throws -> CodeActionRequestResponse? { |
| 170 | + nil |
| 171 | + } |
| 172 | + |
| 173 | + package func inlayHint(_ req: InlayHintRequest) async throws -> [InlayHint] { |
| 174 | + [] |
| 175 | + } |
| 176 | + |
| 177 | + package func codeLens(_ req: CodeLensRequest) async throws -> [CodeLens] { |
| 178 | + [] |
| 179 | + } |
| 180 | + |
| 181 | + package func documentDiagnostic(_ req: DocumentDiagnosticsRequest) async throws -> DocumentDiagnosticReport { |
| 182 | + .full(RelatedFullDocumentDiagnosticReport(items: [])) |
| 183 | + } |
| 184 | + |
| 185 | + package func documentFormatting(_ req: DocumentFormattingRequest) async throws -> [TextEdit]? { |
| 186 | + nil |
| 187 | + } |
| 188 | + |
| 189 | + package func documentRangeFormatting( |
| 190 | + _ req: LanguageServerProtocol.DocumentRangeFormattingRequest |
| 191 | + ) async throws -> [LanguageServerProtocol.TextEdit]? { |
| 192 | + return nil |
| 193 | + } |
| 194 | + |
| 195 | + package func documentOnTypeFormatting(_ req: DocumentOnTypeFormattingRequest) async throws -> [TextEdit]? { |
| 196 | + return nil |
| 197 | + } |
| 198 | + |
| 199 | + package func rename(_ request: RenameRequest) async throws -> (edits: WorkspaceEdit, usr: String?) { |
| 200 | + (edits: WorkspaceEdit(), usr: nil) |
| 201 | + } |
| 202 | + |
| 203 | + package func editsToRename( |
| 204 | + locations renameLocations: [RenameLocation], |
| 205 | + in snapshot: DocumentSnapshot, |
| 206 | + oldName: CrossLanguageName, |
| 207 | + newName: CrossLanguageName |
| 208 | + ) async throws -> [TextEdit] { |
| 209 | + [] |
| 210 | + } |
| 211 | + |
| 212 | + package func prepareRename( |
| 213 | + _ request: PrepareRenameRequest |
| 214 | + ) async throws -> (prepareRename: PrepareRenameResponse, usr: String?)? { |
| 215 | + nil |
| 216 | + } |
| 217 | + |
| 218 | + package func indexedRename(_ request: IndexedRenameRequest) async throws -> WorkspaceEdit? { |
| 219 | + nil |
| 220 | + } |
| 221 | + |
| 222 | + package func editsToRenameParametersInFunctionBody( |
| 223 | + snapshot: DocumentSnapshot, |
| 224 | + renameLocation: RenameLocation, |
| 225 | + newName: CrossLanguageName |
| 226 | + ) async -> [TextEdit] { |
| 227 | + [] |
| 228 | + } |
| 229 | + |
| 230 | + package func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny? { |
| 231 | + nil |
| 232 | + } |
| 233 | + |
| 234 | + package func getReferenceDocument(_ req: GetReferenceDocumentRequest) async throws -> GetReferenceDocumentResponse { |
| 235 | + GetReferenceDocumentResponse(content: "") |
| 236 | + } |
| 237 | + |
| 238 | + package func syntacticDocumentTests( |
| 239 | + for uri: DocumentURI, |
| 240 | + in workspace: Workspace |
| 241 | + ) async throws -> [AnnotatedTestItem]? { |
| 242 | + nil |
| 243 | + } |
| 244 | + |
| 245 | + package func canonicalDeclarationPosition( |
| 246 | + of position: Position, |
| 247 | + in uri: DocumentURI |
| 248 | + ) async -> Position? { |
| 249 | + nil |
| 250 | + } |
| 251 | + |
| 252 | + package func crash() async { |
| 253 | + // There's no way to crash the DocumentationLanguageService |
| 254 | + } |
| 255 | +} |
0 commit comments