Skip to content

Support LSP source.fixAll#3382

Merged
jakebailey merged 10 commits intomainfrom
jabaile/fix-all
Apr 10, 2026
Merged

Support LSP source.fixAll#3382
jakebailey merged 10 commits intomainfrom
jabaile/fix-all

Conversation

@jakebailey
Copy link
Copy Markdown
Member

This adds source.fixAll support. For example, running the "Fix All" command in VS Code nets:

2026-04-09 15:10:58.188 [trace] Sending request 'textDocument/codeAction - (11)'.
Params: {
    "textDocument": {
        "uri": "file:///home/jabaile/work/vscode/extensions/typescript-language-features/src/lazyClientHost.ts"
    },
    "range": {
        "start": {
            "line": 33,
            "character": 17
        },
        "end": {
            "line": 33,
            "character": 17
        }
    },
    "context": {
        "diagnostics": [],
        "only": [
            "source.fixAll"
        ],
        "triggerKind": 1
    }
}
2026-04-09 15:10:58.474 [trace] Received response 'textDocument/codeAction - (11)' in 286ms.
Result: [
    {
        "title": "Fix All",
        "kind": "source.fixAll",
        "edit": {
            "changes": {
                "file:///home/jabaile/work/vscode/extensions/typescript-language-features/src/lazyClientHost.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 19,
                                "character": 0
                            },
                            "end": {
                                "line": 19,
                                "character": 0
                            }
                        },
                        "newText": "import { ActiveJsTsEditorTracker } from './ui/activeJsTsEditorTracker';\nimport { Lazy } from './utils/lazy';\n"
                    }
                ]
            }
        }
    }
]

This involved porting more fourslash code; mostly code stolen from #3304. But, it required more to also handle imports as we now have a test which breaks the import elision heuristic in the converter. Yay.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds source.fixAll support to the Go TypeScript LSP/LS implementation, along with “fix all missing imports” aggregation and new fourslash conversion/test infrastructure to validate code-fix behavior.

Changes:

  • Advertise and implement the source.fixAll code action kind in the LSP/LS code action pipeline.
  • Add a “get all code actions” path for import fixes, coalescing multiple missing-import diagnostics into consolidated edits via ImportAdder.
  • Extend the fourslash converter and add generated tests/helpers for codeFix, codeFixAvailable, and codeFixAll.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/lsp/server.go Advertises source.fixAll as a supported code action kind.
internal/ls/codeactions.go Adds source.fixAll handling and kind hierarchy matching helper.
internal/ls/codeactions_importfixes.go Implements GetAllCodeActions for import-related “fix all” aggregation.
internal/ls/autoimport/import_adder.go Extends ImportAdder with AddImportFix to accumulate fixes directly.
internal/fourslash/fourslash.go Adds fourslash helpers for verifying code fixes and “codeFixAll”.
internal/fourslash/_scripts/failingTests.txt Marks additional generated fourslash tests as failing/skipped.
internal/fourslash/_scripts/convertFourslash.mts Ports fourslash parsing/generation for code-fix verification and import handling.
internal/fourslash/tests/gen/importNameCodeFix_types_classic_test.go New generated code-fix-all test coverage (classic module resolution).
internal/fourslash/tests/gen/importNameCodeFix_typeOnly2_test.go New generated code-fix-all test coverage (type-only scenarios).
internal/fourslash/tests/gen/importNameCodeFix_require_UMD_test.go New generated code-fix test coverage for require + UMD.
internal/fourslash/tests/gen/importNameCodeFix_require_test.go New generated code-fix-all test coverage for require imports.
internal/fourslash/tests/gen/importNameCodeFix_require_namedAndDefault_test.go New generated code-fix-all test coverage for named+default require shape.
internal/fourslash/tests/gen/importNameCodeFix_require_importVsRequire_moduleTarget_test.go New generated test coverage for import vs require selection based on module target.
internal/fourslash/tests/gen/importNameCodeFix_require_importVsRequire_importWins_test.go New generated test coverage for import vs require precedence (import wins).
internal/fourslash/tests/gen/importNameCodeFix_require_importVsRequire_addToExistingWins_test.go New generated test coverage for “add to existing” precedence.
internal/fourslash/tests/gen/importNameCodeFix_require_addToExisting_test.go New generated test coverage for updating existing require destructuring.
internal/fourslash/tests/gen/importNameCodeFix_jsExtension_test.go New generated test coverage for .js/.jsx extension module specifiers.
internal/fourslash/tests/gen/importNameCodeFix_exportEquals_test.go New generated test coverage for export = import forms.
internal/fourslash/tests/gen/importNameCodeFix_all2_test.go New generated code-fix-all test coverage (multiple imports).
internal/fourslash/tests/gen/importNameCodeFix_all_test.go New generated broad code-fix-all coverage across many import shapes.
internal/fourslash/tests/gen/importNameCodeFix_all_promoteType_test.go New generated code-fix-all coverage for promote-type-only cases.
internal/fourslash/tests/gen/importNameCodeFix_all_js_test.go New generated code-fix-all coverage in JS + JSDoc import types.
internal/fourslash/tests/gen/importNameCodeFix_add_all_missing_imports_test.go New generated code-fix-all coverage for multiple missing imports.
internal/fourslash/tests/gen/codeFixAddMissingImportForReactJsx2_test.go New generated code-fix-all coverage for react-jsxdev missing imports.
internal/fourslash/tests/gen/codeFixAddMissingImportForReactJsx1_test.go New generated code-fix-all coverage for react-jsx missing imports.
internal/fourslash/tests/gen/autoImportTypeOnlyPreferred3_test.go New generated tests for type-only auto-import preference interactions.
internal/fourslash/tests/gen/addAllMissingImportsNoCrash_test.go New generated regression test ensuring “add all missing imports” doesn’t crash.

Copy link
Copy Markdown
Member

@gabritto gabritto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some questions but this looks good

@jakebailey jakebailey marked this pull request as draft April 10, 2026 16:18
@jakebailey jakebailey marked this pull request as ready for review April 10, 2026 17:03
@jakebailey jakebailey marked this pull request as draft April 10, 2026 17:27
@jakebailey jakebailey marked this pull request as ready for review April 10, 2026 20:58
@jakebailey jakebailey requested review from Copilot and gabritto April 10, 2026 20:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 31 changed files in this pull request and generated 4 comments.

@jakebailey jakebailey added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit f7d9fde Apr 10, 2026
21 checks passed
@jakebailey jakebailey deleted the jabaile/fix-all branch April 10, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants