ruff/crates/ruff_server/src
Brent Westbrook b5c5f710fc
Render Azure, JSON, and JSON lines output with the new diagnostics (#19133)
## Summary

This was originally stacked on #19129, but some of the changes I made
for JSON also impacted the Azure format, so I went ahead and combined
them. The main changes here are:

- Implementing `FileResolver` for Ruff's `EmitterContext`
- Adding `FileResolver::notebook_index` and `FileResolver::is_notebook`
methods
- Adding a `DisplayDiagnostics` (with an "s") type for rendering a group
of diagnostics at once
- Adding `Azure`, `Json`, and `JsonLines` as new `DiagnosticFormat`s

I tried a couple of alternatives to the `FileResolver::notebook` methods
like passing down the `NotebookIndex` separately and trying to reparse a
`Notebook` from Ruff's `SourceFile`. The latter seemed promising, but
the `SourceFile` only stores the concatenated plain text of the
notebook, not the re-parsable JSON. I guess the current version is just
a variation on passing the `NotebookIndex`, but at least we can reuse
the existing `resolver` argument. I think a lot of this can be cleaned
up once Ruff has its own actual file resolver.

As suggested, I also tried deleting the corresponding `Emitter` files in
`ruff_linter`, but it doesn't look like git was able to follow this as a
rename. It did, however, track that the tests were moved, so the
snapshots should be easy to review.

## Test Plan

Existing Ruff tests ported to tests in `ruff_db`. I think some other
existing ruff tests also cover parts of this refactor.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2025-07-11 15:04:46 -04:00
..
edit Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
server [ty] Add documentation for server traits (#19137) 2025-07-07 14:26:09 +00:00
session Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
edit.rs Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
fix.rs Consider virtual path for various server actions (#18910) 2025-06-24 12:24:28 +00:00
format.rs Consider virtual path for various server actions (#18910) 2025-06-24 12:24:28 +00:00
lib.rs Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
lint.rs Render Azure, JSON, and JSON lines output with the new diagnostics (#19133) 2025-07-11 15:04:46 -04:00
logging.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
resolve.rs Root exclusions in the server to project root (#16043) 2025-02-10 04:57:14 +00:00
server.rs Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
session.rs Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
workspace.rs Centralize client options validation (#18623) 2025-06-12 18:58:30 +02:00