Draft
Conversation
- Add DLS_TEST_DEBUG flag to control test output logs - Add DLS_CHILD_DEBUG flag to control child process logs - Allows granular control over logging during tests - Default behavior is now clean output without logs
- Add fix field to DMLError struct to carry TextEdit fixes - Update DMLError::to_diagnostic() to serialize fix into data field - Modify LinterAnalysis::new() to preserve fix from DMLStyleError - Add test_diagnostic_has_autofix_data to verify fixes in diagnostics - Create autofix.dml example file for testing - Add SOURCE_AUTOFIX and MOCK_URI_AUTOFIX test fixtures The diagnostic.data field now contains the serialized TextEdit when a lint error has an available autofix. This enables CodeAction handlers to extract these fixes and return them as quick fix actions.
- Implement CodeActionRequest handler to extract fixes from diagnostic.data - Deserialize TextEdit from diagnostic data and create CodeAction responses - Return QuickFix actions with WorkspaceEdit containing the fixes - Set is_preferred to None to let client decide preference - Add comprehensive test to verify CodeAction fixes match diagnostics - Test validates: action count, type, titles, edits, and exact fix matching - Update existing test to use autofix.dml with actual fixable errors CodeAction handler now reads fixes from diagnostic.data field and converts them into proper LSP CodeActions that clients can execute to apply fixes.
- Add analyze_files() as main public API for DFA functionality - Create AnalysisRequest and AnalysisResult structs for clear interface - Extract business logic from main_inner() into focused functions: - setup_client(): Configure DLS client with request parameters - open_and_analyze_files(): Open files and wait for analysis - collect_diagnostics(): Gather results from analysis - Add client.shutdown() to properly cleanup DLS process - Add integration test validating analyze_files() behavior - Add tempfile as dev dependency for test infrastructure - Keep ClientInterface as internal implementation detail This refactoring separates CLI argument parsing from business logic, making the DFA functionality testable and reusable. The test validates the refactor maintains existing behavior.
- Create text_edit module with utilities for applying TextEdits - Implement apply_edit_to_content() to apply single edit to string - Implement apply_edits_to_content() to apply multiple edits - Implement has_conflicting_edits() to detect overlapping edits - Calculate line positions from content for accurate byte offsets - Sort edits in reverse order to avoid offset shifting issues - Add comprehensive tests for all text edit functions - All functions are pub(crate) - internal to dfa module These utilities work entirely in memory with strings and will be used by the autofix functionality to apply fixes to file contents before writing them back to disk.
- Add request_code_actions() method to ClientInterface - Method sends textDocument/codeAction request to LSP server - Receives and parses CodeAction responses - Filters CodeAction items from CodeActionOrCommand enum - Returns Vec<CodeAction> with all available quick fixes - Method is pub(crate) for internal dfa module use - Add anyhow macro import for error handling - Keep ClientInterface as pub for dfa binary compatibility This enables requesting code actions from the DLS server with diagnostic context, which will be used by autofix functionality to obtain fixes that can be applied to files.
- Add autofix field to AnalysisRequest - Implement apply_fixes_to_files with subfunctions for clarity - Add text edit utilities for applying LSP TextEdits - Add CodeAction request capability to ClientInterface - Fix collect_diagnostics to populate diagnostics field - Add comprehensive tests for analyze_files with/without autofix - Add conflict detection for overlapping edits
- Replace custom text editing with Ropey rope data structure - Create text_surgery module with TextBuffer for O(log n) edits - Consolidate text manipulation into single module - Remove text_edit.rs in favor of efficient rope-based approach - Maintain public API: apply_edits_to_file() and has_conflicting_edits()
Adds --dry-run flag to preview autofix changes without modifying files. When enabled, shows what fixes would be applied but skips file writes. Only available when --autofix is enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary: Add CodeAction Support and Autofix Functionality
Overview
This PR implements LSP CodeAction support with quick fixes for DML linting errors, plus a new --autofix CLI flag that automatically applies
fixes to files.
Key Features