mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Conside include
, extend-include
for the native server (#12252)
## 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.
e8969128
-c175-4f98-8114-0d692b906cc8
This commit is contained in:
parent
855d62cdde
commit
0bb2fc6eec
10 changed files with 101 additions and 47 deletions
|
@ -683,6 +683,39 @@ pub fn match_any_exclusion(
|
|||
None
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum InclusionKind {
|
||||
/// The inclusion came from the `include` setting.
|
||||
Include,
|
||||
/// The inclusion came from the `extend-include` setting.
|
||||
ExtendInclude,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for InclusionKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
InclusionKind::Include => write!(f, "include"),
|
||||
InclusionKind::ExtendInclude => write!(f, "extend-include"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the [`InclusionKind`] for a given [`Path`], if the path match any of the inclusion
|
||||
/// criteria.
|
||||
pub fn match_any_inclusion(
|
||||
path: &Path,
|
||||
include: &GlobSet,
|
||||
extend_include: &GlobSet,
|
||||
) -> Option<InclusionKind> {
|
||||
if include.is_match(path) {
|
||||
Some(InclusionKind::Include)
|
||||
} else if extend_include.is_match(path) {
|
||||
Some(InclusionKind::ExtendInclude)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs::{create_dir, File};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue