Skip to content

Commit aa6301b

Browse files
authored
Merge pull request #2249 from ahoppen/merge-docc
Merge `DocumentationLanguageService` and `DocCDocumentation` modules
2 parents c1a8301 + 49e1c38 commit aa6301b

21 files changed

+129
-122
lines changed

Package.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ var targets: [Target] = [
133133
name: "ClangLanguageService",
134134
dependencies: [
135135
"BuildServerIntegration",
136-
"DocCDocumentation",
137136
"LanguageServerProtocol",
138137
"LanguageServerProtocolExtensions",
139138
"LanguageServerProtocolJSONRPC",
@@ -243,27 +242,17 @@ var targets: [Target] = [
243242
name: "DocumentationLanguageService",
244243
dependencies: [
245244
"BuildServerIntegration",
246-
"DocCDocumentation",
247-
"LanguageServerProtocol",
248-
"SKUtilities",
249-
"SourceKitLSP",
250-
"SemanticIndex",
251-
.product(name: "Markdown", package: "swift-markdown"),
252-
],
253-
exclude: [],
254-
swiftSettings: globalSwiftSettings
255-
),
256-
257-
.target(
258-
name: "DocCDocumentation",
259-
dependencies: [
260245
"BuildServerProtocol",
261-
"BuildServerIntegration",
262246
"LanguageServerProtocol",
247+
248+
"SemanticIndex",
263249
"SemanticIndex",
264250
"SKLogging",
251+
"SKUtilities",
252+
"SourceKitLSP",
265253
"SwiftExtensions",
266254
.product(name: "IndexStoreDB", package: "indexstore-db"),
255+
.product(name: "Markdown", package: "swift-markdown"),
267256
.product(name: "SwiftDocC", package: "swift-docc"),
268257
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
269258
],
@@ -538,7 +527,6 @@ var targets: [Target] = [
538527
dependencies: [
539528
"BuildServerProtocol",
540529
"BuildServerIntegration",
541-
"DocCDocumentation",
542530
"LanguageServerProtocol",
543531
"LanguageServerProtocolExtensions",
544532
"LanguageServerProtocolJSONRPC",
@@ -614,7 +602,6 @@ var targets: [Target] = [
614602
"BuildServerProtocol",
615603
"BuildServerIntegration",
616604
"Csourcekitd",
617-
"DocCDocumentation",
618605
"LanguageServerProtocol",
619606
"LanguageServerProtocolExtensions",
620607
"LanguageServerProtocolJSONRPC",

Sources/DocCDocumentation/BuildSystemIntegrationExtensions.swift renamed to Sources/DocumentationLanguageService/BuildSystemIntegrationExtensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
package import BuildServerIntegration
14-
package import BuildServerProtocol
15-
package import Foundation
13+
import BuildServerIntegration
14+
import BuildServerProtocol
15+
import Foundation
1616
import LanguageServerProtocol
1717
import SKLogging
1818

19-
package extension BuildServerManager {
19+
extension BuildServerManager {
2020
/// Retrieves the name of the Swift module for a given target.
2121
///
2222
/// **Note:** prefer using ``module(for:in:)`` over ths function. This function

Sources/DocCDocumentation/DocCCatalogIndexManager.swift renamed to Sources/DocumentationLanguageService/DocCCatalogIndexManager.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
package import Foundation
13+
import Foundation
1414
import SKLogging
1515
import SKUtilities
1616
@_spi(LinkCompletion) @preconcurrency import SwiftDocC
@@ -71,12 +71,12 @@ final actor DocCCatalogIndexManager {
7171
}
7272

7373
/// Represents a potential error that the ``DocCCatalogIndexManager`` could encounter while indexing
74-
package enum DocCIndexError: LocalizedError {
74+
enum DocCIndexError: LocalizedError {
7575
case internalError(any Error)
7676
case unexpectedlyNilRenderReferenceStore
7777
case cancelled
7878

79-
package var errorDescription: String? {
79+
var errorDescription: String? {
8080
switch self {
8181
case .internalError(let internalError):
8282
return "An internal error occurred: \(internalError.localizedDescription)"
@@ -88,7 +88,7 @@ package enum DocCIndexError: LocalizedError {
8888
}
8989
}
9090

91-
package struct DocCCatalogIndex: Sendable {
91+
struct DocCCatalogIndex: Sendable {
9292
/// A map from an asset name to its DataAsset contents.
9393
let assets: [String: DataAsset]
9494

@@ -107,7 +107,7 @@ package struct DocCCatalogIndex: Sendable {
107107
/// Retrieves the documentation extension URL for the given symbol if one exists.
108108
///
109109
/// - Parameter symbolInformation: The `DocCSymbolInformation` representing the symbol to search for.
110-
package func documentationExtension(for symbolInformation: DocCSymbolInformation) -> URL? {
110+
func documentationExtension(for symbolInformation: DocCSymbolInformation) -> URL? {
111111
documentationExtensions.filter { symbolInformation.matches($0.link) }.first?.documentURL
112112
}
113113

Sources/DocCDocumentation/DocCDocumentationManager.swift renamed to Sources/DocumentationLanguageService/DocCDocumentationManager.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
package import BuildServerIntegration
13+
import BuildServerIntegration
1414
import BuildServerProtocol
15-
package import Foundation
16-
package import LanguageServerProtocol
15+
import Foundation
16+
import LanguageServerProtocol
1717
import SKLogging
1818
import SwiftDocC
1919

20-
package struct DocCDocumentationManager: Sendable {
20+
struct DocCDocumentationManager: Sendable {
2121
private let doccServer: DocCServer
2222
private let referenceResolutionService: DocCReferenceResolutionService
2323
private let catalogIndexManager: DocCCatalogIndexManager
2424

2525
private let buildServerManager: BuildServerManager
2626

27-
package init(buildServerManager: BuildServerManager) {
27+
init(buildServerManager: BuildServerManager) {
2828
let symbolResolutionServer = DocumentationServer(qualityOfService: .unspecified)
2929
doccServer = DocCServer(
3030
peer: symbolResolutionServer,
@@ -36,7 +36,7 @@ package struct DocCDocumentationManager: Sendable {
3636
self.buildServerManager = buildServerManager
3737
}
3838

39-
package func filesDidChange(_ events: [FileEvent]) async {
39+
func filesDidChange(_ events: [FileEvent]) async {
4040
for event in events {
4141
for target in await buildServerManager.targets(for: event.uri) {
4242
guard let catalogURL = await buildServerManager.doccCatalog(for: target) else {
@@ -47,7 +47,7 @@ package struct DocCDocumentationManager: Sendable {
4747
}
4848
}
4949

50-
package func catalogIndex(for catalogURL: URL) async throws(DocCIndexError) -> DocCCatalogIndex {
50+
func catalogIndex(for catalogURL: URL) async throws(DocCIndexError) -> DocCCatalogIndex {
5151
try await catalogIndexManager.index(for: catalogURL)
5252
}
5353

@@ -63,7 +63,7 @@ package struct DocCDocumentationManager: Sendable {
6363
/// - catalogURL: The URL pointing to the docc catalog that this symbol, tutorial, or markdown file is a part of
6464
/// - Throws: A ResponseError if something went wrong
6565
/// - Returns: The DoccDocumentationResponse containing the RenderNode if successful
66-
package func renderDocCDocumentation(
66+
func renderDocCDocumentation(
6767
symbolUSR: String? = nil,
6868
symbolGraph: String? = nil,
6969
overrideDocComments: [String]? = nil,
File renamed without changes.

Sources/DocCDocumentation/DocCServer.swift renamed to Sources/DocumentationLanguageService/DocCServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Foundation
1414
@preconcurrency import SwiftDocC
1515

16-
package struct DocCServer {
16+
struct DocCServer {
1717
private let server: DocumentationServer
1818

1919
init(peer peerServer: DocumentationServer? = nil, qualityOfService: DispatchQoS) {

Sources/DocCDocumentation/DocCSymbolInformation.swift renamed to Sources/DocumentationLanguageService/DocCSymbolInformation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
import SwiftExtensions
1616
import SymbolKit
1717

18-
package struct DocCSymbolInformation {
18+
struct DocCSymbolInformation {
1919
struct Component {
2020
let name: String
2121
let information: LinkCompletionTools.SymbolInformation
@@ -37,7 +37,7 @@ package struct DocCSymbolInformation {
3737
self.components = components
3838
}
3939

40-
package func matches(_ link: DocCSymbolLink) -> Bool {
40+
func matches(_ link: DocCSymbolLink) -> Bool {
4141
guard link.components.count == components.count else {
4242
return false
4343
}

Sources/DocCDocumentation/DocCSymbolLink.swift renamed to Sources/DocumentationLanguageService/DocCSymbolLink.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ import SemanticIndex
1616
@_spi(LinkCompletion) @preconcurrency import SwiftDocC
1717
import SymbolKit
1818

19-
package struct DocCSymbolLink: Sendable {
19+
struct DocCSymbolLink: Sendable {
2020
let linkString: String
2121
let components: [(name: String, disambiguation: LinkCompletionTools.ParsedDisambiguation)]
2222

2323
var symbolName: String {
2424
components.last!.name
2525
}
2626

27-
package init?(linkString: String) {
27+
init?(linkString: String) {
2828
let components = LinkCompletionTools.parse(linkString: linkString)
2929
guard !components.isEmpty else {
3030
return nil

Sources/DocCDocumentation/DoccDocumentationError.swift renamed to Sources/DocumentationLanguageService/DoccDocumentationError.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import Foundation
14-
package import LanguageServerProtocol
14+
import LanguageServerProtocol
1515

16-
package enum DocCDocumentationError: LocalizedError {
16+
enum DocCDocumentationError: LocalizedError {
1717
case unsupportedLanguage(Language)
18-
case noDocumentableSymbols
1918
case indexNotAvailable
2019
case symbolNotFound(String)
2120

2221
var errorDescription: String? {
2322
switch self {
2423
case .unsupportedLanguage(let language):
2524
return "Documentation preview is not available for \(language.description) files"
26-
case .noDocumentableSymbols:
27-
return "No documentable symbols were found in this Swift file"
2825
case .indexNotAvailable:
2926
return "The index is not availble to complete the request"
3027
case .symbolNotFound(let symbolName):
@@ -33,7 +30,7 @@ package enum DocCDocumentationError: LocalizedError {
3330
}
3431
}
3532

36-
package extension ResponseError {
33+
extension ResponseError {
3734
static func requestFailed(doccDocumentationError: DocCDocumentationError) -> ResponseError {
3835
return ResponseError.requestFailed(doccDocumentationError.localizedDescription)
3936
}

Sources/DocumentationLanguageService/DoccDocumentationHandler.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if canImport(DocCDocumentation)
1413
import BuildServerIntegration
15-
import DocCDocumentation
1614
import Foundation
1715
@preconcurrency import IndexStoreDB
1816
package import LanguageServerProtocol
1917
import Markdown
18+
import SKLogging
2019
import SKUtilities
21-
import SourceKitLSP
2220
import SemanticIndex
23-
import SKLogging
21+
import SourceKitLSP
2422

2523
extension DocumentationLanguageService {
2624
package func doccDocumentation(_ req: DoccDocumentationRequest) async throws -> DoccDocumentationResponse {
@@ -76,7 +74,7 @@ extension DocumentationLanguageService {
7674
moduleName: String?,
7775
catalogURL: URL?
7876
) async throws -> DoccDocumentationResponse {
79-
return try await workspace.doccDocumentationManager.renderDocCDocumentation(
77+
return try await documentationManager.renderDocCDocumentation(
8078
tutorialFile: snapshot.text,
8179
moduleName: moduleName,
8280
catalogURL: catalogURL
@@ -92,7 +90,7 @@ extension DocumentationLanguageService {
9290
guard let sourceKitLSPServer else {
9391
throw ResponseError.internalError("SourceKit-LSP is shutting down")
9492
}
95-
let documentationManager = workspace.doccDocumentationManager
93+
let documentationManager = documentationManager
9694
guard case .symbol(let symbolName) = MarkdownTitleFinder.find(parsing: snapshot.text) else {
9795
// This is an article that can be rendered on its own
9896
return try await documentationManager.renderDocCDocumentation(
@@ -171,7 +169,6 @@ extension DocumentationLanguageService {
171169
guard let sourceKitLSPServer else {
172170
throw ResponseError.internalError("SourceKit-LSP is shutting down")
173171
}
174-
let documentationManager = workspace.doccDocumentationManager
175172
let (symbolGraph, symbolUSR, overrideDocComments) = try await sourceKitLSPServer.primaryLanguageService(
176173
for: snapshot.uri,
177174
snapshot.language,
@@ -275,4 +272,3 @@ struct MarkdownTitleFinder: MarkupVisitor {
275272
return .plainText(heading.plainText)
276273
}
277274
}
278-
#endif

0 commit comments

Comments
 (0)