mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-11-03 21:24:29 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									aefb607405
								
							
						
					
					
						commit
						bec8441cf5
					
				
					 5 changed files with 47 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue