| 18 | std::string main_path; |
| 19 | |
| 20 | void code_complete(llvm::StringRef code, feature::CodeCompletionOptions options = {}) { |
| 21 | vfs = llvm::makeIntrusiveRefCnt<TestVFS>(); |
| 22 | |
| 23 | CompilationParams params; |
| 24 | auto annotation = AnnotatedSource::from(code); |
| 25 | |
| 26 | vfs->add("main.cpp", annotation.content); |
| 27 | params.vfs = vfs; |
| 28 | main_path = TestVFS::path("main.cpp"); |
| 29 | params.arguments = |
| 30 | {"clang++", "-std=c++20", "-ffreestanding", "-Xclang", "-undef", main_path.c_str()}; |
| 31 | params.completion = {main_path, annotation.offsets.lookup("pos")}; |
| 32 | params.add_remapped_file(main_path, annotation.content); |
| 33 | |
| 34 | items = feature::code_complete(params, options, feature::PositionEncoding::UTF8); |
| 35 | } |
| 36 | |
| 37 | auto find_item(llvm::StringRef label) { |
| 38 | return std::ranges::find_if(items, [&](const protocol::CompletionItem& item) { |
no test coverage detected