Don't rename '.' to '_' in cache files.

This makes it easier to browse cached cc/etc files.

Also clean up logging a bit.
This commit is contained in:
Jacob Dufault 2017-04-23 18:24:09 -07:00
parent 91b5614c7e
commit 526fefaf09
4 changed files with 17 additions and 20 deletions

View File

@ -14,7 +14,7 @@ std::string GetCachedBaseFileName(const std::string& cache_directory,
std::replace(source_file.begin(), source_file.end(), '\\', '_');
std::replace(source_file.begin(), source_file.end(), '/', '_');
std::replace(source_file.begin(), source_file.end(), ':', '_');
std::replace(source_file.begin(), source_file.end(), '.', '_');
return cache_directory + source_file;
}
@ -42,8 +42,7 @@ optional<std::string> LoadCachedFileContents(IndexerConfig* config,
if (!config->enableCacheRead)
return nullopt;
return ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename) +
".txt");
return ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename));
}
void WriteToCache(IndexerConfig* config,
@ -55,7 +54,7 @@ void WriteToCache(IndexerConfig* config,
std::string cache_basename =
GetCachedBaseFileName(config->cacheDirectory, filename);
CopyFileTo(cache_basename + ".txt", filename);
CopyFileTo(cache_basename, filename);
std::string indexed_content = Serialize(file);
std::ofstream cache;

View File

@ -1242,7 +1242,7 @@ bool QueryDbMainLoop(
auto request = static_cast<Ipc_InitializeRequest*>(message.get());
if (request->params.rootUri) {
std::string project_path = request->params.rootUri->GetPath();
std::cerr << "[stdin] Initialize in directory " << project_path
std::cerr << "[querydb] Initialize in directory " << project_path
<< " with uri " << request->params.rootUri->raw_uri
<< std::endl;
@ -1607,7 +1607,7 @@ bool QueryDbMainLoop(
break;
}
std::cerr << "File outline size is " << file->def.outline.size() << std::endl;
std::cerr << "[querydb] File outline size is " << file->def.outline.size() << std::endl;
for (SymbolRef ref : file->def.outline) {
optional<lsSymbolInformation> info = GetSymbolInfo(db, working_files, ref.idx);
if (!info)
@ -1739,7 +1739,7 @@ bool QueryDbMainLoop(
std::string query = msg->params.query;
for (int i = 0; i < db->detailed_names.size(); ++i) {
if (response.result.size() >= config->maxWorkspaceSearchResults) {
std::cerr << "[querydb] - Query exceeded maximum number of responses (" << config->maxWorkspaceSearchResults << "), output may not contain all results" << std::endl;
std::cerr << "[querydb] Query exceeded maximum number of responses (" << config->maxWorkspaceSearchResults << "), output may not contain all results" << std::endl;
break;
}
@ -1764,7 +1764,7 @@ bool QueryDbMainLoop(
}
}
std::cerr << "[querydb] - Found " << response.result.size() << " results for query " << query << std::endl;
std::cerr << "[querydb] Found " << response.result.size() << " results for query " << query << std::endl;
ipc->SendOutMessageToClient(IpcId::WorkspaceSymbol, response);
break;
}
@ -1952,7 +1952,7 @@ void LanguageServerStdinLoop(IndexerConfig* config, std::unordered_map<IpcId, Ti
(*request_times)[message->method_id] = Timer();
std::cerr << "[stdin] Got message \"" << IpcIdToString(message->method_id) << '"' << std::endl;
//std::cerr << "[stdin] Got message " << IpcIdToString(message->method_id) << std::endl;
switch (message->method_id) {
case IpcId::Initialized: {
// TODO: don't send output until we get this notification
@ -2049,7 +2049,7 @@ void StdoutMain(std::unordered_map<IpcId, Timer>* request_times, MultiQueueWaite
}
for (auto& message : messages) {
std::cerr << "[stdout] Processing message " << IpcIdToString(message->method_id) << std::endl;
//std::cerr << "[stdout] Processing message " << IpcIdToString(message->method_id) << std::endl;
switch (message->method_id) {
case IpcId::Cout: {

View File

@ -11,11 +11,12 @@ void Timer::Reset() {
}
void Timer::ResetAndPrint(const std::string& message) {
std::cerr << message << " took " << ElapsedMilliseconds() << "ms" << std::endl;
std::chrono::time_point<Clock> end = Clock::now();
long long elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
long long milliseconds = elapsed / 1000;
long long remaining = elapsed - milliseconds;
std::cerr << message << " took " << milliseconds << "." << remaining << "ms" << std::endl;
Reset();
}
long long Timer::ElapsedMilliseconds() {
std::chrono::time_point<Clock> end = Clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
}

View File

@ -14,9 +14,6 @@ struct Timer {
// Resets timer and prints a message like "<foo> took 5ms"
void ResetAndPrint(const std::string& message);
// Return the number of milliseconds since the timer was last reset.
long long ElapsedMilliseconds();
// Raw start time.
std::chrono::time_point<Clock> start;
};