Skip to content

Commit

Permalink
Slightly better --dump-completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Nov 3, 2015
1 parent b9051cc commit 8a5e15a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/CompletionThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,16 @@ void CompletionThread::run()
Log out(&dump->string);
for (SourceFile *cache = mCacheList.first(); cache; cache = cache->next) {
out << cache->source << "\nhash:" << cache->unsavedHash
<< "lastModified:" << cache->lastModified
<< "translationUnit:" << cache->translationUnit << "\n";
<< "\nlastModified:" << cache->lastModified
<< "\nparseTime:" << cache->parseTime
<< "\nreparseTime:" << cache->reparseTime
<< "\ncompletions:" << cache->completions
<< "\ncompletionTime:" << cache->codeCompleteTime
<< (cache->completions
? String::format<32>("(avg: %.2f)",
(static_cast<double>(cache->codeCompleteTime) / cache->completions))
: String())
<< "\ntranslationUnit:" << cache->translationUnit << "\n";
for (Completions *completion = cache->completionsList.first(); completion; completion = completion->next) {
out << " " << completion->location.toString() << "\n";
for (const auto &c : completion->candidates) {
Expand Down Expand Up @@ -272,11 +280,11 @@ void CompletionThread::process(Request *request)
cache->translationUnit, mIndex,
&unsaved, request->unsaved.size() ? 1 : 0, flags, &clangLine);
// error() << "PARSING" << clangLine;
parseTime = sw.restart();
parseTime = cache->parseTime = sw.restart();
if (cache->translationUnit) {
RTags::reparseTranslationUnit(cache->translationUnit, &unsaved, request->unsaved.size() ? 1 : 0);
}
reparseTime = sw.elapsed();
reparseTime = cache->reparseTime = sw.elapsed();
if (!cache->translationUnit)
return;
cache->unsavedHash = hash;
Expand Down Expand Up @@ -304,7 +312,8 @@ void CompletionThread::process(Request *request)
CXCodeCompleteResults *results = clang_codeCompleteAt(cache->translationUnit, sourceFile.constData(),
request->location.line(), request->location.column(),
&unsaved, unsaved.Length ? 1 : 0, completionFlags);
completeTime = sw.restart();
completeTime = cache->codeCompleteTime = sw.restart();
++cache->completions;
if (results) {
std::vector<Completions::Candidate> nodes;
nodes.reserve(results->NumResults);
Expand Down
6 changes: 4 additions & 2 deletions src/CompletionThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ class CompletionThread : public Thread

struct SourceFile {
SourceFile()
: translationUnit(0), unsavedHash(0), lastModified(0), next(0), prev(0)
: translationUnit(0), unsavedHash(0), lastModified(0),
parseTime(0), reparseTime(0), codeCompleteTime(0), completions(0), next(0), prev(0)
{}
CXTranslationUnit translationUnit;
size_t unsavedHash;
uint64_t lastModified; // ms
uint64_t lastModified, parseTime, reparseTime, codeCompleteTime; // ms
size_t completions;
Source source;
Map<Location, Completions*> completionsMap;
EmbeddedLinkedList<Completions*> completionsList;
Expand Down

0 comments on commit 8a5e15a

Please sign in to comment.