mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Don't mark #keyPath as "expression specific" without #
We suggest #keyPath in every String context, so having it be expression-specific is artificially increasing its priority. rdar://problem/26544672
This commit is contained in:
@@ -2196,11 +2196,15 @@ public:
|
|||||||
// #keyPath is only available when the Objective-C runtime is.
|
// #keyPath is only available when the Objective-C runtime is.
|
||||||
if (!Ctx.LangOpts.EnableObjCInterop) return;
|
if (!Ctx.LangOpts.EnableObjCInterop) return;
|
||||||
|
|
||||||
|
// After #, this is a very likely result. When just in a String context,
|
||||||
|
// it's not.
|
||||||
|
auto semanticContext = needPound ? SemanticContextKind::None
|
||||||
|
: SemanticContextKind::ExpressionSpecific;
|
||||||
|
|
||||||
CodeCompletionResultBuilder Builder(
|
CodeCompletionResultBuilder Builder(
|
||||||
Sink,
|
Sink,
|
||||||
CodeCompletionResult::ResultKind::Keyword,
|
CodeCompletionResult::ResultKind::Keyword,
|
||||||
SemanticContextKind::ExpressionSpecific,
|
semanticContext, ExpectedTypes);
|
||||||
ExpectedTypes);
|
|
||||||
if (needPound)
|
if (needPound)
|
||||||
Builder.addTextChunk("#keyPath");
|
Builder.addTextChunk("#keyPath");
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func completeInKeyPath2() {
|
|||||||
|
|
||||||
// CHECK-AFTER_POUND: Keyword/ExprSpecific: keyPath({#@objc property sequence#}); name=keyPath(@objc property sequence)
|
// CHECK-AFTER_POUND: Keyword/ExprSpecific: keyPath({#@objc property sequence#}); name=keyPath(@objc property sequence)
|
||||||
|
|
||||||
// CHECK-KEYPATH_ARG: Keyword/ExprSpecific: #keyPath({#@objc property sequence#}); name=#keyPath(@objc property sequence)
|
// CHECK-KEYPATH_ARG: Keyword/None: #keyPath({#@objc property sequence#}); name=#keyPath(@objc property sequence)
|
||||||
|
|
||||||
// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop1[#String#]; name=prop1
|
// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop1[#String#]; name=prop1
|
||||||
// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop2[#ObjCClass?#]; name=prop2
|
// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop2[#ObjCClass?#]; name=prop2
|
||||||
|
|||||||
Reference in New Issue
Block a user