| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTWORKSPACE_H |
| 17 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTWORKSPACE_H |
| 18 |
|
| 19 |
#include "TestTU.h" |
| 20 |
#include "index/Index.h" |
| 21 |
#include "llvm/ADT/StringRef.h" |
| 22 |
#include <optional> |
| 23 |
#include <string> |
| 24 |
#include <vector> |
| 25 |
|
| 26 |
namespace clang { |
| 27 |
namespace clangd { |
| 28 |
|
| 29 |
class TestWorkspace { |
| 30 |
public: |
| 31 |
|
| 32 |
|
| 33 |
void addSource(llvm::StringRef Filename, llvm::StringRef Code) { |
| 34 |
addInput(Filename.str(), {Code.str(), false}); |
| 35 |
} |
| 36 |
void addMainFile(llvm::StringRef Filename, llvm::StringRef Code) { |
| 37 |
addInput(Filename.str(), {Code.str(), true}); |
| 38 |
} |
| 39 |
|
| 40 |
std::unique_ptr<SymbolIndex> index(); |
| 41 |
|
| 42 |
std::optional<ParsedAST> openFile(llvm::StringRef Filename); |
| 43 |
|
| 44 |
private: |
| 45 |
struct SourceFile { |
| 46 |
std::string Code; |
| 47 |
bool IsMainFile = false; |
| 48 |
}; |
| 49 |
llvm::StringMap<SourceFile> Inputs; |
| 50 |
TestTU TU; |
| 51 |
|
| 52 |
void addInput(llvm::StringRef Filename, const SourceFile &Input); |
| 53 |
}; |
| 54 |
|
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
#endif |