mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Simplify
This commit is contained in:
parent
9cb13b6efb
commit
634d588fd7
13 changed files with 137 additions and 176 deletions
|
@ -128,6 +128,7 @@ pub use {
|
|||
hygiene::{marks_rev, SyntaxContextExt},
|
||||
name::{known, Name},
|
||||
tt, ExpandResult, HirFileId, HirFileIdExt, InFile, InMacroFile, InRealFile, MacroFileId,
|
||||
MacroFileIdExt,
|
||||
},
|
||||
hir_ty::{
|
||||
display::{ClosureStyle, HirDisplay, HirDisplayError, HirWrite},
|
||||
|
@ -607,7 +608,7 @@ impl Module {
|
|||
let tree = loc.id.item_tree(db.upcast());
|
||||
let node = &tree[loc.id.value];
|
||||
let file_id = loc.id.file_id();
|
||||
if file_id.is_builtin_derive(db.upcast()) {
|
||||
if file_id.macro_file().map_or(false, |it| it.is_builtin_derive(db.upcast())) {
|
||||
// these expansion come from us, diagnosing them is a waste of resources
|
||||
// FIXME: Once we diagnose the inputs to builtin derives, we should at least extract those diagnostics somehow
|
||||
continue;
|
||||
|
|
|
@ -20,8 +20,8 @@ use hir_def::{
|
|||
AsMacroCall, DefWithBodyId, FieldId, FunctionId, MacroId, TraitId, VariantId,
|
||||
};
|
||||
use hir_expand::{
|
||||
db::ExpandDatabase, files::InRealFile, name::AsName, ExpansionInfo, HirFileIdExt, MacroCallId,
|
||||
MacroFileId, MacroFileIdExt,
|
||||
db::ExpandDatabase, files::InRealFile, name::AsName, ExpansionInfo, MacroCallId, MacroFileId,
|
||||
MacroFileIdExt,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
@ -865,7 +865,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
Some(parent) => Some(InFile::new(file_id, parent)),
|
||||
None => {
|
||||
self.cache(value.clone(), file_id);
|
||||
file_id.call_node(db)
|
||||
Some(file_id.macro_file()?.call_node(db))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -29,7 +29,7 @@ use hir_expand::{
|
|||
mod_path::path,
|
||||
name,
|
||||
name::{AsName, Name},
|
||||
HirFileId, HirFileIdExt, InFile, MacroFileId, MacroFileIdExt,
|
||||
HirFileId, InFile, MacroFileId, MacroFileIdExt,
|
||||
};
|
||||
use hir_ty::{
|
||||
diagnostics::{
|
||||
|
@ -939,11 +939,12 @@ fn scope_for_offset(
|
|||
}
|
||||
|
||||
// FIXME handle attribute expansion
|
||||
let source = iter::successors(file_id.call_node(db.upcast()), |it| {
|
||||
it.file_id.call_node(db.upcast())
|
||||
})
|
||||
.find(|it| it.file_id == from_file)
|
||||
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
|
||||
let source =
|
||||
iter::successors(file_id.macro_file().map(|it| it.call_node(db.upcast())), |it| {
|
||||
Some(it.file_id.macro_file()?.call_node(db.upcast()))
|
||||
})
|
||||
.find(|it| it.file_id == from_file)
|
||||
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
|
||||
Some((source.value.text_range(), scope))
|
||||
})
|
||||
.filter(|(expr_range, _scope)| expr_range.start() <= offset && offset <= expr_range.end())
|
||||
|
|
|
@ -49,10 +49,6 @@ impl DeclarationLocation {
|
|||
let node = resolve_node(db, self.hir_file_id, &self.ptr);
|
||||
node.as_ref().original_file_range(db.upcast())
|
||||
}
|
||||
|
||||
pub fn original_name_range(&self, db: &dyn HirDatabase) -> FileRange {
|
||||
InFile::new(self.hir_file_id, self.name_ptr.text_range()).original_file_range(db.upcast())
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_node(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue