Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Dec 4, 2025

This PR refactors the diagnostic code action data structure in the language server, replacing the PossibleFixContent enum with an Option design. This simplifies the code by using a more direct representation where None indicates no fixes and Some(LinterCodeAction) contains a vector of available fixes.

Because the fixes are mostly 2 or more, this data struct is better (that what ChatGPT told me).
2 for ignoring the diagnostic for the line/file and possible more for fixing it.
The only time a fix is zero or one is when a parser error happened or an unused disable directive is reported.

Given:
-mostly None
-often multiple fixes (≥3)
-rarely Single
→ You should prefer the Option<Vec> version.
✔️ Smaller memory use for the dominant cases
✔️ No enum tag overhead
✔️ Only one representation (Vec) simplifies code
✔️ Very efficient for multiple items
✔️ No downside since Single is rare

Copy link
Member Author

Sysix commented Dec 4, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the A-editor Area - Editor and Language Server label Dec 4, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Dec 4, 2025
@Sysix Sysix requested a review from Copilot December 4, 2025 20:01
@graphite-app graphite-app bot changed the base branch from 12-04-test_oxlint_lsp_add_codeaction.is_preferred_info_to_snapshot_files to graphite-base/16514 December 4, 2025 20:01
Copilot finished reviewing on behalf of Sysix December 4, 2025 20:04
Copy link
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

This PR refactors the diagnostic code action data structure in the language server, replacing the PossibleFixContent enum with an Option<LinterCodeAction> design. This simplifies the code by using a more direct representation where None indicates no fixes and Some(LinterCodeAction) contains a vector of available fixes.

Key changes:

  • Replaced PossibleFixContent enum (None/Single/Multiple variants) with Option<LinterCodeAction> containing Vec<FixedContent>
  • Refactored add_ignore_fixes to mutate a vector instead of returning a transformed enum
  • Updated code action generation logic to work with the new structure using filter_map

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
crates/oxc_language_server/src/linter/error_with_position.rs Introduces LinterCodeAction struct, removes PossibleFixContent enum, and refactors message_to_lsp_diagnostic and add_ignore_fixes to use mutable vector approach
crates/oxc_language_server/src/linter/code_actions.rs Updates function signatures to accept LinterCodeAction references and simplifies logic by working directly with vectors instead of enum matching
crates/oxc_language_server/src/linter/server_linter.rs Adapts code action generation to use filter_map with the new Option<LinterCodeAction> structure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graphite-app graphite-app bot force-pushed the graphite-base/16514 branch from e12d085 to a7fa043 Compare December 4, 2025 20:06
@graphite-app graphite-app bot force-pushed the 12-04-refactor_oxlint_lsp_store_option_vec_fixedcontent_for_diagnosticreport_code_action_part branch from b27f09a to 648a732 Compare December 4, 2025 20:06
@graphite-app graphite-app bot changed the base branch from graphite-base/16514 to main December 4, 2025 20:07
@graphite-app graphite-app bot force-pushed the 12-04-refactor_oxlint_lsp_store_option_vec_fixedcontent_for_diagnosticreport_code_action_part branch from 648a732 to c82b7b0 Compare December 4, 2025 20:07
@Sysix Sysix force-pushed the 12-04-refactor_oxlint_lsp_store_option_vec_fixedcontent_for_diagnosticreport_code_action_part branch from c82b7b0 to 058e234 Compare December 4, 2025 20:36
@Sysix Sysix marked this pull request as ready for review December 4, 2025 20:41
@Sysix Sysix requested a review from camc314 as a code owner December 4, 2025 20:42
@camc314 camc314 self-assigned this Dec 5, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 5, 2025
Copy link
Contributor

camc314 commented Dec 5, 2025

Merge activity

…icReport` code action part (#16514)

> This PR refactors the diagnostic code action data structure in the language server, replacing the PossibleFixContent enum with an Option<LinterCodeAction> design. This simplifies the code by using a more direct representation where None indicates no fixes and Some(LinterCodeAction) contains a vector of available fixes.

Because the fixes are mostly 2 or more, this data struct is better (that what ChatGPT told me).
2 for ignoring the diagnostic for the line/file and possible more for fixing it.
The only time a fix is zero or one is when a parser error happened or an unused disable directive is reported.

> Given:
> -mostly None
> -often multiple fixes (≥3)
> -rarely Single
> → You should prefer the Option<Vec<FixedContent>> version.
> ✔️ Smaller memory use for the dominant cases
> ✔️ No enum tag overhead
> ✔️ Only one representation (Vec) simplifies code
> ✔️ Very efficient for multiple items
> ✔️ No downside since Single is rare
@graphite-app graphite-app bot force-pushed the 12-04-refactor_oxlint_lsp_store_option_vec_fixedcontent_for_diagnosticreport_code_action_part branch from 058e234 to 316ef44 Compare December 5, 2025 13:50
@graphite-app graphite-app bot merged commit 316ef44 into main Dec 5, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-04-refactor_oxlint_lsp_store_option_vec_fixedcontent_for_diagnosticreport_code_action_part branch December 5, 2025 13:55
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants