|
1 | 1 | //! This module contains functions to suggest names for expressions, functions and other items
|
2 | 2 |
|
3 | 3 | use hir::Semantics;
|
4 |
| -use ide_db::{FxHashSet, RootDatabase}; |
5 | 4 | use itertools::Itertools;
|
| 5 | +use rustc_hash::FxHashSet; |
6 | 6 | use stdx::to_lower_snake_case;
|
7 | 7 | use syntax::{
|
8 | 8 | ast::{self, HasName},
|
9 | 9 | match_ast, AstNode, Edition, SmolStr,
|
10 | 10 | };
|
11 | 11 |
|
| 12 | +use crate::RootDatabase; |
| 13 | + |
12 | 14 | /// Trait names, that will be ignored when in `impl Trait` and `dyn Trait`
|
13 | 15 | const USELESS_TRAITS: &[&str] = &["Send", "Sync", "Copy", "Clone", "Eq", "PartialEq"];
|
14 | 16 |
|
@@ -66,10 +68,7 @@ const USELESS_METHODS: &[&str] = &[
|
66 | 68 | /// The function checks if the name conflicts with existing generic parameters.
|
67 | 69 | /// If so, it will try to resolve the conflict by adding a number suffix, e.g.
|
68 | 70 | /// `T`, `T0`, `T1`, ...
|
69 |
| -pub(crate) fn for_unique_generic_name( |
70 |
| - name: &str, |
71 |
| - existing_params: &ast::GenericParamList, |
72 |
| -) -> SmolStr { |
| 71 | +pub fn for_unique_generic_name(name: &str, existing_params: &ast::GenericParamList) -> SmolStr { |
73 | 72 | let param_names = existing_params
|
74 | 73 | .generic_params()
|
75 | 74 | .map(|param| match param {
|
@@ -101,7 +100,7 @@ pub(crate) fn for_unique_generic_name(
|
101 | 100 | ///
|
102 | 101 | /// If the name conflicts with existing generic parameters, it will try to
|
103 | 102 | /// resolve the conflict with `for_unique_generic_name`.
|
104 |
| -pub(crate) fn for_impl_trait_as_generic( |
| 103 | +pub fn for_impl_trait_as_generic( |
105 | 104 | ty: &ast::ImplTraitType,
|
106 | 105 | existing_params: &ast::GenericParamList,
|
107 | 106 | ) -> SmolStr {
|
@@ -132,7 +131,7 @@ pub(crate) fn for_impl_trait_as_generic(
|
132 | 131 | ///
|
133 | 132 | /// Currently it sticks to the first name found.
|
134 | 133 | // FIXME: Microoptimize and return a `SmolStr` here.
|
135 |
| -pub(crate) fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String { |
| 134 | +pub fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) -> String { |
136 | 135 | // `from_param` does not benefit from stripping
|
137 | 136 | // it need the largest context possible
|
138 | 137 | // so we check firstmost
|
@@ -184,7 +183,7 @@ fn normalize(name: &str) -> Option<String> {
|
184 | 183 |
|
185 | 184 | fn is_valid_name(name: &str) -> bool {
|
186 | 185 | matches!(
|
187 |
| - ide_db::syntax_helpers::LexedStr::single_token(syntax::Edition::CURRENT_FIXME, name), |
| 186 | + super::LexedStr::single_token(syntax::Edition::CURRENT_FIXME, name), |
188 | 187 | Some((syntax::SyntaxKind::IDENT, _error))
|
189 | 188 | )
|
190 | 189 | }
|
|
0 commit comments