mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
rename
This commit is contained in:
parent
5e7f4202cf
commit
00df339c41
6 changed files with 26 additions and 26 deletions
|
@ -127,7 +127,7 @@ salsa::database_storage! {
|
||||||
impl hir::db::HirDatabase {
|
impl hir::db::HirDatabase {
|
||||||
fn module_tree() for hir::db::ModuleTreeQuery;
|
fn module_tree() for hir::db::ModuleTreeQuery;
|
||||||
fn fn_scopes() for hir::db::FnScopesQuery;
|
fn fn_scopes() for hir::db::FnScopesQuery;
|
||||||
fn _file_items() for hir::db::FileItemsQuery;
|
fn _file_items() for hir::db::SourceFileItemsQuery;
|
||||||
fn _file_item() for hir::db::FileItemQuery;
|
fn _file_item() for hir::db::FileItemQuery;
|
||||||
fn _input_module_items() for hir::db::InputModuleItemsQuery;
|
fn _input_module_items() for hir::db::InputModuleItemsQuery;
|
||||||
fn _item_map() for hir::db::ItemMapQuery;
|
fn _item_map() for hir::db::ItemMapQuery;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ra_syntax::{
|
||||||
use crate::{
|
use crate::{
|
||||||
FileId,
|
FileId,
|
||||||
db::SyntaxDatabase,
|
db::SyntaxDatabase,
|
||||||
hir::{FileItems, FileItemId},
|
hir::{SourceFileItems, SourceFileItemId},
|
||||||
hir::query_definitions,
|
hir::query_definitions,
|
||||||
hir::function::{FnId, FnScopes},
|
hir::function::{FnId, FnScopes},
|
||||||
hir::module::{
|
hir::module::{
|
||||||
|
@ -33,13 +33,13 @@ pub(crate) trait HirDatabase: SyntaxDatabase {
|
||||||
use fn query_definitions::fn_syntax;
|
use fn query_definitions::fn_syntax;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_items(file_id: FileId) -> Arc<FileItems> {
|
fn file_items(file_id: FileId) -> Arc<SourceFileItems> {
|
||||||
type FileItemsQuery;
|
type SourceFileItemsQuery;
|
||||||
storage dependencies;
|
storage dependencies;
|
||||||
use fn query_definitions::file_items;
|
use fn query_definitions::file_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_item(file_id: FileId, file_item_id: FileItemId) -> SyntaxNode {
|
fn file_item(file_id: FileId, file_item_id: SourceFileItemId) -> SyntaxNode {
|
||||||
type FileItemQuery;
|
type FileItemQuery;
|
||||||
storage dependencies;
|
storage dependencies;
|
||||||
use fn query_definitions::file_item;
|
use fn query_definitions::file_item;
|
||||||
|
|
|
@ -51,19 +51,19 @@ impl DefId {
|
||||||
|
|
||||||
/// Identifier of item within a specific file. This is stable over reparses, so
|
/// Identifier of item within a specific file. This is stable over reparses, so
|
||||||
/// it's OK to use it as a salsa key/value.
|
/// it's OK to use it as a salsa key/value.
|
||||||
pub(crate) type FileItemId = Id<SyntaxNode>;
|
pub(crate) type SourceFileItemId = Id<SyntaxNode>;
|
||||||
|
|
||||||
/// Maps item's `SyntaxNode`s to `FileItemId` and back.
|
/// Maps item's `SyntaxNode`s to `SourceFileItemId` and back.
|
||||||
#[derive(Debug, PartialEq, Eq, Default)]
|
#[derive(Debug, PartialEq, Eq, Default)]
|
||||||
pub(crate) struct FileItems {
|
pub(crate) struct SourceFileItems {
|
||||||
arena: Arena<SyntaxNode>,
|
arena: Arena<SyntaxNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileItems {
|
impl SourceFileItems {
|
||||||
fn alloc(&mut self, item: SyntaxNode) -> FileItemId {
|
fn alloc(&mut self, item: SyntaxNode) -> SourceFileItemId {
|
||||||
self.arena.alloc(item)
|
self.arena.alloc(item)
|
||||||
}
|
}
|
||||||
fn id_of(&self, item: SyntaxNodeRef) -> FileItemId {
|
fn id_of(&self, item: SyntaxNodeRef) -> SourceFileItemId {
|
||||||
let (id, _item) = self
|
let (id, _item) = self
|
||||||
.arena
|
.arena
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -73,9 +73,9 @@ impl FileItems {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index<FileItemId> for FileItems {
|
impl Index<SourceFileItemId> for SourceFileItems {
|
||||||
type Output = SyntaxNode;
|
type Output = SyntaxNode;
|
||||||
fn index(&self, idx: FileItemId) -> &SyntaxNode {
|
fn index(&self, idx: SourceFileItemId) -> &SyntaxNode {
|
||||||
&self.arena[idx]
|
&self.arena[idx]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::{
|
||||||
Cancelable, FileId,
|
Cancelable, FileId,
|
||||||
loc2id::{DefId, DefLoc},
|
loc2id::{DefId, DefLoc},
|
||||||
hir::{
|
hir::{
|
||||||
FileItemId, FileItems,
|
SourceFileItemId, SourceFileItems,
|
||||||
Path, PathKind,
|
Path, PathKind,
|
||||||
HirDatabase,
|
HirDatabase,
|
||||||
module::{ModuleId, ModuleTree},
|
module::{ModuleId, ModuleTree},
|
||||||
|
@ -73,7 +73,7 @@ pub(crate) struct InputModuleItems {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
struct ModuleItem {
|
struct ModuleItem {
|
||||||
id: FileItemId,
|
id: SourceFileItemId,
|
||||||
name: SmolStr,
|
name: SmolStr,
|
||||||
kind: SyntaxKind,
|
kind: SyntaxKind,
|
||||||
vis: Vis,
|
vis: Vis,
|
||||||
|
@ -93,7 +93,7 @@ struct Import {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub(crate) struct NamedImport {
|
pub(crate) struct NamedImport {
|
||||||
file_item_id: FileItemId,
|
file_item_id: SourceFileItemId,
|
||||||
relative_range: TextRange,
|
relative_range: TextRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ pub(crate) struct Resolution {
|
||||||
|
|
||||||
impl InputModuleItems {
|
impl InputModuleItems {
|
||||||
pub(in crate::hir) fn new<'a>(
|
pub(in crate::hir) fn new<'a>(
|
||||||
file_items: &FileItems,
|
file_items: &SourceFileItems,
|
||||||
items: impl Iterator<Item = ast::ModuleItem<'a>>,
|
items: impl Iterator<Item = ast::ModuleItem<'a>>,
|
||||||
) -> InputModuleItems {
|
) -> InputModuleItems {
|
||||||
let mut res = InputModuleItems::default();
|
let mut res = InputModuleItems::default();
|
||||||
|
@ -145,7 +145,7 @@ impl InputModuleItems {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_item(&mut self, file_items: &FileItems, item: ast::ModuleItem) -> Option<()> {
|
fn add_item(&mut self, file_items: &SourceFileItems, item: ast::ModuleItem) -> Option<()> {
|
||||||
match item {
|
match item {
|
||||||
ast::ModuleItem::StructDef(it) => self.items.push(ModuleItem::new(file_items, it)?),
|
ast::ModuleItem::StructDef(it) => self.items.push(ModuleItem::new(file_items, it)?),
|
||||||
ast::ModuleItem::EnumDef(it) => self.items.push(ModuleItem::new(file_items, it)?),
|
ast::ModuleItem::EnumDef(it) => self.items.push(ModuleItem::new(file_items, it)?),
|
||||||
|
@ -166,7 +166,7 @@ impl InputModuleItems {
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_use_item(&mut self, file_items: &FileItems, item: ast::UseItem) {
|
fn add_use_item(&mut self, file_items: &SourceFileItems, item: ast::UseItem) {
|
||||||
let file_item_id = file_items.id_of(item.syntax());
|
let file_item_id = file_items.id_of(item.syntax());
|
||||||
let start_offset = item.syntax().range().start();
|
let start_offset = item.syntax().range().start();
|
||||||
Path::expand_use_item(item, |path, range| {
|
Path::expand_use_item(item, |path, range| {
|
||||||
|
@ -183,7 +183,7 @@ impl InputModuleItems {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModuleItem {
|
impl ModuleItem {
|
||||||
fn new<'a>(file_items: &FileItems, item: impl ast::NameOwner<'a>) -> Option<ModuleItem> {
|
fn new<'a>(file_items: &SourceFileItems, item: impl ast::NameOwner<'a>) -> Option<ModuleItem> {
|
||||||
let name = item.name()?.text();
|
let name = item.name()?.text();
|
||||||
let kind = item.syntax().kind();
|
let kind = item.syntax().kind();
|
||||||
let vis = Vis::Other;
|
let vis = Vis::Other;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ra_syntax::{
|
||||||
use crate::{
|
use crate::{
|
||||||
FileId, Cancelable,
|
FileId, Cancelable,
|
||||||
hir::{
|
hir::{
|
||||||
FileItems, FileItemId,
|
SourceFileItems, SourceFileItemId,
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
function::{FnId, FnScopes},
|
function::{FnId, FnScopes},
|
||||||
module::{
|
module::{
|
||||||
|
@ -37,10 +37,10 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
|
||||||
Arc::new(res)
|
Arc::new(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<FileItems> {
|
pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> {
|
||||||
let source_file = db.file_syntax(file_id);
|
let source_file = db.file_syntax(file_id);
|
||||||
let source_file = source_file.borrowed();
|
let source_file = source_file.borrowed();
|
||||||
let mut res = FileItems::default();
|
let mut res = SourceFileItems::default();
|
||||||
source_file
|
source_file
|
||||||
.syntax()
|
.syntax()
|
||||||
.descendants()
|
.descendants()
|
||||||
|
@ -55,7 +55,7 @@ pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<FileItem
|
||||||
pub(super) fn file_item(
|
pub(super) fn file_item(
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
file_item_id: FileItemId,
|
file_item_id: SourceFileItemId,
|
||||||
) -> SyntaxNode {
|
) -> SyntaxNode {
|
||||||
db.file_items(file_id)[file_item_id].clone()
|
db.file_items(file_id)[file_item_id].clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
FileId,
|
FileId,
|
||||||
hir::{FileItemId, ModuleId},
|
hir::{SourceFileItemId, ModuleId},
|
||||||
syntax_ptr::SyntaxPtr,
|
syntax_ptr::SyntaxPtr,
|
||||||
input::SourceRootId,
|
input::SourceRootId,
|
||||||
};
|
};
|
||||||
|
@ -104,7 +104,7 @@ pub(crate) enum DefLoc {
|
||||||
},
|
},
|
||||||
Item {
|
Item {
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
id: FileItemId,
|
id: SourceFileItemId,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue