Skip to content

Commit ad8415a

Browse files
committed
[CodeCompletion] Include 'annotated' to cache key
1 parent 773a464 commit ad8415a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

include/swift/IDE/CodeCompletionCache.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class CodeCompletionCache {
4343
bool ForTestableLookup;
4444
bool ForPrivateImportLookup;
4545
bool CodeCompleteInitsInPostfixExpr;
46+
bool Annotated;
4647

4748
friend bool operator==(const Key &LHS, const Key &RHS) {
4849
return LHS.ModuleFilename == RHS.ModuleFilename &&
@@ -108,10 +109,10 @@ template<>
108109
struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
109110
using KeyTy = swift::ide::CodeCompletionCache::Key;
110111
static inline KeyTy getEmptyKey() {
111-
return KeyTy{"", "", {}, false, false, false, false};
112+
return KeyTy{"", "", {}, false, false, false, false, false};
112113
}
113114
static inline KeyTy getTombstoneKey() {
114-
return KeyTy{"", "", {}, true, false, false, false};
115+
return KeyTy{"", "", {}, true, false, false, false, false};
115116
}
116117
static unsigned getHashValue(const KeyTy &Val) {
117118
size_t H = 0;
@@ -122,6 +123,7 @@ struct DenseMapInfo<swift::ide::CodeCompletionCache::Key> {
122123
H ^= std::hash<bool>()(Val.ResultsHaveLeadingDot);
123124
H ^= std::hash<bool>()(Val.ForTestableLookup);
124125
H ^= std::hash<bool>()(Val.ForPrivateImportLookup);
126+
H ^= std::hash<bool>()(Val.Annotated);
125127
return static_cast<unsigned>(H);
126128
}
127129
static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {

lib/IDE/CodeCompletion.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5892,7 +5892,9 @@ void CodeCompletionCallbacksImpl::doneParsing() {
58925892
SF.hasTestableOrPrivateImport(
58935893
AccessLevel::Internal, TheModule,
58945894
SourceFile::ImportQueryKind::PrivateOnly),
5895-
Ctx.LangOpts.CodeCompleteInitsInPostfixExpr};
5895+
Ctx.LangOpts.CodeCompleteInitsInPostfixExpr,
5896+
CompletionContext.getAnnnoateResult(),
5897+
};
58965898

58975899
using PairType = llvm::DenseSet<swift::ide::CodeCompletionCache::Key,
58985900
llvm::DenseMapInfo<CodeCompletionCache::Key>>::iterator;
@@ -6088,6 +6090,7 @@ void SimpleCachingCodeCompletionConsumer::handleResultsAndModules(
60886090
if (!V.hasValue()) {
60896091
// No cached results found. Fill the cache.
60906092
V = context.Cache.createValue();
6093+
(*V)->Sink.annotateResult = context.getAnnnoateResult();
60916094
lookupCodeCompletionResultsFromModule(
60926095
(*V)->Sink, R.TheModule, R.Key.AccessPath,
60936096
R.Key.ResultsHaveLeadingDot, DCForModules);

lib/IDE/CodeCompletionCache.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static void writeCachedModule(llvm::raw_ostream &out,
314314
OSSLE.write(K.ForTestableLookup);
315315
OSSLE.write(K.ForPrivateImportLookup);
316316
OSSLE.write(K.CodeCompleteInitsInPostfixExpr);
317+
OSSLE.write(K.Annotated);
317318
LE.write(static_cast<uint32_t>(OSS.tell())); // Size of debug info
318319
out.write(OSS.str().data(), OSS.str().size()); // Debug info blob
319320
}
@@ -425,7 +426,8 @@ static std::string getName(StringRef cacheDirectory,
425426
OSS << (K.ResultsHaveLeadingDot ? "-dot" : "")
426427
<< (K.ForTestableLookup ? "-testable" : "")
427428
<< (K.ForPrivateImportLookup ? "-private" : "")
428-
<< (K.CodeCompleteInitsInPostfixExpr ? "-inits" : "");
429+
<< (K.CodeCompleteInitsInPostfixExpr ? "-inits" : "")
430+
<< (K.Annotated ? "-annotated" : "");
429431

430432
// name[-access-path-components]
431433
for (StringRef component : K.AccessPath)
@@ -491,7 +493,7 @@ OnDiskCodeCompletionCache::getFromFile(StringRef filename) {
491493

492494
// Make up a key for readCachedModule.
493495
CodeCompletionCache::Key K{filename.str(), "<module-name>", {}, false,
494-
false, false, false};
496+
false, false, false, false};
495497

496498
// Read the cached results.
497499
auto V = CodeCompletionCache::createValue();

0 commit comments

Comments
 (0)