Skip to content

Commit 09803ed

Browse files
committed
[SourceKit] Only verify the solver-based cursor info implementation if requested
This allows us to mark expected deviations between the AST-based and the solver-based implementation in the stress tester as XFails without breaking actual clients We always verify if a cursor info request is issued through `sourcekitd-test`.
1 parent 3fd895a commit 09803ed

File tree

7 files changed

+13
-1
lines changed

7 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ class LangSupport {
948948
bool SymbolGraph, bool CancelOnSubsequentRequest,
949949
ArrayRef<const char *> Args, Optional<VFSOptions> vfsOptions,
950950
SourceKitCancellationToken CancellationToken,
951+
bool VerifySolverBasedCursorInfo,
951952
std::function<void(const RequestResult<CursorInfoData> &)> Receiver) = 0;
952953

953954
virtual void

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ class SwiftLangSupport : public LangSupport {
637637
ArrayRef<const char *> Args,
638638
Optional<VFSOptions> vfsOptions,
639639
SourceKitCancellationToken CancellationToken,
640+
bool VerifySolverBasedCursorInfo,
640641
std::function<void(const RequestResult<CursorInfoData> &)>
641642
Receiver) override;
642643

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 1 addition & 0 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;

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
@@ -1393,10 +1393,13 @@ handleRequestCursorInfo(const RequestDict &Req,
13931393
Req.getInt64(KeyRetrieveRefactorActions, Actionables, /*isOptional=*/true);
13941394
int64_t SymbolGraph = false;
13951395
Req.getInt64(KeyRetrieveSymbolGraph, SymbolGraph, /*isOptional=*/true);
1396+
int64_t VerifySolverBasedCursorInfo = false;
1397+
Req.getInt64(KeyVerifySolverBasedCursorInfo, VerifySolverBasedCursorInfo,
1398+
/*isOptional=*/true);
13961399
return Lang.getCursorInfo(
13971400
*SourceFile, Offset, Length, Actionables, SymbolGraph,
13981401
CancelOnSubsequentRequest, Args, std::move(vfsOptions),
1399-
CancellationToken,
1402+
CancellationToken, VerifySolverBasedCursorInfo,
14001403
[Rec](const RequestResult<CursorInfoData> &Result) {
14011404
reportCursorInfo(Result, Rec);
14021405
});

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)