mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 21:58:08 +00:00
Indexer now has access to |config|
This commit is contained in:
parent
e259bb91d3
commit
c98d53cfe2
@ -188,11 +188,14 @@ void RunQueryDbThread(const std::string& bin_name,
|
||||
|
||||
ClangCompleteManager clang_complete(
|
||||
config, &project, &working_files,
|
||||
std::bind(&EmitDiagnostics, &working_files, std::placeholders::_1,
|
||||
std::placeholders::_2),
|
||||
std::bind(&IndexWithTuFromCodeCompletion, &file_consumer_shared,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3, std::placeholders::_4));
|
||||
[&](std::string path, std::vector<lsDiagnostic> diagnostics) {
|
||||
EmitDiagnostics(&working_files, path, diagnostics);
|
||||
},
|
||||
[&](ClangTranslationUnit* tu, const std::vector<CXUnsavedFile>& unsaved,
|
||||
const std::string& path, const std::vector<std::string>& args) {
|
||||
IndexWithTuFromCodeCompletion(config, &file_consumer_shared, tu,
|
||||
unsaved, path, args);
|
||||
});
|
||||
|
||||
IncludeComplete include_complete(config, &project);
|
||||
auto global_code_complete_cache = MakeUnique<CodeCompleteCache>();
|
||||
|
@ -521,6 +521,7 @@ ImportPipelineStatus::ImportPipelineStatus()
|
||||
// real-time indexing.
|
||||
// TODO: add option to disable this.
|
||||
void IndexWithTuFromCodeCompletion(
|
||||
Config* config,
|
||||
FileConsumerSharedState* file_consumer_shared,
|
||||
ClangTranslationUnit* tu,
|
||||
const std::vector<CXUnsavedFile>& file_contents,
|
||||
@ -530,8 +531,8 @@ void IndexWithTuFromCodeCompletion(
|
||||
|
||||
PerformanceImportFile perf;
|
||||
ClangIndex index;
|
||||
auto indexes = ParseWithTu(file_consumer_shared, &perf, tu, &index, path,
|
||||
args, file_contents);
|
||||
auto indexes = ParseWithTu(config, file_consumer_shared, &perf, tu, &index,
|
||||
path, args, file_contents);
|
||||
if (!indexes)
|
||||
return;
|
||||
|
||||
|
@ -26,6 +26,7 @@ struct ImportPipelineStatus {
|
||||
};
|
||||
|
||||
void IndexWithTuFromCodeCompletion(
|
||||
Config* config,
|
||||
FileConsumerSharedState* file_consumer_shared,
|
||||
ClangTranslationUnit* tu,
|
||||
const std::vector<CXUnsavedFile>& file_contents,
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
// Defined in command_line.cc
|
||||
extern bool g_debug;
|
||||
extern bool g_index_make_unique;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -237,6 +236,8 @@ struct ConstructorCache {
|
||||
};
|
||||
|
||||
struct IndexParam {
|
||||
Config* config = nullptr;
|
||||
|
||||
std::unordered_set<CXFile> seen_cx_files;
|
||||
std::vector<std::string> seen_files;
|
||||
FileContentsMap file_contents;
|
||||
@ -256,8 +257,8 @@ struct IndexParam {
|
||||
NamespaceHelper ns;
|
||||
ConstructorCache ctors;
|
||||
|
||||
IndexParam(ClangTranslationUnit* tu, FileConsumer* file_consumer)
|
||||
: tu(tu), file_consumer(file_consumer) {}
|
||||
IndexParam(Config* config, ClangTranslationUnit* tu, FileConsumer* file_consumer)
|
||||
: config(config), tu(tu), file_consumer(file_consumer) {}
|
||||
};
|
||||
|
||||
IndexFile* ConsumeFile(IndexParam* param, CXFile file) {
|
||||
@ -1967,7 +1968,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
|
||||
bool is_template = ref->referencedEntity->templateKind !=
|
||||
CXIdxEntityCXXTemplateKind::CXIdxEntity_NonTemplate;
|
||||
if (g_index_make_unique && is_template &&
|
||||
if (param->config->index.attributeMakeCallsToCtor && is_template &&
|
||||
str_begin("make", ref->referencedEntity->name)) {
|
||||
// Try to find the return type of called function. That type will have
|
||||
// the constructor function we add a usage to.
|
||||
@ -2099,11 +2100,12 @@ optional<std::vector<std::unique_ptr<IndexFile>>> Parse(
|
||||
if (dump_ast)
|
||||
Dump(clang_getTranslationUnitCursor(tu->cx_tu));
|
||||
|
||||
return ParseWithTu(file_consumer_shared, perf, tu.get(), index, file, args,
|
||||
unsaved_files);
|
||||
return ParseWithTu(config, file_consumer_shared, perf, tu.get(), index, file,
|
||||
args, unsaved_files);
|
||||
}
|
||||
|
||||
optional<std::vector<std::unique_ptr<IndexFile>>> ParseWithTu(
|
||||
Config* config,
|
||||
FileConsumerSharedState* file_consumer_shared,
|
||||
PerformanceImportFile* perf,
|
||||
ClangTranslationUnit* tu,
|
||||
@ -2126,7 +2128,7 @@ optional<std::vector<std::unique_ptr<IndexFile>>> ParseWithTu(
|
||||
callback.indexEntityReference = &OnIndexReference;
|
||||
|
||||
FileConsumer file_consumer(file_consumer_shared, file);
|
||||
IndexParam param(tu, &file_consumer);
|
||||
IndexParam param(config, tu, &file_consumer);
|
||||
for (const CXUnsavedFile& contents : file_contents) {
|
||||
param.file_contents[contents.Filename] = FileContents(
|
||||
contents.Filename, std::string(contents.Contents, contents.Length));
|
||||
|
@ -574,6 +574,7 @@ optional<std::vector<std::unique_ptr<IndexFile>>> Parse(
|
||||
ClangIndex* index,
|
||||
bool dump_ast = false);
|
||||
optional<std::vector<std::unique_ptr<IndexFile>>> ParseWithTu(
|
||||
Config* config,
|
||||
FileConsumerSharedState* file_consumer_shared,
|
||||
PerformanceImportFile* perf,
|
||||
ClangTranslationUnit* tu,
|
||||
|
@ -17,7 +17,6 @@
|
||||
// TODO Cleanup global variables
|
||||
extern std::string g_init_options;
|
||||
int g_index_comments;
|
||||
bool g_index_make_unique;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -504,7 +503,6 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
||||
}
|
||||
|
||||
g_index_comments = config->index.comments;
|
||||
g_index_make_unique = config->index.attributeMakeCallsToCtor;
|
||||
if (config->cacheDirectory.empty()) {
|
||||
LOG_S(ERROR) << "cacheDirectory cannot be empty.";
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user