mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +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
@@ -149,34 +149,38 @@ extension BuildServerBuildSystem: BuildSystem {
|
||||
|
||||
/// Register the given file for build-system level change notifications, such as command
|
||||
/// line flag changes, dependency changes, etc.
|
||||
public func registerForChangeNotifications(for url: LanguageServerProtocol.URL) {
|
||||
let request = RegisterForChanges(uri: url, action: .register)
|
||||
public func registerForChangeNotifications(for uri: DocumentURI) {
|
||||
let request = RegisterForChanges(uri: uri, action: .register)
|
||||
_ = self.buildServer?.send(request, queue: requestQueue, reply: { result in
|
||||
if let error = result.failure {
|
||||
log("error registering \(url): \(error)", level: .error)
|
||||
log("error registering \(uri): \(error)", level: .error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Unregister the given file for build-system level change notifications, such as command
|
||||
/// line flag changes, dependency changes, etc.
|
||||
public func unregisterForChangeNotifications(for url: LanguageServerProtocol.URL) {
|
||||
let request = RegisterForChanges(uri: url, action: .unregister)
|
||||
public func unregisterForChangeNotifications(for uri: DocumentURI) {
|
||||
let request = RegisterForChanges(uri: uri, action: .unregister)
|
||||
_ = self.buildServer?.send(request, queue: requestQueue, reply: { result in
|
||||
if let error = result.failure {
|
||||
log("error unregistering \(url): \(error)", level: .error)
|
||||
log("error unregistering \(uri): \(error)", level: .error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
if let response = try? self.buildServer?.sendSync(SourceKitOptions(uri: url)) {
|
||||
return FileBuildSettings(compilerArguments: response.options, workingDirectory: response.workingDirectory)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func toolchain(for: URL, _ language: Language) -> Toolchain? {
|
||||
public func toolchain(for: DocumentURI, _ language: Language) -> Toolchain? {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user