12
12
13
13
import BuildServerIntegration
14
14
import Foundation
15
- import LanguageServerProtocol
15
+ package import LanguageServerProtocol
16
16
import LanguageServerProtocolExtensions
17
17
import LanguageServerProtocolJSONRPC
18
18
import SKLogging
19
- import SKOptions
20
- import SwiftExtensions
21
- import SwiftSyntax
19
+ package import SKOptions
20
+ package import SwiftExtensions
21
+ package import SwiftSyntax
22
22
import TSCExtensions
23
- import ToolchainRegistry
23
+ package import ToolchainRegistry
24
24
25
25
#if canImport(DocCDocumentation)
26
26
import DocCDocumentation
@@ -38,7 +38,7 @@ import WinSDK
38
38
/// ``ClangLanguageServerShim`` conforms to ``MessageHandler`` to receive
39
39
/// requests and notifications **from** clangd, not from the editor, and it will
40
40
/// forward these requests and notifications to the editor.
41
- actor ClangLanguageService : LanguageService , MessageHandler {
41
+ package actor ClangLanguageService : LanguageService , MessageHandler {
42
42
/// The queue on which all messages that originate from clangd are handled.
43
43
///
44
44
/// These are requests and notifications sent *from* clangd, not replies from
@@ -144,12 +144,12 @@ actor ClangLanguageService: LanguageService, MessageHandler {
144
144
return ClangBuildSettings ( settings, clangPath: clangPath)
145
145
}
146
146
147
- nonisolated func canHandle( workspace: Workspace , toolchain: Toolchain ) -> Bool {
147
+ package nonisolated func canHandle( workspace: Workspace , toolchain: Toolchain ) -> Bool {
148
148
// We launch different clangd instance for each workspace because clangd doesn't have multi-root workspace support.
149
149
return workspace === self . workspace. value && self . clangdPath == toolchain. clangd
150
150
}
151
151
152
- func addStateChangeHandler( handler: @escaping ( LanguageServerState , LanguageServerState ) -> Void ) {
152
+ package func addStateChangeHandler( handler: @escaping ( LanguageServerState , LanguageServerState ) -> Void ) {
153
153
self . stateChangeHandlers. append ( handler)
154
154
}
155
155
@@ -244,7 +244,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
244
244
/// sending a notification that's intended for the editor.
245
245
///
246
246
/// We should either handle it ourselves or forward it to the editor.
247
- nonisolated func handle( _ params: some NotificationType ) {
247
+ package nonisolated func handle( _ params: some NotificationType ) {
248
248
logger. info (
249
249
"""
250
250
Received notification from clangd:
@@ -267,7 +267,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
267
267
/// sending a notification that's intended for the editor.
268
268
///
269
269
/// We should either handle it ourselves or forward it to the client.
270
- nonisolated func handle< R: RequestType > (
270
+ package nonisolated func handle< R: RequestType > (
271
271
_ params: R ,
272
272
id: RequestID ,
273
273
reply: @Sendable @escaping ( LSPResult < R . Response > ) -> Void
@@ -316,7 +316,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
316
316
return nil
317
317
}
318
318
319
- func crash( ) {
319
+ package func crash( ) {
320
320
clangdProcess? . terminateImmediately ( )
321
321
}
322
322
}
@@ -366,7 +366,7 @@ extension ClangLanguageService {
366
366
367
367
extension ClangLanguageService {
368
368
369
- func initialize( _ initialize: InitializeRequest ) async throws -> InitializeResult {
369
+ package func initialize( _ initialize: InitializeRequest ) async throws -> InitializeResult {
370
370
// Store the initialize request so we can replay it in case clangd crashes
371
371
self . initializeRequest = initialize
372
372
@@ -417,7 +417,7 @@ extension ClangLanguageService {
417
417
clangd. send ( notification)
418
418
}
419
419
420
- func reopenDocument( _ notification: ReopenTextDocumentNotification ) { }
420
+ package func reopenDocument( _ notification: ReopenTextDocumentNotification ) { }
421
421
422
422
package func changeDocument(
423
423
_ notification: DidChangeTextDocumentNotification ,
@@ -481,20 +481,20 @@ extension ClangLanguageService {
481
481
return try await forwardRequestToClangd ( req)
482
482
}
483
483
484
- func completion( _ req: CompletionRequest ) async throws -> CompletionList {
484
+ package func completion( _ req: CompletionRequest ) async throws -> CompletionList {
485
485
return try await forwardRequestToClangd ( req)
486
486
}
487
487
488
- func completionItemResolve( _ req: CompletionItemResolveRequest ) async throws -> CompletionItem {
488
+ package func completionItemResolve( _ req: CompletionItemResolveRequest ) async throws -> CompletionItem {
489
489
return try await forwardRequestToClangd ( req)
490
490
}
491
491
492
- func hover( _ req: HoverRequest ) async throws -> HoverResponse ? {
492
+ package func hover( _ req: HoverRequest ) async throws -> HoverResponse ? {
493
493
return try await forwardRequestToClangd ( req)
494
494
}
495
495
496
496
#if canImport(DocCDocumentation)
497
- func doccDocumentation( _ req: DoccDocumentationRequest ) async throws -> DoccDocumentationResponse {
497
+ package func doccDocumentation( _ req: DoccDocumentationRequest ) async throws -> DoccDocumentationResponse {
498
498
guard let sourceKitLSPServer else {
499
499
throw ResponseError . unknown ( " Connection to the editor closed " )
500
500
}
@@ -504,26 +504,28 @@ extension ClangLanguageService {
504
504
}
505
505
#endif
506
506
507
- func symbolInfo( _ req: SymbolInfoRequest ) async throws -> [ SymbolDetails ] {
507
+ package func symbolInfo( _ req: SymbolInfoRequest ) async throws -> [ SymbolDetails ] {
508
508
return try await forwardRequestToClangd ( req)
509
509
}
510
510
511
- func documentSymbolHighlight( _ req: DocumentHighlightRequest ) async throws -> [ DocumentHighlight ] ? {
511
+ package func documentSymbolHighlight( _ req: DocumentHighlightRequest ) async throws -> [ DocumentHighlight ] ? {
512
512
return try await forwardRequestToClangd ( req)
513
513
}
514
514
515
- func documentSymbol( _ req: DocumentSymbolRequest ) async throws -> DocumentSymbolResponse ? {
515
+ package func documentSymbol( _ req: DocumentSymbolRequest ) async throws -> DocumentSymbolResponse ? {
516
516
return try await forwardRequestToClangd ( req)
517
517
}
518
518
519
- func documentColor( _ req: DocumentColorRequest ) async throws -> [ ColorInformation ] {
519
+ package func documentColor( _ req: DocumentColorRequest ) async throws -> [ ColorInformation ] {
520
520
guard self . capabilities? . colorProvider? . isSupported ?? false else {
521
521
return [ ]
522
522
}
523
523
return try await forwardRequestToClangd ( req)
524
524
}
525
525
526
- func documentSemanticTokens( _ req: DocumentSemanticTokensRequest ) async throws -> DocumentSemanticTokensResponse ? {
526
+ package func documentSemanticTokens(
527
+ _ req: DocumentSemanticTokensRequest
528
+ ) async throws -> DocumentSemanticTokensResponse ? {
527
529
guard var response = try await forwardRequestToClangd ( req) else {
528
530
return nil
529
531
}
@@ -533,7 +535,7 @@ extension ClangLanguageService {
533
535
return response
534
536
}
535
537
536
- func documentSemanticTokensDelta(
538
+ package func documentSemanticTokensDelta(
537
539
_ req: DocumentSemanticTokensDeltaRequest
538
540
) async throws -> DocumentSemanticTokensDeltaResponse ? {
539
541
guard var response = try await forwardRequestToClangd ( req) else {
@@ -558,7 +560,7 @@ extension ClangLanguageService {
558
560
return response
559
561
}
560
562
561
- func documentSemanticTokensRange(
563
+ package func documentSemanticTokensRange(
562
564
_ req: DocumentSemanticTokensRangeRequest
563
565
) async throws -> DocumentSemanticTokensResponse ? {
564
566
guard var response = try await forwardRequestToClangd ( req) else {
@@ -570,49 +572,49 @@ extension ClangLanguageService {
570
572
return response
571
573
}
572
574
573
- func colorPresentation( _ req: ColorPresentationRequest ) async throws -> [ ColorPresentation ] {
575
+ package func colorPresentation( _ req: ColorPresentationRequest ) async throws -> [ ColorPresentation ] {
574
576
guard self . capabilities? . colorProvider? . isSupported ?? false else {
575
577
return [ ]
576
578
}
577
579
return try await forwardRequestToClangd ( req)
578
580
}
579
581
580
- func documentFormatting( _ req: DocumentFormattingRequest ) async throws -> [ TextEdit ] ? {
582
+ package func documentFormatting( _ req: DocumentFormattingRequest ) async throws -> [ TextEdit ] ? {
581
583
return try await forwardRequestToClangd ( req)
582
584
}
583
585
584
- func documentRangeFormatting( _ req: DocumentRangeFormattingRequest ) async throws -> [ TextEdit ] ? {
586
+ package func documentRangeFormatting( _ req: DocumentRangeFormattingRequest ) async throws -> [ TextEdit ] ? {
585
587
return try await forwardRequestToClangd ( req)
586
588
}
587
589
588
- func documentOnTypeFormatting( _ req: DocumentOnTypeFormattingRequest ) async throws -> [ TextEdit ] ? {
590
+ package func documentOnTypeFormatting( _ req: DocumentOnTypeFormattingRequest ) async throws -> [ TextEdit ] ? {
589
591
return try await forwardRequestToClangd ( req)
590
592
}
591
593
592
- func codeAction( _ req: CodeActionRequest ) async throws -> CodeActionRequestResponse ? {
594
+ package func codeAction( _ req: CodeActionRequest ) async throws -> CodeActionRequestResponse ? {
593
595
return try await forwardRequestToClangd ( req)
594
596
}
595
597
596
- func inlayHint( _ req: InlayHintRequest ) async throws -> [ InlayHint ] {
598
+ package func inlayHint( _ req: InlayHintRequest ) async throws -> [ InlayHint ] {
597
599
return try await forwardRequestToClangd ( req)
598
600
}
599
601
600
- func documentDiagnostic( _ req: DocumentDiagnosticsRequest ) async throws -> DocumentDiagnosticReport {
602
+ package func documentDiagnostic( _ req: DocumentDiagnosticsRequest ) async throws -> DocumentDiagnosticReport {
601
603
return try await forwardRequestToClangd ( req)
602
604
}
603
605
604
- func codeLens( _ req: CodeLensRequest ) async throws -> [ CodeLens ] {
606
+ package func codeLens( _ req: CodeLensRequest ) async throws -> [ CodeLens ] {
605
607
return try await forwardRequestToClangd ( req) ?? [ ]
606
608
}
607
609
608
- func foldingRange( _ req: FoldingRangeRequest ) async throws -> [ FoldingRange ] ? {
610
+ package func foldingRange( _ req: FoldingRangeRequest ) async throws -> [ FoldingRange ] ? {
609
611
guard self . capabilities? . foldingRangeProvider? . isSupported ?? false else {
610
612
return nil
611
613
}
612
614
return try await forwardRequestToClangd ( req)
613
615
}
614
616
615
- func openGeneratedInterface(
617
+ package func openGeneratedInterface(
616
618
document: DocumentURI ,
617
619
moduleName: String ,
618
620
groupName: String ? ,
@@ -621,21 +623,21 @@ extension ClangLanguageService {
621
623
throw ResponseError . unknown ( " unsupported method " )
622
624
}
623
625
624
- func indexedRename( _ request: IndexedRenameRequest ) async throws -> WorkspaceEdit ? {
626
+ package func indexedRename( _ request: IndexedRenameRequest ) async throws -> WorkspaceEdit ? {
625
627
return try await forwardRequestToClangd ( request)
626
628
}
627
629
628
630
// MARK: - Other
629
631
630
- func executeCommand( _ req: ExecuteCommandRequest ) async throws -> LSPAny ? {
632
+ package func executeCommand( _ req: ExecuteCommandRequest ) async throws -> LSPAny ? {
631
633
return try await forwardRequestToClangd ( req)
632
634
}
633
635
634
- func getReferenceDocument( _ req: GetReferenceDocumentRequest ) async throws -> GetReferenceDocumentResponse {
636
+ package func getReferenceDocument( _ req: GetReferenceDocumentRequest ) async throws -> GetReferenceDocumentResponse {
635
637
throw ResponseError . unknown ( " unsupported method " )
636
638
}
637
639
638
- func rename( _ renameRequest: RenameRequest ) async throws -> ( edits: WorkspaceEdit , usr: String ? ) {
640
+ package func rename( _ renameRequest: RenameRequest ) async throws -> ( edits: WorkspaceEdit , usr: String ? ) {
639
641
async let edits = forwardRequestToClangd ( renameRequest)
640
642
let symbolInfoRequest = SymbolInfoRequest (
641
643
textDocument: renameRequest. textDocument,
@@ -645,7 +647,11 @@ extension ClangLanguageService {
645
647
return ( try await edits ?? WorkspaceEdit ( ) , symbolDetail? . usr)
646
648
}
647
649
648
- func editsToRename(
650
+ package func syntacticDocumentTests( for uri: DocumentURI , in workspace: Workspace ) async -> [ AnnotatedTestItem ] ? {
651
+ return nil
652
+ }
653
+
654
+ package func editsToRename(
649
655
locations renameLocations: [ RenameLocation ] ,
650
656
in snapshot: DocumentSnapshot ,
651
657
oldName oldCrossLanguageName: CrossLanguageName ,
0 commit comments