Simplify
This commit is contained in:
parent
28fcff125a
commit
1e790ea314
@ -76,8 +76,7 @@ pub(crate) fn find_node_at_offset<N: AstNode>(&self) -> Option<N> {
|
||||
find_node_at_offset(self.source_file.syntax(), self.offset())
|
||||
}
|
||||
pub(crate) fn find_node_at_offset_with_descend<N: AstNode>(&self) -> Option<N> {
|
||||
self.sema
|
||||
.find_node_at_offset_with_descend(self.source_file.syntax(), self.frange.range.start())
|
||||
self.sema.find_node_at_offset_with_descend(self.source_file.syntax(), self.offset())
|
||||
}
|
||||
pub(crate) fn covering_element(&self) -> SyntaxElement {
|
||||
find_covering_element(self.source_file.syntax(), self.frange.range)
|
||||
|
@ -93,7 +93,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
|
||||
}
|
||||
|
||||
then_block.syntax().last_child_or_token().filter(|t| t.kind() == R_CURLY)?;
|
||||
let cursor_position = ctx.frange.range.start();
|
||||
let cursor_position = ctx.offset();
|
||||
|
||||
let target = if_expr.syntax().text_range();
|
||||
acc.add(AssistId("convert_to_guarded_return"), "Convert to guarded return", target, |edit| {
|
||||
|
@ -26,7 +26,7 @@
|
||||
pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||
let tree: ast::UseTree = ctx.find_node_at_offset()?;
|
||||
let mut rewriter = SyntaxRewriter::default();
|
||||
let mut offset = ctx.frange.range.start();
|
||||
let mut offset = ctx.offset();
|
||||
|
||||
if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) {
|
||||
let (merged, to_delete) = next_prev()
|
||||
|
@ -45,7 +45,7 @@ enum CursorPos {
|
||||
InExpr(TextSize),
|
||||
InPat(TextSize),
|
||||
}
|
||||
let cursor_pos = ctx.frange.range.start();
|
||||
let cursor_pos = ctx.offset();
|
||||
let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) {
|
||||
CursorPos::InExpr(current_text_range.end() - cursor_pos)
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
||||
if new_tree == use_tree {
|
||||
return None;
|
||||
}
|
||||
let cursor = ctx.frange.range.start();
|
||||
let cursor = ctx.offset();
|
||||
|
||||
let target = colon_colon.text_range();
|
||||
acc.add(AssistId("split_import"), "Split import", target, |edit| {
|
||||
|
Loading…
Reference in New Issue
Block a user