Revert "[clangd] Change index scope convention from "outer::inner" to "outer::inner::""

This reverts commit r322996.

llvm-svn: 322998
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index ab8a22d..1a95b6b 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -313,7 +313,7 @@
 /// completion (e.g. "ns::ab?").
 struct SpecifiedScope {
   /// The scope specifier as written. For example, for completion "ns::ab?", the
-  /// written scope specifier is "ns::". Doesn't include leading "::".
+  /// written scope specifier is "ns".
   std::string Written;
   // If this scope specifier is recognized in Sema (e.g. as a namespace
   // context), this will be set to the fully qualfied name of the corresponding
@@ -321,7 +321,8 @@
   std::string Resolved;
 
   llvm::StringRef forIndex() {
-    return Resolved.empty() ? Written.ltrim('::') : Resolved;
+    llvm::StringRef Chosen = Resolved.empty() ? Written : Resolved;
+    return Chosen.trim(':');
   }
 };
 
@@ -630,14 +631,15 @@
   auto SpecifierRange = SS.getRange();
   Info.Written = Lexer::getSourceText(
       CharSourceRange::getCharRange(SpecifierRange), SM, clang::LangOptions());
-  if (!Info.Written.empty())
-    Info.Written += "::"; // Sema excludes the trailing ::.
   if (SS.isValid()) {
     DeclContext *DC = S.computeDeclContext(SS);
     if (auto *NS = llvm::dyn_cast<NamespaceDecl>(DC)) {
-      Info.Resolved = NS->getQualifiedNameAsString() + "::";
+      Info.Resolved = NS->getQualifiedNameAsString();
     } else if (llvm::dyn_cast<TranslationUnitDecl>(DC) != nullptr) {
-      Info.Resolved = "";
+      Info.Resolved = "::";
+      // Sema does not include the suffix "::" in the range of SS, so we add
+      // it back here.
+      Info.Written = "::";
     }
   }
   return Info;