Use tool specific function to perform exclude checks (#15486)

## Summary

This PR creates separate functions to check whether the document path is
excluded for linting or formatting. The main motivation is to avoid the
double `Option` for the call sites and makes passing the correct
settings simpler.
This commit is contained in:
Dhruv Manilawala 2025-01-15 13:18:46 +05:30 committed by GitHub
parent aefb607405
commit bec8441cf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 17 deletions

View file

@ -6,7 +6,7 @@ use ruff_source_file::LineIndex;
use crate::edit::{Replacement, ToRangeExt};
use crate::fix::Fixes;
use crate::resolve::is_document_excluded;
use crate::resolve::is_document_excluded_for_formatting;
use crate::server::api::LSPResult;
use crate::server::{client::Notifier, Result};
use crate::session::{DocumentQuery, DocumentSnapshot};
@ -87,11 +87,10 @@ fn format_text_document(
// If the document is excluded, return early.
if let Some(file_path) = query.file_path() {
if is_document_excluded(
if is_document_excluded_for_formatting(
&file_path,
file_resolver_settings,
None,
Some(formatter_settings),
formatter_settings,
text_document.language_id(),
) {
return Ok(None);

View file

@ -2,7 +2,7 @@ use anyhow::Context;
use lsp_types::{self as types, request as req, Range};
use crate::edit::{RangeExt, ToRangeExt};
use crate::resolve::is_document_excluded;
use crate::resolve::is_document_excluded_for_formatting;
use crate::server::api::LSPResult;
use crate::server::{client::Notifier, Result};
use crate::session::{DocumentQuery, DocumentSnapshot};
@ -51,11 +51,10 @@ fn format_text_document_range(
// If the document is excluded, return early.
if let Some(file_path) = query.file_path() {
if is_document_excluded(
if is_document_excluded_for_formatting(
&file_path,
file_resolver_settings,
None,
Some(formatter_settings),
formatter_settings,
text_document.language_id(),
) {
return Ok(None);