mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 17:41:58 +00:00
Enable "Make" hack only if config->index.make_unique is true.
This commit is contained in:
parent
871ae34a1b
commit
768f4ecb6e
@ -22,7 +22,7 @@ Range ResolveCXSourceRange(const CXSourceRange& range, CXFile* cx_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Place this global variable into config
|
// TODO Place this global variable into config
|
||||||
int g_enable_comments;
|
extern int g_index_comments;
|
||||||
|
|
||||||
ClangType::ClangType() : cx_type() {}
|
ClangType::ClangType() : cx_type() {}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ std::string ClangCursor::get_type_description() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ClangCursor::get_comments() const {
|
std::string ClangCursor::get_comments() const {
|
||||||
if (!g_enable_comments)
|
if (!g_index_comments)
|
||||||
return "";
|
return "";
|
||||||
CXSourceRange range = clang_Cursor_getCommentRange(cx_cursor);
|
CXSourceRange range = clang_Cursor_getCommentRange(cx_cursor);
|
||||||
if (clang_Range_isNull(range))
|
if (clang_Range_isNull(range))
|
||||||
|
@ -145,6 +145,10 @@ struct Config {
|
|||||||
// - https://github.com/emacs-lsp/lsp-mode/pull/224
|
// - https://github.com/emacs-lsp/lsp-mode/pull/224
|
||||||
// - https://github.com/autozimu/LanguageClient-neovim/issues/224
|
// - https://github.com/autozimu/LanguageClient-neovim/issues/224
|
||||||
int comments = 2;
|
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;
|
Index index;
|
||||||
|
|
||||||
@ -155,7 +159,7 @@ struct Config {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport);
|
MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport);
|
||||||
MAKE_REFLECT_STRUCT(Config::Completion, filterAndSort);
|
MAKE_REFLECT_STRUCT(Config::Completion, filterAndSort);
|
||||||
MAKE_REFLECT_STRUCT(Config::Index, comments);
|
MAKE_REFLECT_STRUCT(Config::Index, comments, make_unique);
|
||||||
MAKE_REFLECT_STRUCT(Config,
|
MAKE_REFLECT_STRUCT(Config,
|
||||||
compilationDatabaseDirectory,
|
compilationDatabaseDirectory,
|
||||||
cacheDirectory,
|
cacheDirectory,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// 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 {
|
||||||
|
|
||||||
@ -1951,7 +1952,8 @@ 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 (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
|
// 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.
|
||||||
optional<ClangCursor> opt_found_type = FindType(ref->cursor);
|
optional<ClangCursor> opt_found_type = FindType(ref->cursor);
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
// TODO Cleanup global variables
|
// TODO Cleanup global variables
|
||||||
extern std::string g_init_options;
|
extern std::string g_init_options;
|
||||||
extern int g_enable_comments;
|
int g_index_comments;
|
||||||
|
bool g_index_make_unique;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -502,7 +503,8 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_enable_comments = config->index.comments;
|
g_index_comments = config->index.comments;
|
||||||
|
g_index_make_unique = config->index.make_unique;
|
||||||
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