feat: centralize quick fixes in analyzer and add stdin support for IDE extensions#21
Merged
willibrandon merged 10 commits intomainfrom Aug 5, 2025
Merged
Conversation
…detection - Add MissingErrorQuickFix that intelligently finds error variables in scope - Remove all caching mechanisms from MtlogExternalAnnotator and MtlogProjectService - Improve stdin mode: pass editor content directly to analyzer without file system dependency - Add test suite with 14 scenarios for error detection - Replace clearCache() with restartProcesses() throughout - Add MtlogForceAnnotator for cases when ExternalAnnotator doesn't call apply() - Improve logging throughout for better debugging The quick fix searches for error variables in the current scope (err, e, myErr, etc.) and adds them as parameters. When no error is found, it adds 'nil' with a TODO comment.
…ension - Add scope-aware error variable detection to analyzer (findErrorVariableInScope) - Switch VS Code extension to use analyzer stdin mode for suggested fixes - Generate contextual error parameters: 'err' when in scope, 'nil' with TODO otherwise - Add test coverage for scope detection scenarios - Match GoLand plugin behavior for error parameter quick fixes - Support TODO comment placement (same line vs next line based on existing comments)
- Add suggested fixes to analyzer for MTLOG001 (template/argument mismatch) and MTLOG006 (missing error parameter) - Update GoLand plugin to use analyzer-provided fixes exclusively, removing custom quick fix implementations - Update VS Code extension to use analyzer-provided fixes and remove ~400 lines of dead code - Fix analyzer scope detection to include function parameters and named return values - Add test coverage for suggested fixes - Ensure parity between VS Code and GoLand extensions by using analyzer as single source of truth Both IDE extensions now rely exclusively on the analyzer for quick fixes, ensuring consistent behavior across platforms and simplifying maintenance.
- Fix test expectations to match new diagnostic message format where ID comes before severity - Ensure MTLOG001 diagnostic properly applies downgrade-errors flag
- Add SPLUNK_GENERAL_TERMS=--accept-sgt-current-at-splunk-com to CI workflow - Update docker-compose.test.yml with new license acceptance requirement - Fixes CI failures due to Splunk's new EULA acceptance requirement for 10.x images
There was a problem hiding this comment.
Pull Request Overview
This PR centralizes quick fix logic in the analyzer and transitions both IDE extensions to use stdin-based communication. It removes custom quick fix implementations from the GoLand plugin and VS Code extension, replacing them with analyzer-provided suggested fixes for consistent behavior across platforms.
- Implements analyzer-provided suggested fixes for MTLOG001 (template/argument mismatch) and MTLOG006 (missing error parameter)
- Transitions both IDE extensions from file-based to stdin-based analyzer communication for real-time analysis
- Removes all custom quick fix implementations (~1000+ lines of code) from IDE extensions
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| vscode-extension/mtlog-analyzer/src/extension.ts | Transitions to stdin-based analyzer communication and removes custom quick fix logic |
| goland-plugin/src/main/kotlin/com/mtlog/analyzer/quickfix/AnalyzerSuggestedQuickFix.kt | New quick fix implementation that applies analyzer-provided text edits |
| cmd/mtlog-analyzer/main.go | Adds stdin mode support for IDE extensions with JSON request/response format |
| cmd/mtlog-analyzer/analyzer/analyzer.go | Implements suggested fixes for MTLOG001 and MTLOG006 diagnostics |
| goland-plugin/src/test/kotlin/com/mtlog/analyzer/quickfix/MissingErrorQuickFixTest.kt | Test coverage for missing error parameter fixes |
goland-plugin/src/main/kotlin/com/mtlog/analyzer/quickfix/AnalyzerSuggestedQuickFix.kt
Outdated
Show resolved
Hide resolved
goland-plugin/src/test/kotlin/com/mtlog/analyzer/quickfix/MissingErrorQuickFixTest.kt
Outdated
Show resolved
Hide resolved
- Fix incorrect pointer dereference in analyzer pass.Report() calls - Clarify module vs non-module pattern logic in main.go - Improve GoLand text edit sorting to use actual document offsets - Remove unnecessary test comment
The previous commit incorrectly removed pointer dereference from pass.Report() calls. Since diagnostic is defined as *analysis.Diagnostic, the dereference is required.
…alyzer - Replace file I/O with AST-based analysis for finding line info - Fix tautological condition and unconditionally terminated loop - Remove redundant break statements in switch cases - Remove unused functions: reportDiagnostic, reportDiagnosticWithConfig, findContainingIfBlock, getErrorVariableFromIfCondition, etc. - Improve compatibility with stdin mode where files may not exist on disk
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.
Description
This PR implements analyzer-provided suggested fixes for mtlog diagnostics and transitions both IDE extensions (VS Code and GoLand) to use stdin-based communication with the analyzer. All quick fix logic is now centralized in the analyzer, ensuring consistent behavior across platforms.
Key changes:
MTLOG006 Quick Fix Details
The analyzer now intelligently adds missing error parameters to Error/E level logs:
err,e,myErr), it adds that variablenilwith a TODO comment:// TODO: replace nil with actual errorType of change
Checklist
go test ./...)golangci-lint run)Additional notes
Relates to #18