mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-06 18:24:36 +01:00
Add support for non-URL URIs
According to the LSP specification, arbitrary URIs can be used as document identifiers. Instead of internally assuming that all URIs are URLs, use a DocumentURI enum to represent URIs. These can either be file URLs or other URIs whose value as treated as an opaque string.
This commit is contained in:
committed by
Ben Langmuir
parent
fcfaa505d7
commit
5c839f8640
@@ -44,7 +44,11 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
|
||||
public var indexStorePath: AbsolutePath? { return nil }
|
||||
public var indexDatabasePath: AbsolutePath? { return nil }
|
||||
|
||||
public func settings(for url: URL, _ language: Language) -> FileBuildSettings? {
|
||||
public func settings(for uri: DocumentURI, _ language: Language) -> FileBuildSettings? {
|
||||
guard case .url(let url) = uri else {
|
||||
// We can't determine build settings for non-file URIs.
|
||||
return nil
|
||||
}
|
||||
guard let db = database(for: url),
|
||||
let cmd = db[url].first else { return nil }
|
||||
return FileBuildSettings(
|
||||
@@ -53,13 +57,13 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
|
||||
)
|
||||
}
|
||||
|
||||
public func toolchain(for: URL, _ language: Language) -> Toolchain? { return nil }
|
||||
public func toolchain(for: DocumentURI, _ language: Language) -> Toolchain? { return nil }
|
||||
|
||||
/// We don't support change watching.
|
||||
public func registerForChangeNotifications(for: URL) {}
|
||||
public func registerForChangeNotifications(for: DocumentURI) {}
|
||||
|
||||
/// We don't support change watching.
|
||||
public func unregisterForChangeNotifications(for: URL) {}
|
||||
public func unregisterForChangeNotifications(for: DocumentURI) {}
|
||||
|
||||
public func buildTargets(reply: @escaping (LSPResult<[BuildTarget]>) -> Void) {
|
||||
reply(.failure(buildTargetsNotSupported))
|
||||
|
||||
Reference in New Issue
Block a user