Skip to content

Commit 67e5f17

Browse files
author
Wang Lun
committed
revert changes
1 parent e147601 commit 67e5f17

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ package actor SourceKitLSPServer {
553553
}
554554

555555
let toolchain = await workspace.buildServerManager.toolchain(
556-
for: uri.buildSettingsFile,
556+
for: uri,
557557
in: workspace.buildServerManager.canonicalTarget(for: uri),
558558
language: language
559559
)
@@ -2066,16 +2066,14 @@ extension SourceKitLSPServer {
20662066
languageService: LanguageService
20672067
) async throws -> Location {
20682068
// Check if we're already in the target interface with the same module/group/symbol
2069-
if let referenceDoc = try? ReferenceDocumentURL(from: originatorUri),
2070-
case .generatedInterface(let interfaceData) = referenceDoc,
2069+
if case .generatedInterface(let interfaceData) = try? ReferenceDocumentURL(from: originatorUri),
20712070
interfaceData.moduleName == moduleName && interfaceData.groupName == groupName {
2072-
20732071
// If we have a specific symbol USR, try to find its position in the current interface
20742072
if let symbolUSR = symbolUSR,
20752073
let swiftLanguageService = languageService as? SwiftLanguageService {
20762074
do {
20772075
let position = try await swiftLanguageService.generatedInterfaceManager.position(
2078-
ofUsr: symbolUSR,
2076+
ofUsr: symbolUSR,
20792077
in: interfaceData
20802078
)
20812079
return Location(uri: originatorUri, range: Range(position))

Sources/SourceKitLSP/Swift/GeneratedInterfaceManager.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,7 @@ actor GeneratedInterfaceManager {
9292
incrementingRefCount: Bool
9393
) async throws -> OpenGeneratedInterfaceDocumentDetails {
9494
func loadFromCache() -> OpenGeneratedInterfaceDocumentDetails? {
95-
// Cache by module name and group name, not the full document data
96-
// This allows reuse across different buildSettingsFrom URIs
97-
guard let cachedIndex = openInterfaces.firstIndex(where: {
98-
$0.url.moduleName == document.moduleName &&
99-
$0.url.groupName == document.groupName &&
100-
$0.url.sourcekitdDocumentName == document.sourcekitdDocumentName
101-
}) else {
95+
guard let cachedIndex = openInterfaces.firstIndex(where: { $0.url == document }) else {
10296
return nil
10397
}
10498
if incrementingRefCount {
@@ -166,11 +160,8 @@ actor GeneratedInterfaceManager {
166160
}
167161

168162
private func decrementRefCount(for document: GeneratedInterfaceDocumentURLData) {
169-
guard let cachedIndex = openInterfaces.firstIndex(where: {
170-
$0.url.moduleName == document.moduleName &&
171-
$0.url.groupName == document.groupName &&
172-
$0.url.sourcekitdDocumentName == document.sourcekitdDocumentName
173-
}) else { logger.fault(
163+
guard let cachedIndex = openInterfaces.firstIndex(where: { $0.url == document }) else {
164+
logger.fault(
174165
"Generated interface document for \(document.moduleName) is not open anymore. Unbalanced retain and releases?"
175166
)
176167
return

Sources/SourceKitLSP/Workspace.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,11 @@ package final class Workspace: Sendable, BuildServerManagerDelegate {
432432
/// document is returned.
433433
func setDocumentService(for uri: DocumentURI, _ newLanguageService: any LanguageService) -> LanguageService {
434434
return documentService.withLock { service in
435-
let key = uri.buildSettingsFile
436-
if let languageService = service[key] {
435+
if let languageService = service[uri] {
437436
return languageService
438437
}
439438

440-
service[key] = newLanguageService
439+
service[uri] = newLanguageService
441440
return newLanguageService
442441
}
443442
}

0 commit comments

Comments
 (0)