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:
Dhruv Manilawala 2024-07-10 09:42:57 +05:30 committed by GitHub
parent 855d62cdde
commit 0bb2fc6eec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 101 additions and 47 deletions

View file

@ -1,9 +1,8 @@
use globset::Candidate;
use ruff_linter::{
display_settings, fs::normalize_path_to, settings::types::FilePattern,
settings::types::PreviewMode,
};
use ruff_workspace::resolver::match_candidate_exclusion;
use ruff_workspace::resolver::match_exclusion;
use ruff_workspace::{
configuration::{Configuration, FormatConfiguration, LintConfiguration, RuleSelection},
pyproject::{find_user_settings_toml, settings_toml},
@ -41,6 +40,7 @@ impl std::fmt::Display for RuffSettings {
display_settings! {
formatter = f,
fields = [
self.file_resolver,
self.linter,
self.formatter
]
@ -146,20 +146,14 @@ impl RuffSettingsIndex {
.range(..directory.clone())
.rfind(|(path, _)| directory.starts_with(path))
{
let candidate = Candidate::new(&directory);
let basename = Candidate::new(file_name);
if match_candidate_exclusion(
&candidate,
&basename,
&settings.file_resolver.exclude,
) {
if match_exclusion(&directory, file_name, &settings.file_resolver.exclude) {
tracing::debug!("Ignored path via `exclude`: {}", directory.display());
walker.skip_current_dir();
continue;
} else if match_candidate_exclusion(
&candidate,
&basename,
} else if match_exclusion(
&directory,
file_name,
&settings.file_resolver.extend_exclude,
) {
tracing::debug!(