diff --git a/src/clang_cursor.cc b/src/clang_cursor.cc index 8bde2949..0b10dbf7 100644 --- a/src/clang_cursor.cc +++ b/src/clang_cursor.cc @@ -22,7 +22,7 @@ Range ResolveCXSourceRange(const CXSourceRange& range, CXFile* cx_file) { } // TODO Place this global variable into config -int g_enable_comments; +extern int g_index_comments; ClangType::ClangType() : cx_type() {} @@ -225,7 +225,7 @@ std::string ClangCursor::get_type_description() const { } std::string ClangCursor::get_comments() const { - if (!g_enable_comments) + if (!g_index_comments) return ""; CXSourceRange range = clang_Cursor_getCommentRange(cx_cursor); if (clang_Range_isNull(range)) diff --git a/src/config.h b/src/config.h index 96ed1cd6..3e5f4ab6 100644 --- a/src/config.h +++ b/src/config.h @@ -145,6 +145,10 @@ struct Config { // - https://github.com/emacs-lsp/lsp-mode/pull/224 // - https://github.com/autozimu/LanguageClient-neovim/issues/224 int comments = 2; + + // A hack to convert calls of make_shared/make_unique and other |Make| + // variants to constructor calls. + bool make_unique = false; }; Index index; @@ -155,7 +159,7 @@ struct Config { }; MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport); MAKE_REFLECT_STRUCT(Config::Completion, filterAndSort); -MAKE_REFLECT_STRUCT(Config::Index, comments); +MAKE_REFLECT_STRUCT(Config::Index, comments, make_unique); MAKE_REFLECT_STRUCT(Config, compilationDatabaseDirectory, cacheDirectory, diff --git a/src/indexer.cc b/src/indexer.cc index 8edb14ba..1bbdda82 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -20,6 +20,7 @@ // Defined in command_line.cc extern bool g_debug; +extern bool g_index_make_unique; namespace { @@ -1951,7 +1952,8 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { bool is_template = ref->referencedEntity->templateKind != CXIdxEntityCXXTemplateKind::CXIdxEntity_NonTemplate; - if (is_template && str_begin("make", ref->referencedEntity->name)) { + if (g_index_make_unique && 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. optional opt_found_type = FindType(ref->cursor); diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index 636c35cb..e7e186d9 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -16,7 +16,8 @@ // TODO Cleanup global variables extern std::string g_init_options; -extern int g_enable_comments; +int g_index_comments; +bool g_index_make_unique; namespace { @@ -502,7 +503,8 @@ struct InitializeHandler : BaseMessageHandler { } } - g_enable_comments = config->index.comments; + g_index_comments = config->index.comments; + g_index_make_unique = config->index.make_unique; if (config->cacheDirectory.empty()) { LOG_S(ERROR) << "cacheDirectory cannot be empty."; exit(1);