mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-23 08:05:07 +00:00
Add index.initial{Blacklist,Whitelist}
index.{blacklist,whitelist}: disable indexes thoroughly index.initial{Blacklist,Whitelist}: disable initial loading. will still be indexed after opening
This commit is contained in:
parent
5b7758a6ca
commit
4420bcf76f
@ -192,6 +192,12 @@ struct Config {
|
||||
// If false, the indexer will be disabled.
|
||||
bool enabled = true;
|
||||
|
||||
// By default, all project entries will be indexed on initialization. Use
|
||||
// these two options to exclude some. They can still be indexed after you
|
||||
// open them.
|
||||
std::vector<std::string> initialBlacklist;
|
||||
std::vector<std::string> initialWhitelist;
|
||||
|
||||
// If not 0, a file will be indexed in each tranlation unit that includes it.
|
||||
int multiVersion = 0;
|
||||
|
||||
@ -247,7 +253,8 @@ MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
|
||||
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
||||
spellChecking, whitelist)
|
||||
MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist)
|
||||
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled, multiVersion,
|
||||
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled,
|
||||
initialBlacklist, initialWhitelist, multiVersion,
|
||||
multiVersionBlacklist, multiVersionWhitelist, onChange,
|
||||
reparseForDependency, threads, whitelist);
|
||||
MAKE_REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
||||
|
@ -421,28 +421,25 @@ Project::FindCompilationEntryForFile(const std::string &filename) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Project::ForAllFilteredFiles(
|
||||
std::function<void(int i, const Entry &entry)> action) {
|
||||
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
|
||||
void Project::Index(WorkingFiles *wfiles, lsRequestId id) {
|
||||
auto &gi = g_config->index;
|
||||
GroupMatch match(gi.whitelist, gi.blacklist),
|
||||
match_i(gi.initialWhitelist, gi.initialBlacklist);
|
||||
for (int i = 0; i < entries.size(); ++i) {
|
||||
const Project::Entry &entry = entries[i];
|
||||
std::string failure_reason;
|
||||
if (matcher.IsMatch(entry.filename, &failure_reason))
|
||||
action(i, entries[i]);
|
||||
else {
|
||||
LOG_V(1) << "[" << i + 1 << "/" << entries.size() << "]: Failed "
|
||||
<< failure_reason << "; skipping " << entry.filename;
|
||||
std::string reason;
|
||||
if (match.IsMatch(entry.filename, &reason) &&
|
||||
match_i.IsMatch(entry.filename, &reason)) {
|
||||
bool interactive = wfiles->GetFileByFilename(entry.filename) != nullptr;
|
||||
pipeline::Index(
|
||||
entry.filename, entry.args,
|
||||
interactive ? IndexMode::Normal : IndexMode::NonInteractive, id);
|
||||
} else {
|
||||
LOG_V(1) << "[" << i << "/" << entries.size() << "]: " << reason
|
||||
<< "; skip " << entry.filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Project::Index(WorkingFiles *wfiles, lsRequestId id) {
|
||||
ForAllFilteredFiles([&](int i, const Project::Entry &entry) {
|
||||
bool interactive = wfiles->GetFileByFilename(entry.filename) != nullptr;
|
||||
pipeline::Index(entry.filename, entry.args,
|
||||
interactive ? IndexMode::Normal : IndexMode::NonInteractive,
|
||||
id);
|
||||
});
|
||||
pipeline::loaded_ts = pipeline::tick;
|
||||
// Dummy request to indicate that project is loaded and
|
||||
// trigger refreshing semantic highlight for all working files.
|
||||
|
@ -55,9 +55,5 @@ struct Project {
|
||||
void SetArgsForFile(const std::vector<const char *> &args,
|
||||
const std::string &path);
|
||||
|
||||
// Run |action| on every file in the project.
|
||||
void
|
||||
ForAllFilteredFiles(std::function<void(int i, const Entry &entry)> action);
|
||||
|
||||
void Index(WorkingFiles *wfiles, lsRequestId id);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user