createDisableFileAction creates a code action to disable the diagnostic for the entire file. It inserts: /** @effect-diagnostics {ruleName}:off */ at the top of the file.
(ctx *fixable.Context, ruleName string)
| 75 | // createDisableFileAction creates a code action to disable the diagnostic for the entire file. |
| 76 | // It inserts: /** @effect-diagnostics {ruleName}:off */ at the top of the file. |
| 77 | func createDisableFileAction(ctx *fixable.Context, ruleName string) *ls.CodeAction { |
| 78 | // Create the comment text (uses :off for consistency with next-line directives) |
| 79 | comment := "/** @effect-diagnostics " + ruleName + ":off */\n" |
| 80 | |
| 81 | // Insert at the very beginning of the file (position 0) |
| 82 | insertPos := ctx.BytePosToLSPPosition(0) |
| 83 | |
| 84 | return ctx.NewFixAction(fixable.FixAction{ |
| 85 | Description: "Disable " + ruleName + " for entire file", |
| 86 | Run: func(tracker *rewriter.Tracker) { |
| 87 | tracker.InsertText(ctx.SourceFile, insertPos, comment) |
| 88 | }, |
| 89 | }) |
| 90 | } |
| 91 | |
| 92 | // getLineStartPositionForPosition finds the start of the line containing the given position. |
| 93 | func getLineStartPositionForPosition(pos int, sourceFile *ast.SourceFile) int { |
no test coverage detected