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