getEffectCodeActions finds applicable fixables and collects their code actions.
(ctx context.Context, fixCtx *ls.CodeFixContext)
| 71 | modulespecifiers.ModuleSpecifierOptions{}, |
| 72 | true, |
| 73 | ) |
| 74 | for _, specifier := range specifiers { |
| 75 | if !strings.Contains(specifier, "/node_modules/") { |
| 76 | return specifier, kind |
| 77 | } |
| 78 | } |
| 79 | return "", modulespecifiers.ResultKindNone |
| 80 | }) |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | // effectFixProvider is the CodeFixProvider that handles all Effect diagnostic codes. |
| 85 | // It delegates to the fixables registered in internal/fixables. |
| 86 | var effectFixProvider = &ls.CodeFixProvider{ |
| 87 | ErrorCodes: fixables.AllErrorCodes(), |
| 88 | GetCodeActions: getEffectCodeActions, |
| 89 | FixIds: fixables.AllFixIDs(), |
| 90 | } |
| 91 | |
| 92 | // getEffectCodeActions finds applicable fixables and collects their code actions. |
| 93 | func getEffectCodeActions(ctx context.Context, fixCtx *ls.CodeFixContext) ([]*ls.CodeAction, error) { |
| 94 | var options *etscore.ResolvedEffectPluginOptions |
| 95 | if fixCtx.Program != nil { |
| 96 | if parsedEffectConfig := fixCtx.Program.Options().Effect; parsedEffectConfig != nil { |
| 97 | options = pluginoptions.ResolveEffectPluginOptionsForSourceFile( |
| 98 | parsedEffectConfig, |
| 99 | fixCtx.SourceFile.FileName(), |
| 100 | fixCtx.Program.Options().ConfigFilePath, |
| 101 | fixCtx.Program.UseCaseSensitiveFileNames(), |
| 102 | ) |
| 103 | |
| 104 | ch, done := fixCtx.Program.GetTypeCheckerForFile(ctx, fixCtx.SourceFile) |
| 105 | defer done() |
| 106 | |
| 107 | if ch != nil { |
| 108 | tp := typeparser.NewTypeParser(fixCtx.Program, ch) |
| 109 | fCtx := fixable.NewContext(ctx, fixCtx, options, ch, tp) |
| 110 | var actions []*ls.CodeAction |
| 111 | for _, provider := range fixables.ByErrorCode(fixCtx.ErrorCode) { |
| 112 | for _, result := range provider.Run(fCtx) { |
| 113 | action := result |
| 114 | actions = append(actions, &action) |
| 115 | } |
| 116 | } |
| 117 | return actions, nil |
| 118 | } |
nothing calls this directly
no test coverage detected