[clangd] Cleanup: stop passing around list of supported URI schemes.

Summary:
Instead of passing around a list of supported URI schemes in clangd, we
expose an interface to convert a path to URI using any compatible scheme
that has been registered. It favors customized schemes and falls
back to "file" when no other scheme works.

Changes in this patch are:
- URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a
compatible scheme from the registry.
- Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex etc).
- Unit tests will use "unittest" by default.
- Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only
register the test scheme when lit-test or enable-lit-scheme is set.
(The new flag is added to make lit protocol.test work; I wonder if there
is alternative here.)

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54800

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347467 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/URI.cpp b/clangd/URI.cpp
index d7b3a63..649fbbc 100644
--- a/clangd/URI.cpp
+++ b/clangd/URI.cpp
@@ -195,12 +195,15 @@
   return S->get()->uriFromAbsolutePath(AbsolutePath);
 }
 
-Expected<URI> URI::create(StringRef AbsolutePath,
-                          const std::vector<std::string> &Schemes) {
+URI URI::create(StringRef AbsolutePath) {
   if (!sys::path::is_absolute(AbsolutePath))
-    return make_string_error("Not a valid absolute path: " + AbsolutePath);
-  for (const auto &Scheme : Schemes) {
-    auto URI = URI::create(AbsolutePath, Scheme);
+    llvm_unreachable(
+        ("Not a valid absolute path: " + AbsolutePath).str().c_str());
+  for (auto &Entry : URISchemeRegistry::entries()) {
+    if (Entry.getName() == "file")
+      continue;
+
+    auto URI = Entry.instantiate()->uriFromAbsolutePath(AbsolutePath);
     // For some paths, conversion to different URI schemes is impossible. These
     // should be just skipped.
     if (!URI) {
@@ -208,10 +211,10 @@
       consumeError(URI.takeError());
       continue;
     }
-    return URI;
+    return std::move(*URI);
   }
-  return make_string_error("Couldn't convert " + AbsolutePath +
-                           " to any given scheme: " + join(Schemes, ", "));
+  // Fallback to file: scheme which should work for any paths.
+  return URI::createFile(AbsolutePath);
 }
 
 URI URI::createFile(StringRef AbsolutePath) {