@@ -12,13 +12,11 @@ use std::{
1212 fmt,
1313 ops:: Range ,
1414 panic,
15- path:: PathBuf ,
1615 sync:: Arc ,
1716 time:: { Duration , Instant } ,
1817} ;
1918
2019use crossbeam_channel:: { never, select, unbounded, RecvError , Sender } ;
21- use itertools:: Itertools ;
2220use lsp_server:: { Connection , ErrorCode , Message , Notification , Request , RequestId , Response } ;
2321use lsp_types:: {
2422 DidChangeTextDocumentParams , NumberOrString , TextDocumentContentChangeEvent , WorkDoneProgress ,
@@ -28,15 +26,15 @@ use lsp_types::{
2826use ra_flycheck:: { CheckTask , Status } ;
2927use ra_ide:: { Canceled , FileId , LibraryData , LineIndex , SourceRootId } ;
3028use ra_prof:: profile;
31- use ra_project_model:: { PackageRoot , ProjectManifest , ProjectWorkspace } ;
29+ use ra_project_model:: { PackageRoot , ProjectWorkspace } ;
3230use ra_vfs:: { VfsFile , VfsTask , Watch } ;
3331use relative_path:: RelativePathBuf ;
3432use rustc_hash:: FxHashSet ;
3533use serde:: { de:: DeserializeOwned , Serialize } ;
3634use threadpool:: ThreadPool ;
3735
3836use crate :: {
39- config:: { Config , FilesWatcher } ,
37+ config:: { Config , FilesWatcher , LinkedProject } ,
4038 diagnostics:: { to_proto:: url_from_path_with_drive_lowercasing, DiagnosticTask } ,
4139 from_proto,
4240 global_state:: { GlobalState , GlobalStateSnapshot } ,
@@ -70,7 +68,7 @@ impl fmt::Display for LspError {
7068
7169impl Error for LspError { }
7270
73- pub fn main_loop ( ws_roots : Vec < PathBuf > , config : Config , connection : Connection ) -> Result < ( ) > {
71+ pub fn main_loop ( config : Config , connection : Connection ) -> Result < ( ) > {
7472 log:: info!( "initial config: {:#?}" , config) ;
7573
7674 // Windows scheduler implements priority boosts: if thread waits for an
@@ -95,25 +93,24 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
9593 let mut loop_state = LoopState :: default ( ) ;
9694 let mut global_state = {
9795 let workspaces = {
98- // FIXME: support dynamic workspace loading.
99- let project_roots = ProjectManifest :: discover_all ( & ws_roots) ;
100-
101- if project_roots. is_empty ( ) && config. notifications . cargo_toml_not_found {
96+ if config. linked_projects . is_empty ( ) && config. notifications . cargo_toml_not_found {
10297 show_message (
10398 lsp_types:: MessageType :: Error ,
104- format ! (
105- "rust-analyzer failed to discover workspace, no Cargo.toml found, dirs searched: {}" ,
106- ws_roots. iter( ) . format_with( ", " , |it, f| f( & it. display( ) ) )
107- ) ,
99+ "rust-analyzer failed to discover workspace" . to_string ( ) ,
108100 & connection. sender ,
109101 ) ;
110102 } ;
111103
112- project_roots
113- . into_iter ( )
104+ config
105+ . linked_projects
106+ . iter ( )
107+ . filter_map ( |project| match project {
108+ LinkedProject :: ProjectManifest ( it) => Some ( it) ,
109+ LinkedProject :: JsonProject ( _) => None ,
110+ } )
114111 . filter_map ( |root| {
115112 ra_project_model:: ProjectWorkspace :: load (
116- root,
113+ root. clone ( ) ,
117114 & config. cargo ,
118115 config. with_sysroot ,
119116 )
0 commit comments