@@ -4,7 +4,8 @@ use crate::commands::scan_kind::compute_scan_kind;
44use crate :: execute:: Stdin ;
55use crate :: logging:: LoggingKind ;
66use crate :: {
7- CliDiagnostic , CliSession , Execution , LoggingLevel , VERSION , execute_mode, setup_cli_subscriber,
7+ CliDiagnostic , CliSession , Execution , LoggingLevel , TraversalMode , VERSION , execute_mode,
8+ setup_cli_subscriber,
89} ;
910use biome_configuration:: analyzer:: assist:: AssistEnabled ;
1011use biome_configuration:: analyzer:: { LinterEnabled , RuleSelector } ;
@@ -34,7 +35,7 @@ use biome_service::configuration::{LoadedConfiguration, load_configuration, load
3435use biome_service:: documentation:: Doc ;
3536use biome_service:: projects:: ProjectKey ;
3637use biome_service:: workspace:: {
37- FixFileMode , OpenProjectParams , ScanProjectFolderParams , UpdateSettingsParams ,
38+ FixFileMode , OpenProjectParams , ScanKind , ScanProjectFolderParams , UpdateSettingsParams ,
3839} ;
3940use biome_service:: { Workspace , WorkspaceError } ;
4041use bpaf:: Bpaf ;
@@ -791,6 +792,7 @@ pub(crate) trait CommandRunner: Sized {
791792 paths,
792793 duration,
793794 configuration_files,
795+ project_key,
794796 } = self . configure_workspace ( fs, console, workspace, cli_options) ?;
795797 execute_mode (
796798 execution,
@@ -799,6 +801,7 @@ pub(crate) trait CommandRunner: Sized {
799801 paths,
800802 duration,
801803 configuration_files,
804+ project_key,
802805 )
803806 }
804807
@@ -837,16 +840,37 @@ pub(crate) trait CommandRunner: Sized {
837840 . working_directory ( )
838841 . map ( BiomePath :: from)
839842 . unwrap_or_default ( ) ;
840- let project_key = workspace. open_project ( OpenProjectParams {
841- path : project_path. clone ( ) ,
842- open_uninitialized : true ,
843- } ) ?;
844843
845- let execution = self . get_execution ( cli_options, console, workspace, project_key) ?;
846- let scan_kind = compute_scan_kind ( & execution, & configuration) ;
844+ let execution = self . get_execution ( cli_options, console, workspace) ?;
845+
846+ let params = if let TraversalMode :: Lint { only, skip, .. } = execution. traversal_mode ( ) {
847+ OpenProjectParams {
848+ path : project_path. clone ( ) ,
849+ open_uninitialized : true ,
850+ only_rules : Some ( only. clone ( ) ) ,
851+ skip_rules : Some ( skip. clone ( ) ) ,
852+ }
853+ } else {
854+ OpenProjectParams {
855+ path : project_path. clone ( ) ,
856+ open_uninitialized : true ,
857+ only_rules : None ,
858+ skip_rules : None ,
859+ }
860+ } ;
861+
862+ let open_project_result = workspace. open_project ( params) ?;
863+
864+ let scan_kind = compute_scan_kind ( & execution, & configuration) . unwrap_or ( {
865+ if open_project_result. scan_kind == ScanKind :: None && configuration. use_ignore_file ( ) {
866+ ScanKind :: KnownFiles
867+ } else {
868+ open_project_result. scan_kind
869+ }
870+ } ) ;
847871
848872 let result = workspace. update_settings ( UpdateSettingsParams {
849- project_key,
873+ project_key : open_project_result . project_key ,
850874 // When the user provides the path to the configuration, we can't use its directory because
851875 // it might be outside the project, so we need to use the current project directory.
852876 workspace_directory : if is_configuration_from_user {
@@ -865,7 +889,7 @@ pub(crate) trait CommandRunner: Sized {
865889 }
866890
867891 let result = workspace. scan_project_folder ( ScanProjectFolderParams {
868- project_key,
892+ project_key : open_project_result . project_key ,
869893 path : Some ( project_path. clone ( ) ) ,
870894 watch : cli_options. use_server ,
871895 force : false , // TODO: Maybe we'll want a CLI flag for this.
@@ -886,6 +910,7 @@ pub(crate) trait CommandRunner: Sized {
886910 paths,
887911 duration : Some ( result. duration ) ,
888912 configuration_files : result. configuration_files ,
913+ project_key : open_project_result. project_key ,
889914 } )
890915 }
891916
@@ -941,7 +966,6 @@ pub(crate) trait CommandRunner: Sized {
941966 cli_options : & CliOptions ,
942967 console : & mut dyn Console ,
943968 workspace : & dyn Workspace ,
944- project_key : ProjectKey ,
945969 ) -> Result < Execution , CliDiagnostic > ;
946970
947971 // Below, methods that consumers can implement
@@ -968,6 +992,8 @@ pub(crate) struct ConfiguredWorkspace {
968992 pub duration : Option < Duration > ,
969993 /// Configuration files found inside the project
970994 pub configuration_files : Vec < BiomePath > ,
995+ /// The unique identifier of the project
996+ pub project_key : ProjectKey ,
971997}
972998
973999pub trait LoadEditorConfig : CommandRunner {
0 commit comments