[CodeCompletion] Include 'annotated' to cache key

This commit is contained in:
Rintaro Ishizaki
2020-04-03 14:07:38 -07:00
parent 773a464e83
commit ad8415a5c2
3 changed files with 12 additions and 5 deletions

View File

@@ -43,6 +43,7 @@ public:
bool ForTestableLookup;
bool ForPrivateImportLookup;
bool CodeCompleteInitsInPostfixExpr;
bool Annotated;
friend bool operator==(const Key &LHS, const Key &RHS) {
return LHS.ModuleFilename == RHS.ModuleFilename &&
@@ -108,10 +109,10 @@ template<>
struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
using KeyTy = swift::ide::CodeCompletionCache::Key;
static inline KeyTy getEmptyKey() {
return KeyTy{"", "", {}, false, false, false, false};
return KeyTy{"", "", {}, false, false, false, false, false};
}
static inline KeyTy getTombstoneKey() {
return KeyTy{"", "", {}, true, false, false, false};
return KeyTy{"", "", {}, true, false, false, false, false};
}
static unsigned getHashValue(const KeyTy &Val) {
size_t H = 0;
@@ -122,6 +123,7 @@ struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
H ^= std::hash<bool>()(Val.ResultsHaveLeadingDot);
H ^= std::hash<bool>()(Val.ForTestableLookup);
H ^= std::hash<bool>()(Val.ForPrivateImportLookup);
H ^= std::hash<bool>()(Val.Annotated);
return static_cast<unsigned>(H);
}
static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {

View File

@@ -5892,7 +5892,9 @@ void CodeCompletionCallbacksImpl::doneParsing() {
SF.hasTestableOrPrivateImport(
AccessLevel::Internal, TheModule,
SourceFile::ImportQueryKind::PrivateOnly),
Ctx.LangOpts.CodeCompleteInitsInPostfixExpr};
Ctx.LangOpts.CodeCompleteInitsInPostfixExpr,
CompletionContext.getAnnnoateResult(),
};
using PairType = llvm::DenseSet<swift::ide::CodeCompletionCache::Key,
llvm::DenseMapInfo<CodeCompletionCache::Key>>::iterator;
@@ -6088,6 +6090,7 @@ void SimpleCachingCodeCompletionConsumer::handleResultsAndModules(
if (!V.hasValue()) {
// No cached results found. Fill the cache.
V = context.Cache.createValue();
(*V)->Sink.annotateResult = context.getAnnnoateResult();
lookupCodeCompletionResultsFromModule(
(*V)->Sink, R.TheModule, R.Key.AccessPath,
R.Key.ResultsHaveLeadingDot, DCForModules);

View File

@@ -314,6 +314,7 @@ static void writeCachedModule(llvm::raw_ostream &out,
OSSLE.write(K.ForTestableLookup);
OSSLE.write(K.ForPrivateImportLookup);
OSSLE.write(K.CodeCompleteInitsInPostfixExpr);
OSSLE.write(K.Annotated);
LE.write(static_cast<uint32_t>(OSS.tell())); // Size of debug info
out.write(OSS.str().data(), OSS.str().size()); // Debug info blob
}
@@ -425,7 +426,8 @@ static std::string getName(StringRef cacheDirectory,
OSS << (K.ResultsHaveLeadingDot ? "-dot" : "")
<< (K.ForTestableLookup ? "-testable" : "")
<< (K.ForPrivateImportLookup ? "-private" : "")
<< (K.CodeCompleteInitsInPostfixExpr ? "-inits" : "");
<< (K.CodeCompleteInitsInPostfixExpr ? "-inits" : "")
<< (K.Annotated ? "-annotated" : "");
// name[-access-path-components]
for (StringRef component : K.AccessPath)
@@ -491,7 +493,7 @@ OnDiskCodeCompletionCache::getFromFile(StringRef filename) {
// Make up a key for readCachedModule.
CodeCompletionCache::Key K{filename.str(), "<module-name>", {}, false,
false, false, false};
false, false, false, false};
// Read the cached results.
auto V = CodeCompletionCache::createValue();