mirror of
https://github.com/MaskRay/ccls.git
synced 2024-12-12 09:27:08 +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
ce68028caf
commit
eb644bb78e
@ -204,6 +204,12 @@ struct Config {
|
|||||||
// If false, the indexer will be disabled.
|
// If false, the indexer will be disabled.
|
||||||
bool enabled = true;
|
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.
|
// If not 0, a file will be indexed in each tranlation unit that includes it.
|
||||||
int multiVersion = 0;
|
int multiVersion = 0;
|
||||||
|
|
||||||
@ -259,7 +265,8 @@ MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
|
|||||||
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
||||||
spellChecking, whitelist)
|
spellChecking, whitelist)
|
||||||
MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, 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,
|
multiVersionBlacklist, multiVersionWhitelist, onChange,
|
||||||
reparseForDependency, threads, whitelist);
|
reparseForDependency, threads, whitelist);
|
||||||
MAKE_REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
MAKE_REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
||||||
|
@ -433,28 +433,25 @@ Project::FindCompilationEntryForFile(const std::string &filename) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::ForAllFilteredFiles(
|
void Project::Index(WorkingFiles *wfiles, lsRequestId id) {
|
||||||
std::function<void(int i, const Entry &entry)> action) {
|
auto &gi = g_config->index;
|
||||||
GroupMatch matcher(g_config->index.whitelist, g_config->index.blacklist);
|
GroupMatch match(gi.whitelist, gi.blacklist),
|
||||||
|
match_i(gi.initialWhitelist, gi.initialBlacklist);
|
||||||
for (int i = 0; i < entries.size(); ++i) {
|
for (int i = 0; i < entries.size(); ++i) {
|
||||||
const Project::Entry &entry = entries[i];
|
const Project::Entry &entry = entries[i];
|
||||||
std::string failure_reason;
|
std::string reason;
|
||||||
if (matcher.IsMatch(entry.filename, &failure_reason))
|
if (match.IsMatch(entry.filename, &reason) &&
|
||||||
action(i, entries[i]);
|
match_i.IsMatch(entry.filename, &reason)) {
|
||||||
else {
|
bool interactive = wfiles->GetFileByFilename(entry.filename) != nullptr;
|
||||||
LOG_V(1) << "[" << i + 1 << "/" << entries.size() << "]: Failed "
|
pipeline::Index(
|
||||||
<< failure_reason << "; skipping " << entry.filename;
|
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;
|
pipeline::loaded_ts = pipeline::tick;
|
||||||
// Dummy request to indicate that project is loaded and
|
// Dummy request to indicate that project is loaded and
|
||||||
// trigger refreshing semantic highlight for all working files.
|
// trigger refreshing semantic highlight for all working files.
|
||||||
|
@ -67,9 +67,5 @@ struct Project {
|
|||||||
void SetArgsForFile(const std::vector<const char *> &args,
|
void SetArgsForFile(const std::vector<const char *> &args,
|
||||||
const std::string &path);
|
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);
|
void Index(WorkingFiles *wfiles, lsRequestId id);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user