mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 17:42:47 +00:00
Draft detached files retrieval
This commit is contained in:
parent
b3383b0661
commit
695569d978
@ -50,6 +50,7 @@ pub use proc_macro_api::ProcMacroClient;
|
||||
pub enum ProjectManifest {
|
||||
ProjectJson(AbsPathBuf),
|
||||
CargoToml(AbsPathBuf),
|
||||
DetachedFile(AbsPathBuf),
|
||||
}
|
||||
|
||||
impl ProjectManifest {
|
||||
|
@ -148,6 +148,9 @@ impl ProjectWorkspace {
|
||||
let rustc_cfg = rustc_cfg::get(Some(&cargo_toml), config.target.as_deref());
|
||||
ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg }
|
||||
}
|
||||
ProjectManifest::DetachedFile(_) => {
|
||||
todo!("TODO kb")
|
||||
}
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
|
@ -214,7 +214,7 @@ fn run_server() -> Result<()> {
|
||||
|
||||
let discovered = ProjectManifest::discover_all(&workspace_roots);
|
||||
log::info!("discovered projects: {:?}", discovered);
|
||||
if discovered.is_empty() {
|
||||
if discovered.is_empty() && config.detached_files().is_empty() {
|
||||
log::error!("failed to find any projects in {:?}", workspace_roots);
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,7 @@ impl Default for ConfigData {
|
||||
pub struct Config {
|
||||
caps: lsp_types::ClientCapabilities,
|
||||
data: ConfigData,
|
||||
detached_files: Vec<ProjectManifest>,
|
||||
pub discovered_projects: Option<Vec<ProjectManifest>>,
|
||||
pub root_path: AbsPathBuf,
|
||||
}
|
||||
@ -328,13 +329,24 @@ pub struct WorkspaceSymbolConfig {
|
||||
|
||||
impl Config {
|
||||
pub fn new(root_path: AbsPathBuf, caps: ClientCapabilities) -> Self {
|
||||
Config { caps, data: ConfigData::default(), discovered_projects: None, root_path }
|
||||
Config {
|
||||
caps,
|
||||
data: ConfigData::default(),
|
||||
detached_files: Vec::new(),
|
||||
discovered_projects: None,
|
||||
root_path,
|
||||
}
|
||||
}
|
||||
pub fn update(&mut self, json: serde_json::Value) {
|
||||
pub fn update(&mut self, mut json: serde_json::Value) {
|
||||
log::info!("updating config from JSON: {:#}", json);
|
||||
if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) {
|
||||
return;
|
||||
}
|
||||
self.detached_files = get_field::<Vec<PathBuf>>(&mut json, "detachedFiles", None, "[]")
|
||||
.into_iter()
|
||||
.map(AbsPathBuf::assert)
|
||||
.map(ProjectManifest::DetachedFile)
|
||||
.collect();
|
||||
self.data = ConfigData::from_json(json);
|
||||
}
|
||||
|
||||
@ -387,6 +399,10 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn detached_files(&self) -> &[ProjectManifest] {
|
||||
&self.detached_files
|
||||
}
|
||||
|
||||
pub fn did_save_text_document_dynamic_registration(&self) -> bool {
|
||||
let caps =
|
||||
try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default());
|
||||
|
@ -103,6 +103,7 @@ impl fmt::Debug for Event {
|
||||
impl GlobalState {
|
||||
fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> {
|
||||
if self.config.linked_projects().is_empty()
|
||||
&& self.config.detached_files().is_empty()
|
||||
&& self.config.notifications().cargo_toml_not_found
|
||||
{
|
||||
self.show_message(
|
||||
|
@ -146,6 +146,7 @@ impl GlobalState {
|
||||
log::info!("will fetch workspaces");
|
||||
|
||||
self.task_pool.handle.spawn_with_sender({
|
||||
// TODO kb reload workspace here?
|
||||
let linked_projects = self.config.linked_projects();
|
||||
let cargo_config = self.config.cargo();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user