mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
rename source_file -> parse
This commit is contained in:
parent
ac757e114e
commit
9457b1f0e6
19 changed files with 41 additions and 47 deletions
|
@ -20,8 +20,8 @@ use crate::{
|
|||
|
||||
#[salsa::query_group(HirDatabaseStorage)]
|
||||
pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
|
||||
#[salsa::invoke(HirFileId::hir_source_file)]
|
||||
fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
||||
#[salsa::invoke(HirFileId::hir_parse)]
|
||||
fn hir_parse(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
||||
|
||||
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
||||
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
||||
|
|
|
@ -86,12 +86,9 @@ impl HirFileId {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn hir_source_file(
|
||||
db: &impl HirDatabase,
|
||||
file_id: HirFileId,
|
||||
) -> TreeArc<SourceFile> {
|
||||
pub(crate) fn hir_parse(db: &impl HirDatabase, file_id: HirFileId) -> TreeArc<SourceFile> {
|
||||
match file_id.0 {
|
||||
HirFileIdRepr::File(file_id) => db.source_file(file_id),
|
||||
HirFileIdRepr::File(file_id) => db.parse(file_id),
|
||||
HirFileIdRepr::Macro(m) => {
|
||||
if let Some(exp) = db.expand_macro_invocation(m) {
|
||||
return exp.file();
|
||||
|
@ -370,7 +367,7 @@ impl SourceFileItems {
|
|||
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
||||
);
|
||||
}
|
||||
pub fn id_of_source_file(&self) -> SourceFileItemId {
|
||||
pub fn id_of_parse(&self) -> SourceFileItemId {
|
||||
let (id, _syntax) = self.arena.iter().next().unwrap();
|
||||
id
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ impl LoweredModule {
|
|||
let id = loc.id(db);
|
||||
let file_id = HirFileId::from(id);
|
||||
//FIXME: expand recursively
|
||||
for item in db.hir_source_file(file_id).items() {
|
||||
for item in db.hir_parse(file_id).items() {
|
||||
self.add_def_id(source_map, db, module, file_id, item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes>
|
|||
}
|
||||
|
||||
pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
|
||||
let source_file = db.hir_source_file(file_id);
|
||||
let source_file = db.hir_parse(file_id);
|
||||
let res = SourceFileItems::new(file_id, &source_file);
|
||||
Arc::new(res)
|
||||
}
|
||||
|
@ -34,10 +34,7 @@ pub(super) fn file_item(
|
|||
) -> TreeArc<SyntaxNode> {
|
||||
match source_item_id.item_id {
|
||||
Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(),
|
||||
None => db
|
||||
.hir_source_file(source_item_id.file_id)
|
||||
.syntax()
|
||||
.to_owned(),
|
||||
None => db.hir_parse(source_item_id.file_id).syntax().to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ pub fn module_from_declaration(
|
|||
|
||||
/// Locates the module by position in the source code.
|
||||
pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> {
|
||||
let file = db.source_file(position.file_id);
|
||||
let file = db.parse(position.file_id);
|
||||
match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) {
|
||||
Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m),
|
||||
_ => module_from_file_id(db, position.file_id.into()),
|
||||
|
@ -95,7 +95,7 @@ fn module_from_source(db: &impl HirDatabase, source: SourceItemId) -> Option<Mod
|
|||
}
|
||||
|
||||
pub fn function_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Function> {
|
||||
let file = db.source_file(position.file_id);
|
||||
let file = db.parse(position.file_id);
|
||||
let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)?;
|
||||
function_from_source(db, position.file_id, fn_def)
|
||||
}
|
||||
|
|
|
@ -547,7 +547,7 @@ fn quux() {
|
|||
|
||||
fn infer(content: &str) -> String {
|
||||
let (db, _, file_id) = MockDatabase::with_single_file(content);
|
||||
let source_file = db.source_file(file_id);
|
||||
let source_file = db.parse(file_id);
|
||||
let mut acc = String::new();
|
||||
for fn_def in source_file
|
||||
.syntax()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue