From 191a6ba330bd47fc3b9cc05d59b2d456b471eb89 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 19 Jul 2019 19:05:34 +0300 Subject: convenience api --- crates/ra_ide_api/src/extend_selection.rs | 4 ++-- crates/ra_ide_api/src/join_lines.rs | 2 +- crates/ra_ide_api/src/syntax_highlighting.rs | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 8c49960f5..292f61f4a 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs @@ -156,7 +156,7 @@ fn extend_list_item(node: &SyntaxNode) -> Option { SyntaxElement::Token(it) => is_single_line_ws(it), }) .next() - .and_then(|it| it.as_token().cloned()) + .and_then(|it| it.into_token()) .filter(|node| node.kind() == T![,]) } @@ -167,7 +167,7 @@ fn extend_list_item(node: &SyntaxNode) -> Option { // Include any following whitespace when comma if after list item. let final_node = comma_node .next_sibling_or_token() - .and_then(|it| it.as_token().cloned()) + .and_then(|it| it.into_token()) .filter(|node| is_single_line_ws(node)) .unwrap_or(comma_node); diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs index 50bcfb5b7..9b81ad9e4 100644 --- a/crates/ra_ide_api/src/join_lines.rs +++ b/crates/ra_ide_api/src/join_lines.rs @@ -27,7 +27,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { SyntaxElement::Token(token) => token.parent(), }; let mut edit = TextEditBuilder::default(); - for token in node.descendants_with_tokens().filter_map(|it| it.as_token().cloned()) { + for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { let range = match range.intersection(&token.range()) { Some(range) => range, None => continue, diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 0e5253025..477827fa7 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs @@ -237,8 +237,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo let mut buf = String::new(); buf.push_str(&STYLE); buf.push_str("
");
-    let tokens =
-        parse.tree().syntax().descendants_with_tokens().filter_map(|it| it.as_token().cloned());
+    let tokens = parse.tree().syntax().descendants_with_tokens().filter_map(|it| it.into_token());
     for token in tokens {
         could_intersect.retain(|it| token.range().start() <= it.range.end());
         while let Some(r) = ranges.get(frontier) {
-- 
cgit v1.2.3