|
1 | 1 | //! Assorted functions shared by several assists.
|
2 | 2 |
|
3 |
| -use std::ops; |
4 |
| - |
5 | 3 | pub(crate) use gen_trait_fn_body::gen_trait_fn_body;
|
6 | 4 | use hir::{db::HirDatabase, HasAttrs as HirHasAttrs, HirDisplay, InFile, Semantics};
|
7 | 5 | use ide_db::{
|
8 | 6 | famous_defs::FamousDefs, path_transform::PathTransform,
|
9 |
| - syntax_helpers::insert_whitespace_into_node::insert_ws_into, RootDatabase, SnippetCap, |
| 7 | + syntax_helpers::insert_whitespace_into_node::insert_ws_into, RootDatabase, |
10 | 8 | };
|
11 | 9 | use stdx::format_to;
|
12 | 10 | use syntax::{
|
@@ -217,43 +215,6 @@ pub fn add_trait_assoc_items_to_impl(
|
217 | 215 | first_item.unwrap()
|
218 | 216 | }
|
219 | 217 |
|
220 |
| -#[derive(Clone, Copy, Debug)] |
221 |
| -pub(crate) enum Cursor<'a> { |
222 |
| - Replace(&'a SyntaxNode), |
223 |
| - Before(&'a SyntaxNode), |
224 |
| -} |
225 |
| - |
226 |
| -impl<'a> Cursor<'a> { |
227 |
| - fn node(self) -> &'a SyntaxNode { |
228 |
| - match self { |
229 |
| - Cursor::Replace(node) | Cursor::Before(node) => node, |
230 |
| - } |
231 |
| - } |
232 |
| -} |
233 |
| - |
234 |
| -pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor<'_>) -> String { |
235 |
| - assert!(cursor.node().ancestors().any(|it| it == *node)); |
236 |
| - let range = cursor.node().text_range() - node.text_range().start(); |
237 |
| - let range: ops::Range<usize> = range.into(); |
238 |
| - |
239 |
| - let mut placeholder = cursor.node().to_string(); |
240 |
| - escape(&mut placeholder); |
241 |
| - let tab_stop = match cursor { |
242 |
| - Cursor::Replace(placeholder) => format!("${{0:{placeholder}}}"), |
243 |
| - Cursor::Before(placeholder) => format!("$0{placeholder}"), |
244 |
| - }; |
245 |
| - |
246 |
| - let mut buf = node.to_string(); |
247 |
| - buf.replace_range(range, &tab_stop); |
248 |
| - return buf; |
249 |
| - |
250 |
| - fn escape(buf: &mut String) { |
251 |
| - stdx::replace(buf, '{', r"\{"); |
252 |
| - stdx::replace(buf, '}', r"\}"); |
253 |
| - stdx::replace(buf, '$', r"\$"); |
254 |
| - } |
255 |
| -} |
256 |
| - |
257 | 218 | pub(crate) fn vis_offset(node: &SyntaxNode) -> TextSize {
|
258 | 219 | node.children_with_tokens()
|
259 | 220 | .find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR))
|
@@ -445,15 +406,6 @@ fn has_any_fn(imp: &ast::Impl, names: &[String]) -> bool {
|
445 | 406 | false
|
446 | 407 | }
|
447 | 408 |
|
448 |
| -/// Find the start of the `impl` block for the given `ast::Impl`. |
449 |
| -// |
450 |
| -// FIXME: this partially overlaps with `find_struct_impl` |
451 |
| -pub(crate) fn find_impl_block_start(impl_def: ast::Impl, buf: &mut String) -> Option<TextSize> { |
452 |
| - buf.push('\n'); |
453 |
| - let start = impl_def.assoc_item_list().and_then(|it| it.l_curly_token())?.text_range().end(); |
454 |
| - Some(start) |
455 |
| -} |
456 |
| - |
457 | 409 | /// Find the end of the `impl` block for the given `ast::Impl`.
|
458 | 410 | //
|
459 | 411 | // FIXME: this partially overlaps with `find_struct_impl`
|
|
0 commit comments