Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1161082

Browse files
committed
Remove unused code in utils
All usages of `render_snippet` and `Cursor` have been removed as part of the migration
1 parent 8eebf17 commit 1161082

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

crates/ide-assists/src/utils.rs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
//! Assorted functions shared by several assists.
22
3-
use std::ops;
4-
53
pub(crate) use gen_trait_fn_body::gen_trait_fn_body;
64
use hir::{db::HirDatabase, HasAttrs as HirHasAttrs, HirDisplay, InFile, Semantics};
75
use ide_db::{
86
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,
108
};
119
use stdx::format_to;
1210
use syntax::{
@@ -217,43 +215,6 @@ pub fn add_trait_assoc_items_to_impl(
217215
first_item.unwrap()
218216
}
219217

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-
257218
pub(crate) fn vis_offset(node: &SyntaxNode) -> TextSize {
258219
node.children_with_tokens()
259220
.find(|it| !matches!(it.kind(), WHITESPACE | COMMENT | ATTR))
@@ -445,15 +406,6 @@ fn has_any_fn(imp: &ast::Impl, names: &[String]) -> bool {
445406
false
446407
}
447408

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-
457409
/// Find the end of the `impl` block for the given `ast::Impl`.
458410
//
459411
// FIXME: this partially overlaps with `find_struct_impl`

0 commit comments

Comments
 (0)