.any(|(name, _)| name.to_string() == variant_name.to_string())
}
+#[allow(dead_code)]
fn insert_import(
ctx: &AssistContext,
builder: &mut AssistBuilder,
builder: &mut AssistBuilder,
reference: Reference,
source_file: &SourceFile,
- enum_module_def: &ModuleDef,
- variant_hir_name: &Name,
- visited_modules_set: &mut FxHashSet<Module>,
+ _enum_module_def: &ModuleDef,
+ _variant_hir_name: &Name,
+ _visited_modules_set: &mut FxHashSet<Module>,
) -> Option<()> {
let path_expr: ast::PathExpr = find_node_at_offset::<ast::PathExpr>(
source_file.syntax(),
let call = path_expr.syntax().parent().and_then(ast::CallExpr::cast)?;
let list = call.arg_list()?;
let segment = path_expr.path()?.segment()?;
- let module = ctx.sema.scope(&path_expr.syntax()).module()?;
+ let _module = ctx.sema.scope(&path_expr.syntax()).module()?;
let list_range = list.syntax().text_range();
let inside_list_range = TextRange::new(
list_range.start().checked_add(TextSize::from(1))?,
+//! Handle syntactic aspects of inserting a new `use`.
use std::iter::{self, successors};
use algo::skip_trivia_token;
ast::{self, make, AstNode},
Direction, InsertPosition, SyntaxElement, SyntaxNode, T,
};
-
use test_utils::mark;
#[derive(Debug)]
fn first_insert_pos(&self) -> (InsertPosition<SyntaxElement>, AddBlankLine) {
match self {
ImportScope::File(_) => (InsertPosition::First, AddBlankLine::AfterTwice),
- // don't insert the impotrs before the item lists curly brace
+ // don't insert the imports before the item list's opening curly brace
ImportScope::Module(item_list) => item_list
.l_curly_token()
.map(|b| (InsertPosition::After(b.into()), AddBlankLine::Around))
}
fn insert_pos_after_inner_attribute(&self) -> (InsertPosition<SyntaxElement>, AddBlankLine) {
- // check if the scope has a inner attributes, we dont want to insert in front of it
+ // check if the scope has inner attributes, we dont want to insert in front of them
match self
.as_syntax_node()
.children()
}
if let ident_level @ 1..=usize::MAX = scope.indent_level().0 as usize {
- // TODO: this alone doesnt properly re-align all cases
+ // FIXME: this alone doesnt properly re-align all cases
buf.push(make::tokens::whitespace(&" ".repeat(4 * ident_level)).into());
}
buf.push(use_item.syntax().clone().into());
#[test]
fn insert_after_inner_attr() {
- // empty files will get two trailing newlines
- // this is due to the test case insert_no_imports above
check_full(
"foo::bar",
r"#![allow(unused_imports)]",
#[test]
fn insert_after_inner_attr2() {
- // empty files will get two trailing newlines
- // this is due to the test case insert_no_imports above
check_full(
"foo::bar",
r"#![allow(unused_imports)]
)
}
+ #[test]
+ fn merge_groups_skip_pub_crate() {
+ check_full(
+ "std::io",
+ r"pub(crate) use std::fmt::{Result, Display};",
+ r"pub(crate) use std::fmt::{Result, Display};
+use std::io;",
+ )
+ }
+
#[test]
#[ignore] // FIXME: Support this
fn split_out_merge() {