From f8b36bbc3b968754b71844d942286e81415627b8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 7 Nov 2018 18:32:33 +0300 Subject: Rename File -> SourceFileNode --- crates/ra_editor/src/code_actions.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'crates/ra_editor/src/code_actions.rs') diff --git a/crates/ra_editor/src/code_actions.rs b/crates/ra_editor/src/code_actions.rs index ef6df0d53..0139b19d3 100644 --- a/crates/ra_editor/src/code_actions.rs +++ b/crates/ra_editor/src/code_actions.rs @@ -3,7 +3,7 @@ use join_to_string::join; use ra_syntax::{ algo::{find_covering_node, find_leaf_at_offset}, ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, - Direction, File, + Direction, SourceFileNode, SyntaxKind::{COMMA, WHITESPACE}, SyntaxNodeRef, TextRange, TextUnit, }; @@ -16,7 +16,10 @@ pub struct LocalEdit { pub cursor_position: Option, } -pub fn flip_comma<'a>(file: &'a File, offset: TextUnit) -> Option LocalEdit + 'a> { +pub fn flip_comma<'a>( + file: &'a SourceFileNode, + offset: TextUnit, +) -> Option LocalEdit + 'a> { let syntax = file.syntax(); let comma = find_leaf_at_offset(syntax, offset).find(|leaf| leaf.kind() == COMMA)?; @@ -33,7 +36,10 @@ pub fn flip_comma<'a>(file: &'a File, offset: TextUnit) -> Option(file: &'a File, offset: TextUnit) -> Option LocalEdit + 'a> { +pub fn add_derive<'a>( + file: &'a SourceFileNode, + offset: TextUnit, +) -> Option LocalEdit + 'a> { let nominal = find_node_at_offset::(file.syntax(), offset)?; Some(move || { let derive_attr = nominal @@ -58,7 +64,10 @@ pub fn add_derive<'a>(file: &'a File, offset: TextUnit) -> Option(file: &'a File, offset: TextUnit) -> Option LocalEdit + 'a> { +pub fn add_impl<'a>( + file: &'a SourceFileNode, + offset: TextUnit, +) -> Option LocalEdit + 'a> { let nominal = find_node_at_offset::(file.syntax(), offset)?; let name = nominal.name()?; @@ -98,7 +107,7 @@ pub fn add_impl<'a>(file: &'a File, offset: TextUnit) -> Option } pub fn introduce_variable<'a>( - file: &'a File, + file: &'a SourceFileNode, range: TextRange, ) -> Option LocalEdit + 'a> { let node = find_covering_node(file.syntax(), range); -- cgit v1.2.3