@@ -401,12 +401,16 @@ func getRewriteCodeActions(ctx context.Context, pkg *cache.Package, snapshot *ca
401
401
// indicated by the given [start, end) range.
402
402
//
403
403
// This is true if:
404
+ // - there are no parse or type errors, and
404
405
// - [start, end) is contained within an unused field or parameter name
405
406
// - ... of a non-method function declaration.
406
407
//
407
408
// (Note that the unusedparam analyzer also computes this property, but
408
409
// much more precisely, allowing it to report its findings as diagnostics.)
409
410
func canRemoveParameter (pkg * cache.Package , pgf * parsego.File , rng protocol.Range ) bool {
411
+ if perrors , terrors := pkg .ParseErrors (), pkg .TypeErrors (); len (perrors ) > 0 || len (terrors ) > 0 {
412
+ return false // can't remove parameters from packages with errors
413
+ }
410
414
info , err := FindParam (pgf , rng )
411
415
if err != nil {
412
416
return false // e.g. invalid range
@@ -449,7 +453,7 @@ func getInlineCodeActions(pkg *cache.Package, pgf *parsego.File, rng protocol.Ra
449
453
return nil , err
450
454
}
451
455
452
- // If range is within call expression, offer inline action .
456
+ // If range is within call expression, offer to inline the call .
453
457
var commands []protocol.Command
454
458
if _ , fn , err := EnclosingStaticCall (pkg , pgf , start , end ); err == nil {
455
459
cmd , err := command .NewApplyFixCommand (fmt .Sprintf ("Inline call to %s" , fn .Name ()), command.ApplyFixArgs {
0 commit comments