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