Commit 079ef783 authored by Dmitri Gribenko's avatar Dmitri Gribenko
Browse files

Revert "[clangd] Implement "textDocument/documentLink" protocol support"

This reverts commit d6417f55. The tests
depend on builtin headers, which is not intentionally supported in
clangd tests; these tests are broken in some build environments.
parent 4658da10
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
@@ -566,10 +566,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
            {"declarationProvider", true},
            {"definitionProvider", true},
            {"documentHighlightProvider", true},
            {"documentLinkProvider",
             llvm::json::Object{
                 {"resolveProvider", false},
             }},
            {"hoverProvider", true},
            {"renameProvider", std::move(RenameProvider)},
            {"selectionRangeProvider", true},
@@ -1204,25 +1200,6 @@ void ClangdLSPServer::onSelectionRange(
      });
}

void ClangdLSPServer::onDocumentLink(
    const DocumentLinkParams &Params,
    Callback<std::vector<DocumentLink>> Reply) {

  // TODO(forster): This currently resolves all targets eagerly. This is slow,
  // because it blocks on the preamble/AST being built. We could respond to the
  // request faster by using string matching or the lexer to find the includes
  // and resolving the targets lazily.
  Server->documentLinks(
      Params.textDocument.uri.file(),
      [Reply = std::move(Reply)](
          llvm::Expected<std::vector<DocumentLink>> Links) mutable {
        if (!Links) {
          return Reply(Links.takeError());
        }
        return Reply(std::move(Links));
      });
}

ClangdLSPServer::ClangdLSPServer(
    class Transport &Transp, const FileSystemProvider &FSProvider,
    const clangd::CodeCompleteOptions &CCOpts,
@@ -1266,7 +1243,6 @@ ClangdLSPServer::ClangdLSPServer(
  MsgHandler->bind("textDocument/typeHierarchy", &ClangdLSPServer::onTypeHierarchy);
  MsgHandler->bind("typeHierarchy/resolve", &ClangdLSPServer::onResolveTypeHierarchy);
  MsgHandler->bind("textDocument/selectionRange", &ClangdLSPServer::onSelectionRange);
  MsgHandler->bind("textDocument/documentLink", &ClangdLSPServer::onDocumentLink);
  // clang-format on
}

+0 −2
Original line number Diff line number Diff line
@@ -111,8 +111,6 @@ private:
                    Callback<std::vector<SymbolDetails>>);
  void onSelectionRange(const SelectionRangeParams &,
                        Callback<std::vector<SelectionRange>>);
  void onDocumentLink(const DocumentLinkParams &,
                      Callback<std::vector<DocumentLink>>);

  std::vector<Fix> getFixes(StringRef File, const clangd::Diagnostic &D);

+0 −11
Original line number Diff line number Diff line
@@ -611,17 +611,6 @@ void ClangdServer::semanticRanges(PathRef File, Position Pos,
  WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
}

void ClangdServer::documentLinks(PathRef File,
                                 Callback<std::vector<DocumentLink>> CB) {
  auto Action =
      [CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable {
        if (!InpAST)
          return CB(InpAST.takeError());
        CB(clangd::getDocumentLinks(InpAST->AST));
      };
  WorkScheduler.runWithAST("DocumentLinks", File, std::move(Action));
}

std::vector<std::pair<Path, std::size_t>>
ClangdServer::getUsedBytesPerFile() const {
  return WorkScheduler.getUsedBytesPerFile();
+0 −3
Original line number Diff line number Diff line
@@ -287,9 +287,6 @@ public:
  void semanticRanges(PathRef File, Position Pos,
                      Callback<std::vector<Range>> CB);

  /// Get all document links in a file.
  void documentLinks(PathRef File, Callback<std::vector<DocumentLink>> CB);
 
  /// Returns estimated memory usage for each of the currently open files.
  /// The order of results is unspecified.
  /// Overall memory usage of clangd may be significantly more than reported
+0 −13
Original line number Diff line number Diff line
@@ -1087,18 +1087,5 @@ llvm::json::Value toJSON(const SelectionRange &Out) {
  }
  return llvm::json::Object{{"range", Out.range}};
}

bool fromJSON(const llvm::json::Value &Params, DocumentLinkParams &R) {
  llvm::json::ObjectMapper O(Params);
  return O && O.map("textDocument", R.textDocument);
}

llvm::json::Value toJSON(const DocumentLink &DocumentLink) {
  return llvm::json::Object{
      {"range", DocumentLink.range},
      {"target", DocumentLink.target},
  };
}

} // namespace clangd
} // namespace clang
Loading