@@ -6,19 +6,19 @@ namespace ts.codefix {
6
6
* @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for.
7
7
* @returns Empty string iff there are no member insertions.
8
8
*/
9
- export function createMissingMemberNodes ( classDeclaration : ClassLikeDeclaration , possiblyMissingSymbols : ReadonlyArray < Symbol > , checker : TypeChecker , out : ( node : ClassElement ) => void ) : void {
9
+ export function createMissingMemberNodes ( classDeclaration : ClassLikeDeclaration , possiblyMissingSymbols : ReadonlyArray < Symbol > , checker : TypeChecker , options : Options , out : ( node : ClassElement ) => void ) : void {
10
10
const classMembers = classDeclaration . symbol . members ;
11
11
for ( const symbol of possiblyMissingSymbols ) {
12
12
if ( ! classMembers . has ( symbol . escapedName ) ) {
13
- addNewNodeForMemberSymbol ( symbol , classDeclaration , checker , out ) ;
13
+ addNewNodeForMemberSymbol ( symbol , classDeclaration , checker , options , out ) ;
14
14
}
15
15
}
16
16
}
17
17
18
18
/**
19
19
* @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`.
20
20
*/
21
- function addNewNodeForMemberSymbol ( symbol : Symbol , enclosingDeclaration : ClassLikeDeclaration , checker : TypeChecker , out : ( node : Node ) => void ) : void {
21
+ function addNewNodeForMemberSymbol ( symbol : Symbol , enclosingDeclaration : ClassLikeDeclaration , checker : TypeChecker , options : Options , out : ( node : Node ) => void ) : void {
22
22
const declarations = symbol . getDeclarations ( ) ;
23
23
if ( ! ( declarations && declarations . length ) ) {
24
24
return undefined ;
@@ -63,7 +63,7 @@ namespace ts.codefix {
63
63
if ( declarations . length === 1 ) {
64
64
Debug . assert ( signatures . length === 1 ) ;
65
65
const signature = signatures [ 0 ] ;
66
- outputMethod ( signature , modifiers , name , createStubbedMethodBody ( ) ) ;
66
+ outputMethod ( signature , modifiers , name , createStubbedMethodBody ( options ) ) ;
67
67
break ;
68
68
}
69
69
@@ -74,11 +74,11 @@ namespace ts.codefix {
74
74
75
75
if ( declarations . length > signatures . length ) {
76
76
const signature = checker . getSignatureFromDeclaration ( declarations [ declarations . length - 1 ] as SignatureDeclaration ) ;
77
- outputMethod ( signature , modifiers , name , createStubbedMethodBody ( ) ) ;
77
+ outputMethod ( signature , modifiers , name , createStubbedMethodBody ( options ) ) ;
78
78
}
79
79
else {
80
80
Debug . assert ( declarations . length === signatures . length ) ;
81
- out ( createMethodImplementingSignatures ( signatures , name , optional , modifiers ) ) ;
81
+ out ( createMethodImplementingSignatures ( signatures , name , optional , modifiers , options ) ) ;
82
82
}
83
83
break ;
84
84
}
@@ -107,7 +107,13 @@ namespace ts.codefix {
107
107
return nodes && createNodeArray ( nodes . map ( getSynthesizedDeepClone ) ) ;
108
108
}
109
109
110
- export function createMethodFromCallExpression ( { typeArguments, arguments : args } : CallExpression , methodName : string , inJs : boolean , makeStatic : boolean ) : MethodDeclaration {
110
+ export function createMethodFromCallExpression (
111
+ { typeArguments, arguments : args } : CallExpression ,
112
+ methodName : string ,
113
+ inJs : boolean ,
114
+ makeStatic : boolean ,
115
+ options : Options ,
116
+ ) : MethodDeclaration {
111
117
return createMethod (
112
118
/*decorators*/ undefined ,
113
119
/*modifiers*/ makeStatic ? [ createToken ( SyntaxKind . StaticKeyword ) ] : undefined ,
@@ -118,7 +124,7 @@ namespace ts.codefix {
118
124
createTypeParameterDeclaration ( CharacterCodes . T + typeArguments . length - 1 <= CharacterCodes . Z ? String . fromCharCode ( CharacterCodes . T + i ) : `T${ i } ` ) ) ,
119
125
/*parameters*/ createDummyParameters ( args . length , /*names*/ undefined , /*minArgumentCount*/ undefined , inJs ) ,
120
126
/*type*/ inJs ? undefined : createKeywordTypeNode ( SyntaxKind . AnyKeyword ) ,
121
- createStubbedMethodBody ( ) ) ;
127
+ createStubbedMethodBody ( options ) ) ;
122
128
}
123
129
124
130
function createDummyParameters ( argCount : number , names : string [ ] | undefined , minArgumentCount : number | undefined , inJs : boolean ) : ParameterDeclaration [ ] {
@@ -137,7 +143,13 @@ namespace ts.codefix {
137
143
return parameters ;
138
144
}
139
145
140
- function createMethodImplementingSignatures ( signatures : ReadonlyArray < Signature > , name : PropertyName , optional : boolean , modifiers : ReadonlyArray < Modifier > | undefined ) : MethodDeclaration {
146
+ function createMethodImplementingSignatures (
147
+ signatures : ReadonlyArray < Signature > ,
148
+ name : PropertyName ,
149
+ optional : boolean ,
150
+ modifiers : ReadonlyArray < Modifier > | undefined ,
151
+ options : Options ,
152
+ ) : MethodDeclaration {
141
153
/** This is *a* signature with the maximal number of arguments,
142
154
* such that if there is a "maximal" signature without rest arguments,
143
155
* this is one of them.
@@ -178,7 +190,8 @@ namespace ts.codefix {
178
190
optional ,
179
191
/*typeParameters*/ undefined ,
180
192
parameters ,
181
- /*returnType*/ undefined ) ;
193
+ /*returnType*/ undefined ,
194
+ options ) ;
182
195
}
183
196
184
197
function createStubbedMethod (
@@ -187,7 +200,9 @@ namespace ts.codefix {
187
200
optional : boolean ,
188
201
typeParameters : ReadonlyArray < TypeParameterDeclaration > | undefined ,
189
202
parameters : ReadonlyArray < ParameterDeclaration > ,
190
- returnType : TypeNode | undefined ) {
203
+ returnType : TypeNode | undefined ,
204
+ options : Options
205
+ ) : MethodDeclaration {
191
206
return createMethod (
192
207
/*decorators*/ undefined ,
193
208
modifiers ,
@@ -197,16 +212,16 @@ namespace ts.codefix {
197
212
typeParameters ,
198
213
parameters ,
199
214
returnType ,
200
- createStubbedMethodBody ( ) ) ;
215
+ createStubbedMethodBody ( options ) ) ;
201
216
}
202
217
203
- function createStubbedMethodBody ( ) {
218
+ function createStubbedMethodBody ( options : Options ) : Block {
204
219
return createBlock (
205
220
[ createThrow (
206
221
createNew (
207
222
createIdentifier ( "Error" ) ,
208
223
/*typeArguments*/ undefined ,
209
- [ createLiteral ( "Method not implemented." ) ] ) ) ] ,
224
+ [ createLiteral ( "Method not implemented." , /*isSingleQuote*/ options . quote === "single" ) ] ) ) ] ,
210
225
/*multiline*/ true ) ;
211
226
}
212
227
0 commit comments