2018-02-12 19:37:28 +08:00
|
|
|
//===--- SyncAPI.h - Sync version of ClangdServer's API ----------*- C++-*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
2018-08-15 00:03:32 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2018-02-12 19:37:28 +08:00
|
|
|
// This file contains synchronous versions of ClangdServer's async API. We
|
|
|
|
// deliberately don't expose the sync API outside tests to encourage using the
|
|
|
|
// async versions in clangd code.
|
2018-08-15 00:03:32 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-02-12 19:37:28 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
|
|
|
|
|
|
|
|
#include "ClangdServer.h"
|
[clangd] Minimal implementation of automatic static index (not enabled).
Summary:
See tinyurl.com/clangd-automatic-index for design and goals.
Lots of limitations to keep this patch smallish, TODOs everywhere:
- no serialization to disk
- no changes to dynamic index, which now has a much simpler job
- no partitioning of symbols by file to avoid duplication of header symbols
- no reindexing of edited files
- only a single worker thread
- compilation database is slurped synchronously (doesn't scale)
- uses memindex, rebuilds after every file (should be dex, periodically)
It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering
isn't clear (it should really be in ClangdServer, but ClangdLSPServer
has all the CDB interactions).
Reviewers: ioeric
Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D53032
llvm-svn: 344513
2018-10-15 21:34:10 +08:00
|
|
|
#include "index/Index.h"
|
2018-02-12 19:37:28 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace clangd {
|
|
|
|
|
2018-03-06 01:28:54 +08:00
|
|
|
// Calls addDocument and then blockUntilIdleForTest.
|
2018-03-15 01:08:41 +08:00
|
|
|
void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
|
2018-06-13 17:20:41 +08:00
|
|
|
WantDiagnostics WantDiags = WantDiagnostics::Auto);
|
2018-03-06 01:28:54 +08:00
|
|
|
|
2018-07-02 19:13:16 +08:00
|
|
|
llvm::Expected<CodeCompleteResult>
|
2018-03-13 07:22:35 +08:00
|
|
|
runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
|
|
|
|
clangd::CodeCompleteOptions Opts);
|
2018-02-15 21:15:47 +08:00
|
|
|
|
2018-03-13 07:22:35 +08:00
|
|
|
llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server,
|
|
|
|
PathRef File, Position Pos);
|
2018-02-15 21:15:47 +08:00
|
|
|
|
2018-03-13 07:22:35 +08:00
|
|
|
llvm::Expected<std::vector<Location>>
|
2018-02-15 21:15:47 +08:00
|
|
|
runFindDefinitions(ClangdServer &Server, PathRef File, Position Pos);
|
|
|
|
|
2018-03-13 07:22:35 +08:00
|
|
|
llvm::Expected<std::vector<DocumentHighlight>>
|
2018-02-15 21:15:47 +08:00
|
|
|
runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
|
|
|
|
|
|
|
|
llvm::Expected<std::vector<tooling::Replacement>>
|
|
|
|
runRename(ClangdServer &Server, PathRef File, Position Pos, StringRef NewName);
|
|
|
|
|
|
|
|
std::string runDumpAST(ClangdServer &Server, PathRef File);
|
|
|
|
|
[clangd] Implementation of workspace/symbol request
Summary:
This is a basic implementation of the "workspace/symbol" request which is
used to find symbols by a string query. Since this is similar to code completion
in terms of result, this implementation reuses the "fuzzyFind" in order to get
matches. For now, the scoring algorithm is the same as code completion and
improvements could be done in the future.
The index model doesn't contain quite enough symbols for this to cover
common symbols like methods, enum class enumerators, functions in unamed
namespaces, etc. The index model will be augmented separately to achieve this.
Reviewers: sammccall, ilya-biryukov
Reviewed By: sammccall
Subscribers: jkorous, hokein, simark, sammccall, klimek, mgorny, ilya-biryukov, mgrang, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D44882
llvm-svn: 330637
2018-04-24 04:00:52 +08:00
|
|
|
llvm::Expected<std::vector<SymbolInformation>>
|
|
|
|
runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
|
|
|
|
|
2018-07-06 03:35:01 +08:00
|
|
|
llvm::Expected<std::vector<SymbolInformation>>
|
|
|
|
runDocumentSymbols(ClangdServer &Server, PathRef File);
|
|
|
|
|
[clangd] Minimal implementation of automatic static index (not enabled).
Summary:
See tinyurl.com/clangd-automatic-index for design and goals.
Lots of limitations to keep this patch smallish, TODOs everywhere:
- no serialization to disk
- no changes to dynamic index, which now has a much simpler job
- no partitioning of symbols by file to avoid duplication of header symbols
- no reindexing of edited files
- only a single worker thread
- compilation database is slurped synchronously (doesn't scale)
- uses memindex, rebuilds after every file (should be dex, periodically)
It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering
isn't clear (it should really be in ClangdServer, but ClangdLSPServer
has all the CDB interactions).
Reviewers: ioeric
Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D53032
llvm-svn: 344513
2018-10-15 21:34:10 +08:00
|
|
|
SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);
|
|
|
|
SymbolSlab runFuzzyFind(const SymbolIndex &Index, const FuzzyFindRequest &Req);
|
|
|
|
|
2018-02-12 19:37:28 +08:00
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|
|
|
|
|
2018-08-15 00:03:32 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
|