Skip to content

Commit fcc7e41

Browse files
committed
[SourceKit] Add a test case for fast code completion
1 parent a83c7e8 commit fcc7e41

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ ERROR(repl_must_be_initialized,none,
214214
ERROR(error_doing_code_completion,none,
215215
"compiler is in code completion mode (benign diagnostic)", ())
216216

217+
WARNING(completion_reusing_astcontext,none,
218+
"completion reusing previous ASTContext (benign diagnostic)", ())
219+
217220
ERROR(verify_encountered_fatal,none,
218221
"fatal error encountered while in -verify mode", ())
219222

lib/IDE/CompletionInstance.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "swift/AST/ASTContext.h"
1616
#include "swift/AST/DiagnosticEngine.h"
17+
#include "swift/AST/DiagnosticsFrontend.h"
1718
#include "swift/AST/Module.h"
1819
#include "swift/AST/SourceFile.h"
1920
#include "swift/Basic/LangOptions.h"
@@ -290,6 +291,11 @@ CompilerInstance *CompletionInstance::getReusingCompilerInstance(
290291
AFD->setBodyDelayed(AFD->getBodySourceRange());
291292
if (DiagC)
292293
CachedCI->addDiagnosticConsumer(DiagC);
294+
295+
CachedCI->getDiags().diagnose(
296+
SM.getLocForOffset(BufferID, newInfo.StartOffset),
297+
diag::completion_reusing_astcontext);
298+
293299
return CachedCI.get();
294300
}
295301

tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
573573
case SourceKitRequest::CodeComplete:
574574
sourcekitd_request_dictionary_set_uid(Req, KeyRequest, RequestCodeComplete);
575575
sourcekitd_request_dictionary_set_int64(Req, KeyOffset, ByteOffset);
576+
addCodeCompleteOptions(Req, Opts);
576577
break;
577578

578579
case SourceKitRequest::CodeCompleteOpen:

0 commit comments

Comments
 (0)