Skip to content

Commit 500333c

Browse files
authored
Merge pull request #25590 from rintaro/5.1-ide-completion-customattr-func-rdar50352482
[5.1][CodeCompletion] Enable custom attribute completion for func decl
2 parents c375167 + 805c8d6 commit 500333c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,9 +5381,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53815381
case CompletionKind::AttributeBegin: {
53825382
Lookup.getAttributeDeclCompletions(IsInSil, AttTargetDK);
53835383

5384-
// Provide any type name for property delegate.
5384+
// TypeName at attribute position after '@'.
5385+
// - VarDecl: Property Wrappers.
5386+
// - ParamDecl/VarDecl/FuncDecl: Function Buildres.
53855387
if (!AttTargetDK || *AttTargetDK == DeclKind::Var ||
5386-
*AttTargetDK == DeclKind::Param)
5388+
*AttTargetDK == DeclKind::Param || *AttTargetDK == DeclKind::Func)
53875389
Lookup.getTypeCompletionsInDeclContext(
53885390
P.Context.SourceMgr.getCodeCompletionLoc());
53895391
break;

test/IDE/complete_attributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=MEMBER_DECL_ATTR_1 -code-completion-keywords=false | %FileCheck %s -check-prefix=ERROR_COMMON
33

44
// ERROR_COMMON: found code completion token
5-
// ERROR_COMMON-NOT: Begin completions
5+
// ERROR_COMMON-NOT: Keyword/
66

77
@#^TOP_LEVEL_ATTR_1^# class TopLevelDeclAttr1 {}
88

test/IDE/complete_decl_attribute.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ func method(){}
5959
// KEYWORD2-NEXT: Keyword/None: usableFromInline[#Func Attribute#]; name=usableFromInline
6060
// KEYWORD2-NEXT: Keyword/None: discardableResult[#Func Attribute#]; name=discardableResult
6161
// KEYWORD2-NEXT: Keyword/None: IBSegueAction[#Func Attribute#]; name=IBSegueAction{{$}}
62-
// KEYWORD2-NEXT: End completions
62+
// KEYWORD2-NOT: Keyword
63+
// KEYWORD2: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
64+
// KEYWORD2: End completions
6365

6466
@#^KEYWORD3^#
6567
class C {}
@@ -171,6 +173,8 @@ struct _S {
171173
// ON_METHOD-DAG: Keyword/None: usableFromInline[#Func Attribute#]; name=usableFromInline
172174
// ON_METHOD-DAG: Keyword/None: discardableResult[#Func Attribute#]; name=discardableResult
173175
// ON_METHOD-DAG: Keyword/None: IBSegueAction[#Func Attribute#]; name=IBSegueAction
176+
// ON_METHOD-NOT: Keyword
177+
// ON_METHOD: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
174178
// ON_METHOD: End completions
175179

176180
func bar(@#^ON_PARAM^#)

0 commit comments

Comments
 (0)