mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 18:00:26 +00:00
Reindex a file when command line arguments have changed
This commit is contained in:
parent
bc2521382d
commit
a3774a371f
@ -91,7 +91,9 @@ FileParseQuery FileNeedsParse(bool is_interactive,
|
|||||||
ImportManager* import_manager,
|
ImportManager* import_manager,
|
||||||
ICacheManager* cache_manager,
|
ICacheManager* cache_manager,
|
||||||
FileConsumerSharedState* file_consumer_shared,
|
FileConsumerSharedState* file_consumer_shared,
|
||||||
|
IndexFile* opt_previous_index,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
|
const std::vector<std::string>& args,
|
||||||
bool is_dependency) {
|
bool is_dependency) {
|
||||||
// If the file is a dependency but another file as already imported it,
|
// If the file is a dependency but another file as already imported it,
|
||||||
// don't bother.
|
// don't bother.
|
||||||
@ -100,6 +102,7 @@ FileParseQuery FileNeedsParse(bool is_interactive,
|
|||||||
return FileParseQuery::DoesNotNeedParse;
|
return FileParseQuery::DoesNotNeedParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: allow test to fake GetLastModificationTime
|
||||||
optional<int64_t> modification_timestamp = GetLastModificationTime(path);
|
optional<int64_t> modification_timestamp = GetLastModificationTime(path);
|
||||||
|
|
||||||
// Cannot find file.
|
// Cannot find file.
|
||||||
@ -116,6 +119,10 @@ FileParseQuery FileNeedsParse(bool is_interactive,
|
|||||||
return FileParseQuery::NeedsParse;
|
return FileParseQuery::NeedsParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Command-line arguments changed.
|
||||||
|
if (opt_previous_index && opt_previous_index->args != args)
|
||||||
|
return FileParseQuery::NeedsParse;
|
||||||
|
|
||||||
// File has not changed, do not parse it.
|
// File has not changed, do not parse it.
|
||||||
return FileParseQuery::DoesNotNeedParse;
|
return FileParseQuery::DoesNotNeedParse;
|
||||||
};
|
};
|
||||||
@ -154,9 +161,10 @@ std::vector<Index_DoIdMap> ParseFile(
|
|||||||
// from cache.
|
// from cache.
|
||||||
|
|
||||||
// Check timestamps and update |file_consumer_shared|.
|
// Check timestamps and update |file_consumer_shared|.
|
||||||
FileParseQuery path_state = FileNeedsParse(
|
FileParseQuery path_state =
|
||||||
is_interactive, timestamp_manager, import_manager, cache_manager,
|
FileNeedsParse(is_interactive, timestamp_manager, import_manager,
|
||||||
file_consumer_shared, path, false /*is_dependency*/);
|
cache_manager, file_consumer_shared, previous_index,
|
||||||
|
path, entry.args, false /*is_dependency*/);
|
||||||
|
|
||||||
// Target file does not exist on disk, do not emit any indexes.
|
// Target file does not exist on disk, do not emit any indexes.
|
||||||
// TODO: Dependencies should be reassigned to other files. We can do this by
|
// TODO: Dependencies should be reassigned to other files. We can do this by
|
||||||
@ -173,8 +181,8 @@ std::vector<Index_DoIdMap> ParseFile(
|
|||||||
|
|
||||||
// note: Use != as there are multiple failure results for FileParseQuery.
|
// note: Use != as there are multiple failure results for FileParseQuery.
|
||||||
if (FileNeedsParse(is_interactive, timestamp_manager, import_manager,
|
if (FileNeedsParse(is_interactive, timestamp_manager, import_manager,
|
||||||
cache_manager, file_consumer_shared, dependency,
|
cache_manager, file_consumer_shared, previous_index,
|
||||||
true /*is_dependency*/) !=
|
dependency, entry.args, true /*is_dependency*/) !=
|
||||||
FileParseQuery::DoesNotNeedParse) {
|
FileParseQuery::DoesNotNeedParse) {
|
||||||
LOG_S(INFO) << "Timestamp has changed for " << dependency << " (via "
|
LOG_S(INFO) << "Timestamp has changed for " << dependency << " (via "
|
||||||
<< previous_index->path << ")";
|
<< previous_index->path << ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user