mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
add DefId
This commit is contained in:
parent
8086107b6a
commit
c54b51fded
2 changed files with 32 additions and 1 deletions
|
@ -7,6 +7,7 @@ use ra_syntax::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
loc2id::DefId,
|
||||||
descriptors::module::ModuleId,
|
descriptors::module::ModuleId,
|
||||||
syntax_ptr::LocalSyntaxPtr,
|
syntax_ptr::LocalSyntaxPtr,
|
||||||
};
|
};
|
||||||
|
@ -45,7 +46,8 @@ struct ItemMap {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct ModuleItems {
|
struct ModuleItems {
|
||||||
items: FxHashMap<SmolStr, PerNs<ModuleItem>>,
|
items: FxHashMap<SmolStr, PerNs<DefId>>,
|
||||||
|
import_resolutions: FxHashMap<LocalSyntaxPtr, DefId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -197,3 +199,14 @@ impl ModuleItem {
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Resolver {
|
||||||
|
input: FxHashMap<ModuleId, InputModuleItems>,
|
||||||
|
result: ModuleItems,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Resolver {
|
||||||
|
fn resolve(&mut self){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,9 @@ use std::{
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
descriptors::module::ModuleId,
|
||||||
syntax_ptr::SyntaxPtr,
|
syntax_ptr::SyntaxPtr,
|
||||||
|
input::SourceRootId,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// There are two principle ways to refer to things:
|
/// There are two principle ways to refer to things:
|
||||||
|
@ -89,6 +91,21 @@ macro_rules! impl_numeric_id {
|
||||||
pub(crate) struct FnId(u32);
|
pub(crate) struct FnId(u32);
|
||||||
impl_numeric_id!(FnId);
|
impl_numeric_id!(FnId);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub(crate) struct DefId(u32);
|
||||||
|
impl_numeric_id!(DefId);
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
enum DefLoc {
|
||||||
|
Module {
|
||||||
|
id: ModuleId,
|
||||||
|
source_root: SourceRootId,
|
||||||
|
},
|
||||||
|
Item {
|
||||||
|
ptr: SyntaxPtr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) trait IdDatabase: salsa::Database {
|
pub(crate) trait IdDatabase: salsa::Database {
|
||||||
fn id_maps(&self) -> &IdMaps;
|
fn id_maps(&self) -> &IdMaps;
|
||||||
}
|
}
|
||||||
|
@ -110,4 +127,5 @@ impl IdMaps {
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct IdMapsInner {
|
struct IdMapsInner {
|
||||||
fns: Mutex<Loc2IdMap<SyntaxPtr, FnId>>,
|
fns: Mutex<Loc2IdMap<SyntaxPtr, FnId>>,
|
||||||
|
defs: Mutex<Loc2IdMap<DefLoc, DefId>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue