mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-23 16:15:07 +00:00
Random changes. (#6)
This commit is contained in:
parent
04a848e065
commit
b55819a8a1
@ -1841,13 +1841,16 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
if (!ns.def.spell) {
|
||||
ClangCursor sem_parent = referenced.get_semantic_parent();
|
||||
ClangCursor lex_parent = referenced.get_lexical_parent();
|
||||
ns.def.spell =
|
||||
SetUse(db, referenced.get_spell(), sem_parent, Role::Definition);
|
||||
CXFile referenced_file;
|
||||
Range spell = referenced.get_spell(&referenced_file);
|
||||
if (file == referenced_file) {
|
||||
ns.def.spell = SetUse(db, spell, sem_parent, Role::Definition);
|
||||
ns.def.extent =
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,13 @@ bool Indexer_Parse(DiagnosticsEngine* diag_engine,
|
||||
auto& request = *opt_request;
|
||||
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;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(project->mutex_);
|
||||
@ -216,6 +223,18 @@ void QueryDb_OnIndexed(QueueManager* queue,
|
||||
SemanticHighlightSymbolCache* semantic_cache,
|
||||
WorkingFiles* working_files,
|
||||
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;
|
||||
db->ApplyIndexUpdate(&response->update);
|
||||
|
||||
|
@ -106,8 +106,8 @@ void IncludeComplete::Rescan() {
|
||||
SetThreadName("scan_includes");
|
||||
Timer timer;
|
||||
|
||||
InsertIncludesFromDirectory(g_config->projectRoot,
|
||||
false /*use_angle_brackets*/);
|
||||
// InsertIncludesFromDirectory(g_config->projectRoot,
|
||||
// false /*use_angle_brackets*/);
|
||||
for (const std::string& dir : project_->quote_include_directories)
|
||||
InsertIncludesFromDirectory(dir, false /*use_angle_brackets*/);
|
||||
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
|
||||
// may take a long time. Indexer threads will emit status/progress
|
||||
// reports.
|
||||
if (g_config->index.threads == 0) {
|
||||
// If the user has not specified how many indexers to run, try to
|
||||
// guess an appropriate value. Default to 80% utilization.
|
||||
g_config->index.threads =
|
||||
std::max(int(std::thread::hardware_concurrency() * 0.8), 1);
|
||||
}
|
||||
if (g_config->index.threads == 0)
|
||||
g_config->index.threads = std::thread::hardware_concurrency();
|
||||
|
||||
LOG_S(INFO) << "Starting " << g_config->index.threads << " indexers";
|
||||
for (int i = 0; i < g_config->index.threads; i++) {
|
||||
std::thread([=]() {
|
||||
|
@ -563,6 +563,9 @@ void Project::Index(QueueManager* queue,
|
||||
queue->index_request.PushBack(Index_Request(entry.filename, entry.args,
|
||||
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") {
|
||||
|
@ -99,11 +99,7 @@ struct IndexUpdate {
|
||||
static IndexUpdate CreateDelta(IndexFile* previous,
|
||||
IndexFile* current);
|
||||
|
||||
// Merge |update| into this update; this can reduce overhead / index update
|
||||
// work can be parallelized.
|
||||
void Merge(IndexUpdate&& update);
|
||||
|
||||
int file_id;
|
||||
int file_id = -1;
|
||||
|
||||
// File updates.
|
||||
std::optional<std::string> files_removed;
|
||||
|
Loading…
Reference in New Issue
Block a user