@@ -49,43 +49,55 @@ static StringRef copyAndClearString(llvm::BumpPtrAllocator &Allocator,
49
49
return Ref;
50
50
}
51
51
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
+
56
64
CodeCompletionStringBuilder StringBuilder (
57
65
Allocator, /* AnnotateResults=*/ false ,
58
- /* UnderscoreEmptyArgumentLabel=*/ !IsSubscript,
66
+ /* UnderscoreEmptyArgumentLabel=*/ !Signature. IsSubscript ,
59
67
/* FullParameterFlags=*/ true );
60
68
61
69
DeclBaseName BaseName;
62
70
63
- if (!IsSecondApply && FD) {
71
+ if (!Signature. IsSecondApply && FD) {
64
72
BaseName = FD->getBaseName ();
65
- } else if (IsSubscript) {
73
+ } else if (Signature. IsSubscript ) {
66
74
BaseName = DeclBaseName::createSubscript ();
67
75
}
68
76
69
77
if (!BaseName.empty ())
70
- StringBuilder.addValueBaseName (BaseName, IsMember);
78
+ StringBuilder.addValueBaseName (BaseName,
79
+ /* IsMember=*/ bool (Signature.BaseType ));
71
80
72
81
StringBuilder.addLeftParen ();
73
82
74
83
const ParamDecl *ParamScratch;
75
84
StringBuilder.addCallArgumentPatterns (
76
85
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 );
79
89
80
90
StringBuilder.addRightParen ();
81
91
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
+ }
89
101
}
90
102
91
103
if (FD && FD->isImplicitlyUnwrappedOptional ()) {
@@ -104,19 +116,9 @@ SignatureHelpFormatter::formatSignature(const DeclContext *DC,
104
116
auto *FD = Signature.FuncD ;
105
117
auto *AFT = Signature.FuncTy ;
106
118
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);
115
120
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);
120
122
121
123
llvm::SmallString<512 > SS;
122
124
llvm::raw_svector_ostream OS (SS);
0 commit comments