Skip to content

Commit b0980d9

Browse files
authored
Merge pull request #63348 from ahoppen/ahoppen/5.8-only-verify-cursor-info-if-requested
[5.8][SourceKit] Only verify the solver-based cursor info implementation if requested
2 parents d78b035 + 4b195a8 commit b0980d9

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ class LangSupport {
938938
bool SymbolGraph, bool CancelOnSubsequentRequest,
939939
ArrayRef<const char *> Args, Optional<VFSOptions> vfsOptions,
940940
SourceKitCancellationToken CancellationToken,
941+
bool VerifySolverBasedCursorInfo,
941942
std::function<void(const RequestResult<CursorInfoData> &)> Receiver) = 0;
942943

943944
virtual void

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ class SwiftLangSupport : public LangSupport {
627627
ArrayRef<const char *> Args,
628628
Optional<VFSOptions> vfsOptions,
629629
SourceKitCancellationToken CancellationToken,
630+
bool VerifySolverBasedCursorInfo,
630631
std::function<void(const RequestResult<CursorInfoData> &)>
631632
Receiver) override;
632633

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ void SwiftLangSupport::getCursorInfo(
18911891
bool SymbolGraph, bool CancelOnSubsequentRequest,
18921892
ArrayRef<const char *> Args, Optional<VFSOptions> vfsOptions,
18931893
SourceKitCancellationToken CancellationToken,
1894+
bool VerifySolverBasedCursorInfo,
18941895
std::function<void(const RequestResult<CursorInfoData> &)> Receiver) {
18951896

18961897
std::string error;
@@ -1967,19 +1968,14 @@ void SwiftLangSupport::getCursorInfo(
19671968
// Currently, we only verify that the solver-based cursor implementation
19681969
// produces the same results as the AST-based implementation. Only enable it
19691970
// in assert builds for now.
1970-
#ifndef NDEBUG
1971-
bool EnableSolverBasedCursorInfo = true;
1972-
#else
1973-
bool EnableSolverBasedCursorInfo = false;
1974-
#endif
19751971

19761972
// If solver based completion is enabled, a string description of the cursor
19771973
// info result produced by the solver-based implementation. Once the AST-based
19781974
// result is produced, we verify that the solver-based result matches the
19791975
// AST-based result.
19801976
std::string SolverBasedResultDescription;
19811977
size_t SolverBasedResultCount = 0;
1982-
if (EnableSolverBasedCursorInfo) {
1978+
if (VerifySolverBasedCursorInfo) {
19831979
std::string InputFileError;
19841980
llvm::SmallString<64> RealInputFilePath;
19851981
fileSystem->getRealPath(InputFile, RealInputFilePath);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
770770
} else {
771771
sourcekitd_request_dictionary_set_int64(Req, KeyOffset, ByteOffset);
772772
}
773+
sourcekitd_request_dictionary_set_int64(Req, KeyVerifySolverBasedCursorInfo,
774+
true);
773775
addRequestOptionsDirect(Req, Opts);
774776
break;
775777
case SourceKitRequest::RangeInfo: {

tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,10 +1128,13 @@ static void handleSemanticRequest(
11281128
Req.getInt64(KeyRetrieveRefactorActions, Actionables, /*isOptional=*/true);
11291129
int64_t SymbolGraph = false;
11301130
Req.getInt64(KeyRetrieveSymbolGraph, SymbolGraph, /*isOptional=*/true);
1131+
int64_t VerifySolverBasedCursorInfo = false;
1132+
Req.getInt64(KeyVerifySolverBasedCursorInfo, VerifySolverBasedCursorInfo,
1133+
/*isOptional=*/true);
11311134
return Lang.getCursorInfo(
11321135
*SourceFile, Offset, Length, Actionables, SymbolGraph,
11331136
CancelOnSubsequentRequest, Args, std::move(vfsOptions),
1134-
CancellationToken,
1137+
CancellationToken, VerifySolverBasedCursorInfo,
11351138
[Rec](const RequestResult<CursorInfoData> &Result) {
11361139
reportCursorInfo(Result, Rec);
11371140
});

unittests/SourceKit/SwiftLang/CursorInfoTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class CursorInfoTest : public ::testing::Test {
166166
DocName, Offset, /*Length=*/0, /*Actionables=*/false,
167167
/*SymbolGraph=*/false, CancelOnSubsequentRequest, Args,
168168
/*vfsOptions=*/None, CancellationToken,
169+
/*VerifySolverBasedCursorInfo=*/true,
169170
[&](const RequestResult<CursorInfoData> &Result) {
170171
assert(!Result.isCancelled());
171172
if (Result.isError()) {
@@ -451,6 +452,7 @@ TEST_F(CursorInfoTest, CursorInfoCancelsPreviousRequest) {
451452
SlowDocName, SlowOffset, /*Length=*/0, /*Actionables=*/false,
452453
/*SymbolGraph=*/false, /*CancelOnSubsequentRequest=*/true, ArgsForSlow,
453454
/*vfsOptions=*/None, /*CancellationToken=*/nullptr,
455+
/*VerifySolverBasedCursorInfo=*/true,
454456
[&](const RequestResult<CursorInfoData> &Result) {
455457
EXPECT_TRUE(Result.isCancelled());
456458
FirstCursorInfoSema.signal();
@@ -494,6 +496,7 @@ TEST_F(CursorInfoTest, CursorInfoCancellation) {
494496
SlowDocName, SlowOffset, /*Length=*/0, /*Actionables=*/false,
495497
/*SymbolGraph=*/false, /*CancelOnSubsequentRequest=*/false, ArgsForSlow,
496498
/*vfsOptions=*/None, /*CancellationToken=*/CancellationToken,
499+
/*VerifySolverBasedCursorInfo=*/true,
497500
[&](const RequestResult<CursorInfoData> &Result) {
498501
EXPECT_TRUE(Result.isCancelled());
499502
CursorInfoSema.signal();

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def __init__(self, internal_name, external_name):
189189
KEY('OptimizeForIDE', 'key.optimize_for_ide'),
190190
KEY('RequiredBystanders', 'key.required_bystanders'),
191191
KEY('ReusingASTContext', 'key.reusingastcontext'),
192+
KEY('VerifySolverBasedCursorInfo', 'key.verifysolverbasedcursorinfo'),
192193
KEY('CompletionMaxASTContextReuseCount',
193194
'key.completion_max_astcontext_reuse_count'),
194195
KEY('CompletionCheckDependencyInterval',

0 commit comments

Comments
 (0)