mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-27 10:02:03 +00:00
Random changes. (#6)
This commit is contained in:
parent
04a848e065
commit
b55819a8a1
@ -1841,12 +1841,15 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
if (!ns.def.spell) {
|
if (!ns.def.spell) {
|
||||||
ClangCursor sem_parent = referenced.get_semantic_parent();
|
ClangCursor sem_parent = referenced.get_semantic_parent();
|
||||||
ClangCursor lex_parent = referenced.get_lexical_parent();
|
ClangCursor lex_parent = referenced.get_lexical_parent();
|
||||||
ns.def.spell =
|
CXFile referenced_file;
|
||||||
SetUse(db, referenced.get_spell(), sem_parent, Role::Definition);
|
Range spell = referenced.get_spell(&referenced_file);
|
||||||
ns.def.extent =
|
if (file == referenced_file) {
|
||||||
SetUse(db, referenced.get_extent(), lex_parent, Role::None);
|
ns.def.spell = SetUse(db, spell, sem_parent, Role::Definition);
|
||||||
std::string name = referenced.get_spell_name();
|
ns.def.extent =
|
||||||
SetTypeName(ns, referenced, nullptr, name.c_str(), param);
|
SetUse(db, referenced.get_extent(), lex_parent, Role::None);
|
||||||
|
std::string name = referenced.get_spell_name();
|
||||||
|
SetTypeName(ns, referenced, nullptr, name.c_str(), param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,13 @@ bool Indexer_Parse(DiagnosticsEngine* diag_engine,
|
|||||||
auto& request = *opt_request;
|
auto& request = *opt_request;
|
||||||
ICacheManager cache;
|
ICacheManager cache;
|
||||||
|
|
||||||
|
// dummy one to trigger refresh semantic highlight
|
||||||
|
if (request.path.empty()) {
|
||||||
|
queue->on_indexed.PushBack(
|
||||||
|
Index_OnIndexed(IndexUpdate{}, PerformanceImportFile()), false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Project::Entry entry;
|
Project::Entry entry;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(project->mutex_);
|
std::lock_guard<std::mutex> lock(project->mutex_);
|
||||||
@ -216,6 +223,18 @@ void QueryDb_OnIndexed(QueueManager* queue,
|
|||||||
SemanticHighlightSymbolCache* semantic_cache,
|
SemanticHighlightSymbolCache* semantic_cache,
|
||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
Index_OnIndexed* response) {
|
Index_OnIndexed* response) {
|
||||||
|
|
||||||
|
if (response->update.file_id < 0) { // dummy
|
||||||
|
LOG_S(INFO) << "Loaded project. Refresh semantic highlight for all working file.";
|
||||||
|
std::lock_guard<std::mutex> lock(working_files->files_mutex);
|
||||||
|
for (auto& f : working_files->files) {
|
||||||
|
int file_id = db->name2file_id[LowerPathIfInsensitive(f->filename)];
|
||||||
|
QueryFile* file = &db->files[file_id];
|
||||||
|
EmitSemanticHighlighting(db, semantic_cache, f.get(), file);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Timer time;
|
Timer time;
|
||||||
db->ApplyIndexUpdate(&response->update);
|
db->ApplyIndexUpdate(&response->update);
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ void IncludeComplete::Rescan() {
|
|||||||
SetThreadName("scan_includes");
|
SetThreadName("scan_includes");
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
InsertIncludesFromDirectory(g_config->projectRoot,
|
// InsertIncludesFromDirectory(g_config->projectRoot,
|
||||||
false /*use_angle_brackets*/);
|
// false /*use_angle_brackets*/);
|
||||||
for (const std::string& dir : project_->quote_include_directories)
|
for (const std::string& dir : project_->quote_include_directories)
|
||||||
InsertIncludesFromDirectory(dir, false /*use_angle_brackets*/);
|
InsertIncludesFromDirectory(dir, false /*use_angle_brackets*/);
|
||||||
for (const std::string& dir : project_->angle_include_directories)
|
for (const std::string& dir : project_->angle_include_directories)
|
||||||
|
@ -510,12 +510,9 @@ struct Handler_Initialize : BaseMessageHandler<In_InitializeRequest> {
|
|||||||
// Start indexer threads. Start this after loading the project, as that
|
// Start indexer threads. Start this after loading the project, as that
|
||||||
// may take a long time. Indexer threads will emit status/progress
|
// may take a long time. Indexer threads will emit status/progress
|
||||||
// reports.
|
// reports.
|
||||||
if (g_config->index.threads == 0) {
|
if (g_config->index.threads == 0)
|
||||||
// If the user has not specified how many indexers to run, try to
|
g_config->index.threads = std::thread::hardware_concurrency();
|
||||||
// guess an appropriate value. Default to 80% utilization.
|
|
||||||
g_config->index.threads =
|
|
||||||
std::max(int(std::thread::hardware_concurrency() * 0.8), 1);
|
|
||||||
}
|
|
||||||
LOG_S(INFO) << "Starting " << g_config->index.threads << " indexers";
|
LOG_S(INFO) << "Starting " << g_config->index.threads << " indexers";
|
||||||
for (int i = 0; i < g_config->index.threads; i++) {
|
for (int i = 0; i < g_config->index.threads; i++) {
|
||||||
std::thread([=]() {
|
std::thread([=]() {
|
||||||
|
@ -563,6 +563,9 @@ void Project::Index(QueueManager* queue,
|
|||||||
queue->index_request.PushBack(Index_Request(entry.filename, entry.args,
|
queue->index_request.PushBack(Index_Request(entry.filename, entry.args,
|
||||||
is_interactive, *content, id));
|
is_interactive, *content, id));
|
||||||
});
|
});
|
||||||
|
// dummy request to indicate that project is loaded and
|
||||||
|
// trigger refreshing semantic highlight for all working files
|
||||||
|
queue->index_request.PushBack(Index_Request("", {}, false, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_SUITE("Project") {
|
TEST_SUITE("Project") {
|
||||||
|
@ -99,11 +99,7 @@ struct IndexUpdate {
|
|||||||
static IndexUpdate CreateDelta(IndexFile* previous,
|
static IndexUpdate CreateDelta(IndexFile* previous,
|
||||||
IndexFile* current);
|
IndexFile* current);
|
||||||
|
|
||||||
// Merge |update| into this update; this can reduce overhead / index update
|
int file_id = -1;
|
||||||
// work can be parallelized.
|
|
||||||
void Merge(IndexUpdate&& update);
|
|
||||||
|
|
||||||
int file_id;
|
|
||||||
|
|
||||||
// File updates.
|
// File updates.
|
||||||
std::optional<std::string> files_removed;
|
std::optional<std::string> files_removed;
|
||||||
|
Loading…
Reference in New Issue
Block a user