mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
Fix typo defenition -> definition
This commit is contained in:
parent
46f74e33ca
commit
f8261d611a
@ -75,8 +75,8 @@ impl Module {
|
||||
}
|
||||
|
||||
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
|
||||
pub fn defenition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> {
|
||||
self.defenition_source_impl(db)
|
||||
pub fn definition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> {
|
||||
self.definition_source_impl(db)
|
||||
}
|
||||
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
|
||||
/// `None` for the crate root.
|
||||
|
@ -37,7 +37,7 @@ impl Module {
|
||||
Ok(Some(link.name(&module_tree).clone()))
|
||||
}
|
||||
|
||||
pub fn defenition_source_impl(
|
||||
pub fn definition_source_impl(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<(FileId, ModuleSource)> {
|
||||
|
@ -150,7 +150,7 @@ impl ModuleImplBlocks {
|
||||
}
|
||||
|
||||
fn collect(&mut self, db: &impl HirDatabase, module: Module) -> Cancelable<()> {
|
||||
let (file_id, module_source) = module.defenition_source(db)?;
|
||||
let (file_id, module_source) = module.definition_source(db)?;
|
||||
let node = match &module_source {
|
||||
ModuleSource::SourceFile(node) => node.syntax(),
|
||||
ModuleSource::Module(node) => node.syntax(),
|
||||
|
@ -20,7 +20,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
|
||||
}
|
||||
|
||||
let module_scope = module.scope(ctx.db)?;
|
||||
let (file_id, _) = module.defenition_source(ctx.db)?;
|
||||
let (file_id, _) = module.definition_source(ctx.db)?;
|
||||
module_scope
|
||||
.entries()
|
||||
.filter(|(_name, res)| {
|
||||
|
@ -6,22 +6,22 @@ use ra_syntax::{
|
||||
|
||||
use crate::{FilePosition, NavigationTarget, db::RootDatabase};
|
||||
|
||||
pub(crate) fn goto_defenition(
|
||||
pub(crate) fn goto_definition(
|
||||
db: &RootDatabase,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<Vec<NavigationTarget>>> {
|
||||
let file = db.source_file(position.file_id);
|
||||
let syntax = file.syntax();
|
||||
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) {
|
||||
return Ok(Some(reference_defenition(db, position.file_id, name_ref)?));
|
||||
return Ok(Some(reference_definition(db, position.file_id, name_ref)?));
|
||||
}
|
||||
if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) {
|
||||
return name_defenition(db, position.file_id, name);
|
||||
return name_definition(db, position.file_id, name);
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub(crate) fn reference_defenition(
|
||||
pub(crate) fn reference_definition(
|
||||
db: &RootDatabase,
|
||||
file_id: FileId,
|
||||
name_ref: &ast::NameRef,
|
||||
@ -51,7 +51,7 @@ pub(crate) fn reference_defenition(
|
||||
Ok(navs)
|
||||
}
|
||||
|
||||
fn name_defenition(
|
||||
fn name_definition(
|
||||
db: &RootDatabase,
|
||||
file_id: FileId,
|
||||
name: &ast::Name,
|
||||
@ -61,7 +61,7 @@ fn name_defenition(
|
||||
if let Some(child_module) =
|
||||
hir::source_binder::module_from_declaration(db, file_id, module)?
|
||||
{
|
||||
let (file_id, _) = child_module.defenition_source(db)?;
|
||||
let (file_id, _) = child_module.definition_source(db)?;
|
||||
let name = match child_module.name(db)? {
|
||||
Some(name) => name.to_string().into(),
|
||||
None => "".into(),
|
||||
@ -86,7 +86,7 @@ mod tests {
|
||||
use crate::mock_analysis::analysis_and_position;
|
||||
|
||||
#[test]
|
||||
fn goto_defenition_works_in_items() {
|
||||
fn goto_definition_works_in_items() {
|
||||
let (analysis, pos) = analysis_and_position(
|
||||
"
|
||||
//- /lib.rs
|
||||
@ -95,7 +95,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
|
||||
let symbols = analysis.goto_defenition(pos).unwrap().unwrap();
|
||||
let symbols = analysis.goto_definition(pos).unwrap().unwrap();
|
||||
assert_eq_dbg(
|
||||
r#"[NavigationTarget { file_id: FileId(1), name: "Foo",
|
||||
kind: STRUCT_DEF, range: [0; 11),
|
||||
@ -105,7 +105,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn goto_defenition_works_for_module_declaration() {
|
||||
fn goto_definition_works_for_module_declaration() {
|
||||
let (analysis, pos) = analysis_and_position(
|
||||
"
|
||||
//- /lib.rs
|
||||
@ -115,7 +115,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
|
||||
let symbols = analysis.goto_defenition(pos).unwrap().unwrap();
|
||||
let symbols = analysis.goto_definition(pos).unwrap().unwrap();
|
||||
assert_eq_dbg(
|
||||
r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
|
||||
&symbols,
|
||||
@ -130,7 +130,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
|
||||
let symbols = analysis.goto_defenition(pos).unwrap().unwrap();
|
||||
let symbols = analysis.goto_definition(pos).unwrap().unwrap();
|
||||
assert_eq_dbg(
|
||||
r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
|
||||
&symbols,
|
@ -16,7 +16,7 @@ pub(crate) fn hover(
|
||||
|
||||
let mut range = None;
|
||||
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) {
|
||||
let navs = crate::goto_defenition::reference_defenition(db, position.file_id, name_ref)?;
|
||||
let navs = crate::goto_definition::reference_definition(db, position.file_id, name_ref)?;
|
||||
for nav in navs {
|
||||
res.extend(doc_text_for(db, nav)?)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ macro_rules! ctry {
|
||||
|
||||
mod completion;
|
||||
mod db;
|
||||
mod goto_defenition;
|
||||
mod goto_definition;
|
||||
mod imp;
|
||||
pub mod mock_analysis;
|
||||
mod runnables;
|
||||
@ -399,11 +399,11 @@ impl Analysis {
|
||||
.collect();
|
||||
Ok(res)
|
||||
}
|
||||
pub fn goto_defenition(
|
||||
pub fn goto_definition(
|
||||
&self,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<Vec<NavigationTarget>>> {
|
||||
goto_defenition::goto_defenition(&*self.db, position)
|
||||
goto_definition::goto_definition(&*self.db, position)
|
||||
}
|
||||
/// Finds all usages of the reference at point.
|
||||
pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {
|
||||
|
@ -213,7 +213,7 @@ pub fn handle_goto_definition(
|
||||
params: req::TextDocumentPositionParams,
|
||||
) -> Result<Option<req::GotoDefinitionResponse>> {
|
||||
let position = params.try_conv_with(&world)?;
|
||||
let navs = match world.analysis().goto_defenition(position)? {
|
||||
let navs = match world.analysis().goto_definition(position)? {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user