Directly include Settings struct for the server (#16042)

## Summary

This PR refactors the `RuffSettings` struct to directly include the
resolved `Settings` instead of including the specific fields from it.
The server utilizes a lot of it already, so it makes sense to just
include the entire struct for simplicity.

### `Deref`

I implemented `Deref` on `RuffSettings` to return the `Settings` because
`RuffSettings` is now basically a wrapper around it with the config path
as the other field. This path field is only used for debugging
("printDebugInformation" command).
This commit is contained in:
Dhruv Manilawala 2025-02-10 10:20:01 +05:30 committed by GitHub
parent b54e390cb4
commit cc0a5dd14a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 76 deletions

View file

@ -67,16 +67,15 @@ pub(crate) fn check(
show_syntax_errors: bool,
) -> DiagnosticsMap {
let source_kind = query.make_source_kind();
let file_resolver_settings = query.settings().file_resolver();
let linter_settings = query.settings().linter();
let settings = query.settings();
let document_path = query.file_path();
// If the document is excluded, return an empty list of diagnostics.
let package = if let Some(document_path) = document_path.as_ref() {
if is_document_excluded_for_linting(
document_path,
file_resolver_settings,
linter_settings,
&settings.file_resolver,
&settings.linter,
query.text_document_language_id(),
) {
return DiagnosticsMap::default();
@ -86,7 +85,7 @@ pub(crate) fn check(
document_path
.parent()
.expect("a path to a document should have a parent path"),
&linter_settings.namespace_packages,
&settings.linter.namespace_packages,
)
.map(PackageRoot::root)
} else {
@ -118,7 +117,7 @@ pub(crate) fn check(
&stylist,
&indexer,
&directives,
linter_settings,
&settings.linter,
flags::Noqa::Enabled,
&source_kind,
source_type,
@ -130,7 +129,7 @@ pub(crate) fn check(
&diagnostics,
&locator,
indexer.comment_ranges(),
&linter_settings.external,
&settings.linter.external,
&directives.noqa_line_for,
stylist.line_ending(),
);