diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 32 |
3 files changed, 27 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 06dd373c0..60d9671de 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -350,7 +350,7 @@ fn on_notification( | |||
350 | .write() | 350 | .write() |
351 | .add_file_overlay(&path, params.text_document.text) | 351 | .add_file_overlay(&path, params.text_document.text) |
352 | { | 352 | { |
353 | subs.add_sub(FileId(file_id.0)); | 353 | subs.add_sub(FileId(file_id.0.into())); |
354 | } | 354 | } |
355 | return Ok(()); | 355 | return Ok(()); |
356 | } | 356 | } |
@@ -379,7 +379,7 @@ fn on_notification( | |||
379 | .to_file_path() | 379 | .to_file_path() |
380 | .map_err(|()| format_err!("invalid uri: {}", uri))?; | 380 | .map_err(|()| format_err!("invalid uri: {}", uri))?; |
381 | if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { | 381 | if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { |
382 | subs.remove_sub(FileId(file_id.0)); | 382 | subs.remove_sub(FileId(file_id.0.into())); |
383 | } | 383 | } |
384 | let params = req::PublishDiagnosticsParams { | 384 | let params = req::PublishDiagnosticsParams { |
385 | uri, | 385 | uri, |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index b5792f3b8..4e895a9a9 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -337,7 +337,10 @@ pub fn handle_runnables( | |||
337 | None => return Ok(None), | 337 | None => return Ok(None), |
338 | }; | 338 | }; |
339 | let file_id = world.analysis().crate_root(crate_id)?; | 339 | let file_id = world.analysis().crate_root(crate_id)?; |
340 | let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0)); | 340 | let path = world |
341 | .vfs | ||
342 | .read() | ||
343 | .file2path(ra_vfs::VfsFile(file_id.0.into())); | ||
341 | let res = world.workspaces.iter().find_map(|ws| { | 344 | let res = world.workspaces.iter().find_map(|ws| { |
342 | let tgt = ws.target_by_root(&path)?; | 345 | let tgt = ws.target_by_root(&path)?; |
343 | let res = CargoTargetSpec { | 346 | let res = CargoTargetSpec { |
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index c183c25af..ebf2b15cc 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -49,7 +49,7 @@ impl ServerWorldState { | |||
49 | let (mut vfs, roots) = Vfs::new(roots); | 49 | let (mut vfs, roots) = Vfs::new(roots); |
50 | for r in roots { | 50 | for r in roots { |
51 | let is_local = vfs.root2path(r).starts_with(&root); | 51 | let is_local = vfs.root2path(r).starts_with(&root); |
52 | change.add_root(SourceRootId(r.0), is_local); | 52 | change.add_root(SourceRootId(r.0.into()), is_local); |
53 | } | 53 | } |
54 | 54 | ||
55 | let mut crate_graph = CrateGraph::default(); | 55 | let mut crate_graph = CrateGraph::default(); |
@@ -60,7 +60,7 @@ impl ServerWorldState { | |||
60 | for tgt in pkg.targets(ws) { | 60 | for tgt in pkg.targets(ws) { |
61 | let root = tgt.root(ws); | 61 | let root = tgt.root(ws); |
62 | if let Some(file_id) = vfs.load(root) { | 62 | if let Some(file_id) = vfs.load(root) { |
63 | let file_id = FileId(file_id.0); | 63 | let file_id = FileId(file_id.0.into()); |
64 | let crate_id = crate_graph.add_crate_root(file_id); | 64 | let crate_id = crate_graph.add_crate_root(file_id); |
65 | if tgt.kind(ws) == TargetKind::Lib { | 65 | if tgt.kind(ws) == TargetKind::Lib { |
66 | pkg_to_lib_crate.insert(pkg, crate_id); | 66 | pkg_to_lib_crate.insert(pkg, crate_id); |
@@ -113,14 +113,19 @@ impl ServerWorldState { | |||
113 | if root_path.starts_with(&self.root) { | 113 | if root_path.starts_with(&self.root) { |
114 | self.roots_to_scan -= 1; | 114 | self.roots_to_scan -= 1; |
115 | for (file, path, text) in files { | 115 | for (file, path, text) in files { |
116 | change.add_file(SourceRootId(root.0), FileId(file.0), path, text); | 116 | change.add_file( |
117 | SourceRootId(root.0.into()), | ||
118 | FileId(file.0.into()), | ||
119 | path, | ||
120 | text, | ||
121 | ); | ||
117 | } | 122 | } |
118 | } else { | 123 | } else { |
119 | let files = files | 124 | let files = files |
120 | .into_iter() | 125 | .into_iter() |
121 | .map(|(vfsfile, path, text)| (FileId(vfsfile.0), path, text)) | 126 | .map(|(vfsfile, path, text)| (FileId(vfsfile.0.into()), path, text)) |
122 | .collect(); | 127 | .collect(); |
123 | libs.push((SourceRootId(root.0), files)); | 128 | libs.push((SourceRootId(root.0.into()), files)); |
124 | } | 129 | } |
125 | } | 130 | } |
126 | VfsChange::AddFile { | 131 | VfsChange::AddFile { |
@@ -129,13 +134,18 @@ impl ServerWorldState { | |||
129 | path, | 134 | path, |
130 | text, | 135 | text, |
131 | } => { | 136 | } => { |
132 | change.add_file(SourceRootId(root.0), FileId(file.0), path, text); | 137 | change.add_file( |
138 | SourceRootId(root.0.into()), | ||
139 | FileId(file.0.into()), | ||
140 | path, | ||
141 | text, | ||
142 | ); | ||
133 | } | 143 | } |
134 | VfsChange::RemoveFile { root, file, path } => { | 144 | VfsChange::RemoveFile { root, file, path } => { |
135 | change.remove_file(SourceRootId(root.0), FileId(file.0), path) | 145 | change.remove_file(SourceRootId(root.0.into()), FileId(file.0.into()), path) |
136 | } | 146 | } |
137 | VfsChange::ChangeFile { file, text } => { | 147 | VfsChange::ChangeFile { file, text } => { |
138 | change.change_file(FileId(file.0), text); | 148 | change.change_file(FileId(file.0.into()), text); |
139 | } | 149 | } |
140 | } | 150 | } |
141 | } | 151 | } |
@@ -173,18 +183,18 @@ impl ServerWorld { | |||
173 | .read() | 183 | .read() |
174 | .path2file(&path) | 184 | .path2file(&path) |
175 | .ok_or_else(|| format_err!("unknown file: {}", path.display()))?; | 185 | .ok_or_else(|| format_err!("unknown file: {}", path.display()))?; |
176 | Ok(FileId(file.0)) | 186 | Ok(FileId(file.0.into())) |
177 | } | 187 | } |
178 | 188 | ||
179 | pub fn file_id_to_uri(&self, id: FileId) -> Result<Url> { | 189 | pub fn file_id_to_uri(&self, id: FileId) -> Result<Url> { |
180 | let path = self.vfs.read().file2path(VfsFile(id.0)); | 190 | let path = self.vfs.read().file2path(VfsFile(id.0.into())); |
181 | let url = Url::from_file_path(&path) | 191 | let url = Url::from_file_path(&path) |
182 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; | 192 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; |
183 | Ok(url) | 193 | Ok(url) |
184 | } | 194 | } |
185 | 195 | ||
186 | pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result<Url> { | 196 | pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result<Url> { |
187 | let base = self.vfs.read().root2path(VfsRoot(root.0)); | 197 | let base = self.vfs.read().root2path(VfsRoot(root.0.into())); |
188 | let path = path.to_path(base); | 198 | let path = path.to_path(base); |
189 | let url = Url::from_file_path(&path) | 199 | let url = Url::from_file_path(&path) |
190 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; | 200 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; |