mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
use really correct resolver for expressions
This commit is contained in:
parent
20013de2ab
commit
0fd93bc14a
9 changed files with 27 additions and 13 deletions
|
@ -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 analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax());
|
||||
let analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax(), None);
|
||||
let function = match calling_node {
|
||||
FnCallNode::CallExpr(expr) => {
|
||||
//FIXME: apply subst
|
||||
|
|
|
@ -48,7 +48,8 @@ impl<'a> CompletionContext<'a> {
|
|||
) -> Option<CompletionContext<'a>> {
|
||||
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::SourceAnalyzer::new(db, position.file_id, token.parent());
|
||||
let analyzer =
|
||||
hir::SourceAnalyzer::new(db, position.file_id, token.parent(), Some(position.offset));
|
||||
let mut ctx = CompletionContext {
|
||||
db,
|
||||
analyzer,
|
||||
|
|
|
@ -47,7 +47,7 @@ pub(crate) fn reference_definition(
|
|||
) -> ReferenceResult {
|
||||
use self::ReferenceResult::*;
|
||||
|
||||
let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax());
|
||||
let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None);
|
||||
|
||||
// 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::SourceAnalyzer::new(db, frange.file_id, node);
|
||||
let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, node, None);
|
||||
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…
Add table
Add a link
Reference in a new issue