Skip to content

refactor: extract LSP diagnostics reporting utility#21946

Closed
kitlangton wants to merge 1 commit intodevfrom
refactor/lsp-diagnostics-utility
Closed

refactor: extract LSP diagnostics reporting utility#21946
kitlangton wants to merge 1 commit intodevfrom
refactor/lsp-diagnostics-utility

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

@kitlangton kitlangton commented Apr 10, 2026

Summary

Adds LSP.Diagnostic.report(file, issues) next to the existing LSP.Diagnostic.pretty to centralize the filter / cap / <diagnostics>-block formatting that was duplicated across write, edit, and apply_patch.

Call sites keep control over their surrounding header text ("in this file", "in other files", "in {rel}") since that's the only real variation.

Stats

  • lsp/index.ts +11
  • write.ts −6 net
  • edit.ts −10 net
  • apply_patch.ts −7 net
  • Net −11 lines, no new files.

Test plan

  • bun run typecheck in packages/opencode

Extract duplicated LSP diagnostics error reporting code into a shared
utility module:

- Create diagnostics-reporter.ts with formatDiagnostics(),
  formatDiagnosticsForOtherFile(), and formatProjectDiagnostics()
- Replace 20+ lines of duplicated code in write.ts, edit.ts, and
  apply_patch.ts with single function calls
- Remove MAX_DIAGNOSTICS_PER_FILE constant duplication across files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant