@@ -101,8 +101,8 @@ final class InferredMethodProvider(
101
101
.mkString(" , " )
102
102
103
103
def printSignature (
104
- methodName : Name ,
105
- params : List [List [Type ]],
104
+ methodName : Name ,
105
+ params : List [List [Type ]],
106
106
retTypeOpt : Option [Type ]
107
107
): String =
108
108
val retTypeString = retTypeOpt match
@@ -129,7 +129,7 @@ final class InferredMethodProvider(
129
129
if pos > 0 then
130
130
val isSpace = text(pos) == ' '
131
131
val isTab = text(pos) == '\t '
132
- val indent = countIndent(params.text(), pos, 0 )
132
+ val indent = countIndent(params.text().nn , pos, 0 )
133
133
134
134
if isSpace then " " * indent else if isTab then " \t " * indent else " "
135
135
else " "
@@ -145,8 +145,8 @@ final class InferredMethodProvider(
145
145
/**
146
146
* Returns the position to insert the method signature for a container.
147
147
* If the container has an empty body, the position is the end of the container.
148
- * If the container has a non-empty body, the position is the end of the last element in the body.
149
- *
148
+ * If the container has a non-empty body, the position is the end of the last element in the body.
149
+ *
150
150
* @param container the container to insert the method signature for
151
151
* @return the position to insert the method signature for the container and a boolean indicating if the container has an empty body
152
152
*/
@@ -170,9 +170,9 @@ final class InferredMethodProvider(
170
170
171
171
/**
172
172
* Extracts type information for a specific parameter in a method signature.
173
- * If the parameter is a function type, extracts both the function's argument types
173
+ * If the parameter is a function type, extracts both the function's argument types
174
174
* and return type. Otherwise, extracts just the parameter type.
175
- *
175
+ *
176
176
* @param methodType the method type to analyze
177
177
* @param argIndex the index of the parameter to extract information for
178
178
* @return a tuple of (argument types, return type) where:
@@ -192,10 +192,10 @@ final class InferredMethodProvider(
192
192
else
193
193
(None , Some (m.paramInfos(argIndex)))
194
194
case _ => (None , None )
195
-
195
+
196
196
def signatureEdits (signature : String ): List [TextEdit ] =
197
197
val pos = insertPosition()
198
- val indent = indentation(params.text(), pos.start - 1 )
198
+ val indent = indentation(params.text().nn , pos.start - 1 )
199
199
val lspPos = pos.toLsp
200
200
lspPos.setEnd(lspPos.getStart())
201
201
@@ -211,7 +211,7 @@ final class InferredMethodProvider(
211
211
case Some ((pos, hasEmptyBody)) =>
212
212
val lspPos = pos.toLsp
213
213
lspPos.setStart(lspPos.getEnd())
214
- val indent = indentation(params.text(), pos.start - 1 )
214
+ val indent = indentation(params.text().nn , pos.start - 1 )
215
215
216
216
if hasEmptyBody then
217
217
List (
@@ -234,17 +234,17 @@ final class InferredMethodProvider(
234
234
* outerArgs
235
235
* ---------------------------
236
236
* method(..., errorMethod(args), ...)
237
- *
237
+ *
238
238
*/
239
- case (id @ Ident (errorMethod)) ::
240
- (apply @ Apply (func, args)) ::
241
- Apply (method, outerArgs) ::
239
+ case (id @ Ident (errorMethod)) ::
240
+ (apply @ Apply (func, args)) ::
241
+ Apply (method, outerArgs) ::
242
242
_ if id.symbol == NoSymbol && func == id && method != apply =>
243
-
243
+
244
244
val argTypes = args.map(_.typeOpt.widenDealias)
245
245
246
246
val argIndex = outerArgs.indexOf(apply)
247
- val (allArgTypes, retTypeOpt) =
247
+ val (allArgTypes, retTypeOpt) =
248
248
extractParameterTypeInfo(method.tpe.widenDealias, argIndex) match
249
249
case (Some (argTypes2), retTypeOpt) => (List (argTypes, argTypes2), retTypeOpt)
250
250
case (None , retTypeOpt) => (List (argTypes), retTypeOpt)
@@ -257,12 +257,12 @@ final class InferredMethodProvider(
257
257
* outerArgs
258
258
* ---------------------
259
259
* method(..., errorMethod, ...)
260
- *
260
+ *
261
261
*/
262
- case (id @ Ident (errorMethod)) ::
263
- Apply (method, outerArgs) ::
262
+ case (id @ Ident (errorMethod)) ::
263
+ Apply (method, outerArgs) ::
264
264
_ if id.symbol == NoSymbol && method != id =>
265
-
265
+
266
266
val argIndex = outerArgs.indexOf(id)
267
267
268
268
val (argTypes, retTypeOpt) = extractParameterTypeInfo(method.tpe.widenDealias, argIndex)
@@ -272,20 +272,20 @@ final class InferredMethodProvider(
272
272
case None => Nil
273
273
274
274
val signature = printSignature(errorMethod, allArgTypes, retTypeOpt)
275
-
275
+
276
276
signatureEdits(signature)
277
277
278
278
/**
279
279
* tpt body
280
280
* ----------- ----------------
281
281
* val value: DefinedType = errorMethod(args)
282
- *
282
+ *
283
283
*/
284
- case (id @ Ident (errorMethod)) ::
285
- (apply @ Apply (func, args)) ::
286
- ValDef (_, tpt, body) ::
284
+ case (id @ Ident (errorMethod)) ::
285
+ (apply @ Apply (func, args)) ::
286
+ ValDef (_, tpt, body) ::
287
287
_ if id.symbol == NoSymbol && func == id && apply == body =>
288
-
288
+
289
289
val retType = tpt.tpe.widenDealias
290
290
val argTypes = args.map(_.typeOpt.widenDealias)
291
291
@@ -296,24 +296,24 @@ final class InferredMethodProvider(
296
296
* tpt body
297
297
* ----------- -----------
298
298
* val value: DefinedType = errorMethod
299
- *
299
+ *
300
300
*/
301
- case (id @ Ident (errorMethod)) ::
302
- ValDef (_, tpt, body) ::
301
+ case (id @ Ident (errorMethod)) ::
302
+ ValDef (_, tpt, body) ::
303
303
_ if id.symbol == NoSymbol && id == body =>
304
-
304
+
305
305
val retType = tpt.tpe.widenDealias
306
306
307
307
val signature = printSignature(errorMethod, Nil , Some (retType))
308
308
signatureEdits(signature)
309
309
310
310
/**
311
- *
311
+ *
312
312
* errorMethod(args)
313
- *
313
+ *
314
314
*/
315
- case (id @ Ident (errorMethod)) ::
316
- (apply @ Apply (func, args)) ::
315
+ case (id @ Ident (errorMethod)) ::
316
+ (apply @ Apply (func, args)) ::
317
317
_ if id.symbol == NoSymbol && func == id =>
318
318
319
319
val argTypes = args.map(_.typeOpt.widenDealias)
@@ -322,37 +322,37 @@ final class InferredMethodProvider(
322
322
signatureEdits(signature)
323
323
324
324
/**
325
- *
325
+ *
326
326
* errorMethod
327
- *
327
+ *
328
328
*/
329
- case (id @ Ident (errorMethod)) ::
329
+ case (id @ Ident (errorMethod)) ::
330
330
_ if id.symbol == NoSymbol =>
331
331
332
332
val signature = printSignature(errorMethod, Nil , None )
333
333
signatureEdits(signature)
334
334
335
335
/**
336
- *
336
+ *
337
337
* container.errorMethod(args)
338
- *
338
+ *
339
339
*/
340
- case (select @ Select (container, errorMethod)) ::
341
- (apply @ Apply (func, args)) ::
340
+ case (select @ Select (container, errorMethod)) ::
341
+ (apply @ Apply (func, args)) ::
342
342
_ if select.symbol == NoSymbol && func == select =>
343
-
343
+
344
344
val argTypes = args.map(_.typeOpt.widenDealias)
345
345
val signature = printSignature(errorMethod, List (argTypes), None )
346
346
signatureEditsForContainer(signature, container)
347
347
348
348
/**
349
- *
349
+ *
350
350
* container.errorMethod
351
- *
351
+ *
352
352
*/
353
- case (select @ Select (container, errorMethod)) ::
353
+ case (select @ Select (container, errorMethod)) ::
354
354
_ if select.symbol == NoSymbol =>
355
-
355
+
356
356
val signature = printSignature(errorMethod, Nil , None )
357
357
signatureEditsForContainer(signature, container)
358
358
0 commit comments