Skip to content

Commit 4058ac6

Browse files
author
Wang Lun
committed
fixed group of module can't navi, no langserver for swiftinterface
1 parent 56a91e9 commit 4058ac6

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

Sources/LanguageServerProtocolExtensions/Language+Inference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension Language {
3939
case "cpp", "cc", "cxx", "hpp": self = .cpp
4040
case "m": self = .objective_c
4141
case "mm", "h": self = .objective_cpp
42-
case "swift": self = .swift
42+
case "swift", "swiftinterface": self = .swift
4343
default: return nil
4444
}
4545
}

Sources/SKTestSupport/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension Language {
3232
case "cpp": self = .cpp
3333
case "m": self = .objective_c
3434
case "mm": self = .objective_cpp
35-
case "swift": self = .swift
35+
case "swift", "swiftinterface": self = .swift
3636
case "md": self = .markdown
3737
case "tutorial": self = .tutorial
3838
default: return nil

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 18 additions & 4 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,
556+
for: uri.buildSettingsFile,
557557
in: workspace.buildServerManager.canonicalTarget(for: uri),
558558
language: language
559559
)
@@ -1850,10 +1850,24 @@ extension SourceKitLSPServer {
18501850
languageService: LanguageService
18511851
) async throws -> [Location] {
18521852
// If this symbol is a module then generate a textual interface
1853-
if symbol.kind == .module, let name = symbol.name {
1853+
if symbol.kind == .module {
1854+
// For module symbols, prefer using systemModule information if available
1855+
let moduleName: String
1856+
let groupName: String?
1857+
1858+
if let systemModule = symbol.systemModule {
1859+
moduleName = systemModule.moduleName
1860+
groupName = systemModule.groupName
1861+
} else if let name = symbol.name {
1862+
moduleName = name
1863+
groupName = nil
1864+
} else {
1865+
return []
1866+
}
1867+
18541868
let interfaceLocation = try await self.definitionInInterface(
1855-
moduleName: name,
1856-
groupName: nil,
1869+
moduleName: moduleName,
1870+
groupName: groupName,
18571871
symbolUSR: nil,
18581872
originatorUri: uri,
18591873
languageService: languageService

Sources/SourceKitLSP/Swift/ReferenceDocumentURL.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,14 @@ extension DocumentURI {
165165
return referenceDocument.buildSettingsFile
166166
}
167167
return self
168+
} /// Convert sourcekit-lsp:// URIs to actual file system paths when possible.
169+
/// For generated Swift interfaces, this returns the path where the interface file
170+
/// would be stored in the GeneratedInterfaces directory.
171+
var actualFileSystemPath: DocumentURI {
172+
return self
168173
}
169174
}
170175

171176
package struct ReferenceDocumentURLError: Error, CustomStringConvertible {
172177
package var description: String
173-
174-
init(description: String) {
175-
self.description = description
176-
}
177178
}

0 commit comments

Comments
 (0)