@@ -49,43 +49,55 @@ static StringRef copyAndClearString(llvm::BumpPtrAllocator &Allocator,
4949 return Ref;
5050}
5151
52- CodeCompletionString *SignatureHelpFormatter::createSignatureString (
53- ValueDecl *FD, AnyFunctionType *AFT, const DeclContext *DC,
54- GenericSignature GenericSig, bool IsSubscript, bool IsMember,
55- bool IsImplicitlyCurried, bool IsSecondApply) {
52+ CodeCompletionString *
53+ SignatureHelpFormatter::createSignatureString (const ide::Signature &Signature,
54+ const DeclContext *DC) {
55+ ValueDecl *FD = Signature.FuncD ;
56+ AnyFunctionType *AFT = Signature.FuncTy ;
57+
58+ GenericSignature GenericSig;
59+ if (FD) {
60+ if (auto *GC = FD->getAsGenericContext ())
61+ GenericSig = GC->getGenericSignature ();
62+ }
63+
5664 CodeCompletionStringBuilder StringBuilder (
5765 Allocator, /* AnnotateResults=*/ false ,
58- /* UnderscoreEmptyArgumentLabel=*/ !IsSubscript,
66+ /* UnderscoreEmptyArgumentLabel=*/ !Signature. IsSubscript ,
5967 /* FullParameterFlags=*/ true );
6068
6169 DeclBaseName BaseName;
6270
63- if (!IsSecondApply && FD) {
71+ if (!Signature. IsSecondApply && FD) {
6472 BaseName = FD->getBaseName ();
65- } else if (IsSubscript) {
73+ } else if (Signature. IsSubscript ) {
6674 BaseName = DeclBaseName::createSubscript ();
6775 }
6876
6977 if (!BaseName.empty ())
70- StringBuilder.addValueBaseName (BaseName, IsMember);
78+ StringBuilder.addValueBaseName (BaseName,
79+ /* IsMember=*/ bool (Signature.BaseType ));
7180
7281 StringBuilder.addLeftParen ();
7382
7483 const ParamDecl *ParamScratch;
7584 StringBuilder.addCallArgumentPatterns (
7685 AFT->getParams (),
77- getParameterArray (FD, IsImplicitlyCurried, ParamScratch), DC, GenericSig,
78- DefaultArgumentOutputMode::All, /* includeDefaultValues=*/ true );
86+ getParameterArray (FD, Signature.IsImplicitlyCurried , ParamScratch), DC,
87+ GenericSig, DefaultArgumentOutputMode::All,
88+ /* includeDefaultValues=*/ true );
7989
8090 StringBuilder.addRightParen ();
8191
82- if (!IsImplicitlyCurried) {
83- // For a second apply, we don't pass the declaration to avoid adding
84- // incorrect rethrows and reasync which are only usable in a single apply.
85- StringBuilder.addEffectsSpecifiers (
86- AFT,
87- /* AFD=*/ IsSecondApply ? nullptr
88- : dyn_cast_or_null<AbstractFunctionDecl>(FD));
92+ if (!Signature.IsImplicitlyCurried ) {
93+ if (Signature.IsSecondApply ) {
94+ // For a second apply, we don't pass the declaration to avoid adding
95+ // incorrect rethrows and reasync which are only usable in a single apply.
96+ StringBuilder.addEffectsSpecifiers (AFT, /* AFD=*/ nullptr );
97+ } else {
98+ StringBuilder.addEffectsSpecifiers (
99+ AFT, dyn_cast_or_null<AbstractFunctionDecl>(FD));
100+ }
89101 }
90102
91103 if (FD && FD->isImplicitlyUnwrappedOptional ()) {
@@ -104,19 +116,9 @@ SignatureHelpFormatter::formatSignature(const DeclContext *DC,
104116 auto *FD = Signature.FuncD ;
105117 auto *AFT = Signature.FuncTy ;
106118
107- bool IsConstructor = false ;
108- GenericSignature genericSig;
109- if (FD) {
110- IsConstructor = isa<ConstructorDecl>(FD);
111-
112- if (auto *GC = FD->getAsGenericContext ())
113- genericSig = GC->getGenericSignature ();
114- }
119+ bool IsConstructor = isa_and_nonnull<ConstructorDecl>(FD);
115120
116- auto *SignatureString = createSignatureString (
117- FD, AFT, DC, genericSig, Signature.IsSubscript ,
118- /* IsMember=*/ bool (Signature.BaseType ), Signature.IsImplicitlyCurried ,
119- Signature.IsSecondApply );
121+ auto *SignatureString = createSignatureString (Signature, DC);
120122
121123 llvm::SmallString<512 > SS;
122124 llvm::raw_svector_ostream OS (SS);
0 commit comments