blob: b4d8da1e6511aa6192e262c71d76b3238893bd9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use std::sync::Arc;
use ra_syntax::{
SyntaxNode, TreeArc,
};
use crate::{
SourceFileItems, SourceItemId, HirFileId,
PersistentHirDatabase,
};
pub(super) fn file_items(
db: &impl PersistentHirDatabase,
file_id: HirFileId,
) -> Arc<SourceFileItems> {
let source_file = db.hir_parse(file_id);
let res = SourceFileItems::new(file_id, &source_file);
Arc::new(res)
}
pub(super) fn file_item(
db: &impl PersistentHirDatabase,
source_item_id: SourceItemId,
) -> TreeArc<SyntaxNode> {
let source_file = db.hir_parse(source_item_id.file_id);
db.file_items(source_item_id.file_id)[source_item_id.item_id]
.to_node(&source_file)
.to_owned()
}
|