mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
When indexing make sure we use the correct contents.
Hopefully this will make overlapping saves more robust.
This commit is contained in:
parent
d8567c75cc
commit
f907d1d1b9
@ -1006,7 +1006,8 @@ void ParseFile(IndexerConfig* config,
|
||||
|
||||
std::vector<std::unique_ptr<IndexFile>> indexes = Parse(
|
||||
config, file_consumer_shared,
|
||||
tu_path, tu_args);
|
||||
tu_path, tu_args,
|
||||
entry.filename, indexed_content);
|
||||
time.ResetAndPrint("Parsing/indexing " + tu_path);
|
||||
|
||||
for (std::unique_ptr<IndexFile>& new_index : indexes) {
|
||||
|
@ -1380,6 +1380,8 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
||||
IndexerConfig* config, FileConsumer::SharedState* file_consumer_shared,
|
||||
std::string file,
|
||||
std::vector<std::string> args,
|
||||
const std::string& file_contents_path,
|
||||
const optional<std::string>& file_contents,
|
||||
bool dump_ast) {
|
||||
|
||||
if (!config->enableIndexing)
|
||||
@ -1390,6 +1392,13 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
||||
clang::Index index(0 /*excludeDeclarationsFromPCH*/,
|
||||
0 /*displayDiagnostics*/);
|
||||
std::vector<CXUnsavedFile> unsaved_files;
|
||||
if (file_contents) {
|
||||
CXUnsavedFile unsaved;
|
||||
unsaved.Filename = file_contents_path.c_str();
|
||||
unsaved.Contents = file_contents->c_str();
|
||||
unsaved.Length = file_contents->size();
|
||||
unsaved_files.push_back(unsaved);
|
||||
}
|
||||
clang::TranslationUnit tu(index, file, args, unsaved_files, CXTranslationUnit_KeepGoing);
|
||||
|
||||
if (dump_ast)
|
||||
|
@ -506,5 +506,7 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
||||
IndexerConfig* config, FileConsumer::SharedState* file_consumer_shared,
|
||||
std::string file,
|
||||
std::vector<std::string> args,
|
||||
const std::string& file_contents_path,
|
||||
const optional<std::string>& file_contents,
|
||||
bool dump_ast = false);
|
||||
void IndexInit();
|
||||
|
@ -148,6 +148,7 @@ void RunTests() {
|
||||
"-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include",
|
||||
"-IC:/Users/jacob/Desktop/superindex/indexer/src"
|
||||
},
|
||||
"", nullopt,
|
||||
false /*dump_ast*/);
|
||||
|
||||
#if false
|
||||
|
Loading…
Reference in New Issue
Block a user