mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 04:04:06 +00:00
rename
This commit is contained in:
parent
6c2ba945ed
commit
b6809b6695
@ -29,7 +29,7 @@ pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<
|
||||
}
|
||||
// Infer type
|
||||
let db = ctx.db;
|
||||
let analyzer = hir::SourceAnalyser::new(db, ctx.frange.file_id, stmt.syntax());
|
||||
let analyzer = hir::SourceAnalyzer::new(db, ctx.frange.file_id, stmt.syntax());
|
||||
let ty = analyzer.type_of(db, expr)?;
|
||||
// Assist not applicable if the type is unknown
|
||||
if is_unknown(&ty) {
|
||||
|
@ -45,7 +45,7 @@ fn add_missing_impl_members_inner(
|
||||
let trait_def = {
|
||||
let file_id = ctx.frange.file_id;
|
||||
let position = FilePosition { file_id, offset: impl_node.syntax().range().start() };
|
||||
let analyser = hir::SourceAnalyser::new(ctx.db, position.file_id, impl_node.syntax());
|
||||
let analyser = hir::SourceAnalyzer::new(ctx.db, position.file_id, impl_node.syntax());
|
||||
|
||||
resolve_target_trait_def(ctx.db, &analyser, impl_node)?
|
||||
};
|
||||
@ -121,13 +121,13 @@ fn add_missing_impl_members_inner(
|
||||
/// implemented) to a `ast::TraitDef`.
|
||||
fn resolve_target_trait_def(
|
||||
db: &impl HirDatabase,
|
||||
binder: &hir::SourceAnalyser,
|
||||
analyzer: &hir::SourceAnalyzer,
|
||||
impl_block: &ast::ImplBlock,
|
||||
) -> Option<TreeArc<ast::TraitDef>> {
|
||||
let ast_path =
|
||||
impl_block.target_trait().map(AstNode::syntax).and_then(ast::PathType::cast)?.path()?;
|
||||
|
||||
match binder.resolve_path(db, &ast_path) {
|
||||
match analyzer.resolve_path(db, &ast_path) {
|
||||
Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def.source(db).1),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As
|
||||
}
|
||||
|
||||
let expr = match_expr.expr()?;
|
||||
let analyzer = hir::SourceAnalyser::new(ctx.db, ctx.frange.file_id, expr.syntax());
|
||||
let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax());
|
||||
let match_expr_ty = analyzer.type_of(ctx.db, expr)?;
|
||||
let enum_def = match_expr_ty.autoderef(ctx.db).find_map(|ty| match ty.as_adt() {
|
||||
Some((AdtDef::Enum(e), _)) => Some(e),
|
||||
|
@ -51,7 +51,7 @@ where
|
||||
}
|
||||
|
||||
fn evaluate_struct_def_fields(&mut self) -> Option<()> {
|
||||
let analyzer = hir::SourceAnalyser::new(
|
||||
let analyzer = hir::SourceAnalyzer::new(
|
||||
self.ctx.db,
|
||||
self.ctx.frange.file_id,
|
||||
self.struct_lit.syntax(),
|
||||
|
@ -66,7 +66,7 @@ pub use self::{
|
||||
adt::AdtDef,
|
||||
expr::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax},
|
||||
resolve::{Resolver, Resolution},
|
||||
source_binder::{SourceAnalyser, PathResolution},
|
||||
source_binder::{SourceAnalyzer, PathResolution},
|
||||
};
|
||||
|
||||
pub use self::code_model_api::{
|
||||
|
@ -261,9 +261,9 @@ fn try_get_resolver_for_node(
|
||||
}
|
||||
}
|
||||
|
||||
// Name is bad, don't use inside HIR
|
||||
/// `SourceAnalyzer`
|
||||
#[derive(Debug)]
|
||||
pub struct SourceAnalyser {
|
||||
pub struct SourceAnalyzer {
|
||||
resolver: Resolver,
|
||||
body_source_map: Option<Arc<crate::expr::BodySourceMap>>,
|
||||
infer: Option<Arc<crate::ty::InferenceResult>>,
|
||||
@ -281,18 +281,18 @@ pub enum PathResolution {
|
||||
AssocItem(crate::ImplItem),
|
||||
}
|
||||
|
||||
impl SourceAnalyser {
|
||||
pub fn new(db: &impl HirDatabase, file_id: FileId, node: &SyntaxNode) -> SourceAnalyser {
|
||||
impl SourceAnalyzer {
|
||||
pub fn new(db: &impl HirDatabase, file_id: FileId, node: &SyntaxNode) -> SourceAnalyzer {
|
||||
let resolver = resolver_for_node(db, file_id, node);
|
||||
let function = function_from_child_node(db, file_id, node);
|
||||
if let Some(function) = function {
|
||||
SourceAnalyser {
|
||||
SourceAnalyzer {
|
||||
resolver,
|
||||
body_source_map: Some(function.body_source_map(db)),
|
||||
infer: Some(function.infer(db)),
|
||||
}
|
||||
} else {
|
||||
SourceAnalyser { resolver, body_source_map: None, infer: None }
|
||||
SourceAnalyzer { resolver, body_source_map: None, infer: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
|
||||
let calling_node = FnCallNode::with_node(syntax, position.offset)?;
|
||||
let name_ref = calling_node.name_ref()?;
|
||||
|
||||
let analyser = hir::SourceAnalyser::new(db, position.file_id, name_ref.syntax());
|
||||
let analyser = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax());
|
||||
let function = match calling_node {
|
||||
FnCallNode::CallExpr(expr) => {
|
||||
//FIXME: apply subst
|
||||
|
@ -14,7 +14,7 @@ use crate::{db, FilePosition};
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct CompletionContext<'a> {
|
||||
pub(super) db: &'a db::RootDatabase,
|
||||
pub(super) analyzer: hir::SourceAnalyser,
|
||||
pub(super) analyzer: hir::SourceAnalyzer,
|
||||
pub(super) offset: TextUnit,
|
||||
pub(super) token: SyntaxToken<'a>,
|
||||
pub(super) resolver: Resolver,
|
||||
@ -50,7 +50,7 @@ impl<'a> CompletionContext<'a> {
|
||||
let resolver = source_binder::resolver_for_position(db, position);
|
||||
let module = source_binder::module_from_position(db, position);
|
||||
let token = find_token_at_offset(original_file.syntax(), position.offset).left_biased()?;
|
||||
let analyzer = hir::SourceAnalyser::new(db, position.file_id, token.parent());
|
||||
let analyzer = hir::SourceAnalyzer::new(db, position.file_id, token.parent());
|
||||
let mut ctx = CompletionContext {
|
||||
db,
|
||||
analyzer,
|
||||
|
@ -47,7 +47,7 @@ pub(crate) fn reference_definition(
|
||||
) -> ReferenceResult {
|
||||
use self::ReferenceResult::*;
|
||||
|
||||
let analyzer = hir::SourceAnalyser::new(db, file_id, name_ref.syntax());
|
||||
let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax());
|
||||
|
||||
// Special cases:
|
||||
|
||||
|
@ -132,7 +132,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
|
||||
.ancestors()
|
||||
.take_while(|it| it.range() == leaf_node.range())
|
||||
.find(|&it| ast::Expr::cast(it).is_some() || ast::Pat::cast(it).is_some())?;
|
||||
let analyzer = hir::SourceAnalyser::new(db, frange.file_id, node);
|
||||
let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, node);
|
||||
let ty = if let Some(ty) = ast::Expr::cast(node).and_then(|e| analyzer.type_of(db, e)) {
|
||||
ty
|
||||
} else if let Some(ty) = ast::Pat::cast(node).and_then(|p| analyzer.type_of_pat(db, p)) {
|
||||
|
Loading…
Reference in New Issue
Block a user