Skip to content

Commit 634ec92

Browse files
committed
Move ClangLanguageService to its own module
1 parent c692a83 commit 634ec92

13 files changed

+367
-286
lines changed

Package.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ var targets: [Target] = [
127127
dependencies: []
128128
),
129129

130+
// MARK: ClangLanguageService
131+
132+
.target(
133+
name: "ClangLanguageService",
134+
dependencies: [
135+
"BuildServerIntegration",
136+
"DocCDocumentation",
137+
"LanguageServerProtocol",
138+
"LanguageServerProtocolExtensions",
139+
"LanguageServerProtocolJSONRPC",
140+
"SKLogging",
141+
"SKOptions",
142+
"SourceKitLSP",
143+
"SwiftExtensions",
144+
"ToolchainRegistry",
145+
"TSCExtensions",
146+
] + swiftSyntaxDependencies(["SwiftSyntax"]),
147+
exclude: ["CMakeLists.txt"],
148+
swiftSettings: globalSwiftSettings
149+
),
150+
130151
// MARK: CompletionScoring
131152

132153
.target(
@@ -241,6 +262,7 @@ var targets: [Target] = [
241262
name: "InProcessClient",
242263
dependencies: [
243264
"BuildServerIntegration",
265+
"ClangLanguageService",
244266
"LanguageServerProtocol",
245267
"SKLogging",
246268
"SKOptions",

Sources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_subdirectory(BuildServerProtocol)
55
add_subdirectory(BuildServerIntegration)
66
add_subdirectory(CAtomics)
77
add_subdirectory(CCompletionScoring)
8+
add_subdirectory(ClangLanguageService)
89
add_subdirectory(CompletionScoring)
910
add_subdirectory(Csourcekitd)
1011
add_subdirectory(Diagnose)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
add_library(ClangLanguageService STATIC
2+
ClangLanguageService.swift
3+
SemanticTokenTranslator.swift
4+
)
5+
6+
set_target_properties(ClangLanguageService PROPERTIES
7+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}
8+
)
9+
10+
target_link_libraries(ClangLanguageService PUBLIC
11+
LanguageServerProtocol
12+
SKOptions
13+
SourceKitLSP
14+
SwiftExtensions
15+
ToolchainRegistry
16+
SwiftSyntax::SwiftSyntax
17+
)
18+
19+
target_link_libraries(ClangLanguageService PRIVATE
20+
BuildServerIntegration
21+
LanguageServerProtocolExtensions
22+
LanguageServerProtocolJSONRPC
23+
SKLogging
24+
TSCExtensions
25+
)

Sources/SourceKitLSP/Clang/ClangLanguageService.swift renamed to Sources/ClangLanguageService/ClangLanguageService.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import LanguageServerProtocolExtensions
1717
import LanguageServerProtocolJSONRPC
1818
import SKLogging
1919
package import SKOptions
20+
package import SourceKitLSP
2021
package import SwiftExtensions
2122
package import SwiftSyntax
2223
import TSCExtensions
@@ -499,7 +500,7 @@ extension ClangLanguageService {
499500
throw ResponseError.unknown("Connection to the editor closed")
500501
}
501502

502-
let snapshot = try sourceKitLSPServer.documentManager.latestSnapshot(req.textDocument.uri)
503+
let snapshot = try await sourceKitLSPServer.documentManager.latestSnapshot(req.textDocument.uri)
503504
throw ResponseError.requestFailed(doccDocumentationError: .unsupportedLanguage(snapshot.language))
504505
}
505506
#endif

Sources/InProcessClient/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set_target_properties(InProcessClient PROPERTIES
77

88
target_link_libraries(InProcessClient PUBLIC
99
BuildServerIntegration
10+
ClangLanguageService
1011
LanguageServerProtocol
1112
SKLogging
1213
SKOptions

Sources/InProcessClient/LanguageServiceRegistry+staticallyKnownServices.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 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 ClangLanguageService
114
import LanguageServerProtocol
215
package import SourceKitLSP
316

Sources/SourceKitLSP/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ add_library(SourceKitLSP STATIC
33
CapabilityRegistry.swift
44
DocumentManager.swift
55
DocumentSnapshot+FromFileContents.swift
6+
DocumentSnapshot+PositionConversions.swift
67
Hooks.swift
78
IndexProgressManager.swift
89
IndexStoreDB+MainFilesProvider.swift
@@ -21,10 +22,6 @@ add_library(SourceKitLSP STATIC
2122
TextEdit+IsNoop.swift
2223
Workspace.swift
2324
)
24-
target_sources(SourceKitLSP PRIVATE
25-
Clang/ClangLanguageService.swift
26-
Clang/SemanticTokenTranslator.swift
27-
)
2825
target_sources(SourceKitLSP PRIVATE
2926
Documentation/DocCDocumentationHandler.swift
3027
Documentation/DocumentationLanguageService.swift

0 commit comments

Comments
 (0)