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:
Alex Hoppen
2019-11-18 16:18:05 -08:00
committed by Ben Langmuir
parent fcfaa505d7
commit 5c839f8640
46 changed files with 609 additions and 426 deletions

View File

@@ -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))