-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary This PR updates the native server to consider the `include` and `extend-include` file resolver settings. fixes: #12242 ## Test Plan Note: Settings reloading doesn't work for nested configs which is fixed in #12253 so the preview here only showcases root level config. https://github.com/astral-sh/ruff/assets/67177269/e8969128-c175-4f98-8114-0d692b906cc8
- Loading branch information
1 parent
855d62c
commit 0bb2fc6
Showing
10 changed files
with
101 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ mod edit; | |
mod fix; | ||
mod format; | ||
mod lint; | ||
mod resolve; | ||
mod server; | ||
mod session; | ||
mod trace; | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::Path; | ||
|
||
use ruff_linter::settings::LinterSettings; | ||
use ruff_workspace::resolver::{match_any_exclusion, match_any_inclusion}; | ||
use ruff_workspace::{FileResolverSettings, FormatterSettings}; | ||
|
||
/// Return `true` if the document at the given [`Path`] should be excluded. | ||
/// | ||
/// The tool-specific settings should be provided if the request for the document is specific to | ||
/// that tool. For example, a diagnostics request should provide the linter settings while the | ||
/// formatting request should provide the formatter settings. | ||
/// | ||
/// The logic for the resolution considers both inclusion and exclusion and is as follows: | ||
/// 1. Check for global `exclude` and `extend-exclude` options along with tool specific `exclude` | ||
/// option (`lint.exclude`, `format.exclude`). | ||
/// 2. Check for global `include` and `extend-include` options. | ||
pub(crate) fn is_document_excluded( | ||
path: &Path, | ||
resolver_settings: &FileResolverSettings, | ||
linter_settings: Option<&LinterSettings>, | ||
formatter_settings: Option<&FormatterSettings>, | ||
) -> bool { | ||
if let Some(exclusion) = match_any_exclusion( | ||
path, | ||
&resolver_settings.exclude, | ||
&resolver_settings.extend_exclude, | ||
linter_settings.map(|s| &*s.exclude), | ||
formatter_settings.map(|s| &*s.exclude), | ||
) { | ||
tracing::debug!("Ignored path via `{}`: {}", exclusion, path.display()); | ||
return true; | ||
} | ||
|
||
if let Some(inclusion) = match_any_inclusion( | ||
path, | ||
&resolver_settings.include, | ||
&resolver_settings.extend_include, | ||
) { | ||
tracing::debug!("Included path via `{}`: {}", inclusion, path.display()); | ||
false | ||
} else { | ||
// Path is excluded by not being in the inclusion set. | ||
true | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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