Fix typo defenition -> definition

This commit is contained in:
Marcus Klaas de Vries 2019-01-08 23:38:51 +01:00
parent 46f74e33ca
commit f8261d611a
8 changed files with 21 additions and 21 deletions

View file

@ -75,8 +75,8 @@ impl Module {
} }
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. /// 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)> { pub fn definition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> {
self.defenition_source_impl(db) self.definition_source_impl(db)
} }
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
/// `None` for the crate root. /// `None` for the crate root.

View file

@ -37,7 +37,7 @@ impl Module {
Ok(Some(link.name(&module_tree).clone())) Ok(Some(link.name(&module_tree).clone()))
} }
pub fn defenition_source_impl( pub fn definition_source_impl(
&self, &self,
db: &impl HirDatabase, db: &impl HirDatabase,
) -> Cancelable<(FileId, ModuleSource)> { ) -> Cancelable<(FileId, ModuleSource)> {

View file

@ -150,7 +150,7 @@ impl ModuleImplBlocks {
} }
fn collect(&mut self, db: &impl HirDatabase, module: Module) -> Cancelable<()> { 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 { let node = match &module_source {
ModuleSource::SourceFile(node) => node.syntax(), ModuleSource::SourceFile(node) => node.syntax(),
ModuleSource::Module(node) => node.syntax(), ModuleSource::Module(node) => node.syntax(),

View file

@ -20,7 +20,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
} }
let module_scope = module.scope(ctx.db)?; 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 module_scope
.entries() .entries()
.filter(|(_name, res)| { .filter(|(_name, res)| {

View file

@ -6,22 +6,22 @@ use ra_syntax::{
use crate::{FilePosition, NavigationTarget, db::RootDatabase}; use crate::{FilePosition, NavigationTarget, db::RootDatabase};
pub(crate) fn goto_defenition( pub(crate) fn goto_definition(
db: &RootDatabase, db: &RootDatabase,
position: FilePosition, position: FilePosition,
) -> Cancelable<Option<Vec<NavigationTarget>>> { ) -> Cancelable<Option<Vec<NavigationTarget>>> {
let file = db.source_file(position.file_id); let file = db.source_file(position.file_id);
let syntax = file.syntax(); let syntax = file.syntax();
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { 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) { 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) Ok(None)
} }
pub(crate) fn reference_defenition( pub(crate) fn reference_definition(
db: &RootDatabase, db: &RootDatabase,
file_id: FileId, file_id: FileId,
name_ref: &ast::NameRef, name_ref: &ast::NameRef,
@ -51,7 +51,7 @@ pub(crate) fn reference_defenition(
Ok(navs) Ok(navs)
} }
fn name_defenition( fn name_definition(
db: &RootDatabase, db: &RootDatabase,
file_id: FileId, file_id: FileId,
name: &ast::Name, name: &ast::Name,
@ -61,7 +61,7 @@ fn name_defenition(
if let Some(child_module) = if let Some(child_module) =
hir::source_binder::module_from_declaration(db, file_id, 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)? { let name = match child_module.name(db)? {
Some(name) => name.to_string().into(), Some(name) => name.to_string().into(),
None => "".into(), None => "".into(),
@ -86,7 +86,7 @@ mod tests {
use crate::mock_analysis::analysis_and_position; use crate::mock_analysis::analysis_and_position;
#[test] #[test]
fn goto_defenition_works_in_items() { fn goto_definition_works_in_items() {
let (analysis, pos) = analysis_and_position( let (analysis, pos) = analysis_and_position(
" "
//- /lib.rs //- /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( assert_eq_dbg(
r#"[NavigationTarget { file_id: FileId(1), name: "Foo", r#"[NavigationTarget { file_id: FileId(1), name: "Foo",
kind: STRUCT_DEF, range: [0; 11), kind: STRUCT_DEF, range: [0; 11),
@ -105,7 +105,7 @@ mod tests {
} }
#[test] #[test]
fn goto_defenition_works_for_module_declaration() { fn goto_definition_works_for_module_declaration() {
let (analysis, pos) = analysis_and_position( let (analysis, pos) = analysis_and_position(
" "
//- /lib.rs //- /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( assert_eq_dbg(
r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#, r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
&symbols, &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( assert_eq_dbg(
r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#, r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
&symbols, &symbols,

View file

@ -16,7 +16,7 @@ pub(crate) fn hover(
let mut range = None; let mut range = None;
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { 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 { for nav in navs {
res.extend(doc_text_for(db, nav)?) res.extend(doc_text_for(db, nav)?)
} }

View file

@ -20,7 +20,7 @@ macro_rules! ctry {
mod completion; mod completion;
mod db; mod db;
mod goto_defenition; mod goto_definition;
mod imp; mod imp;
pub mod mock_analysis; pub mod mock_analysis;
mod runnables; mod runnables;
@ -399,11 +399,11 @@ impl Analysis {
.collect(); .collect();
Ok(res) Ok(res)
} }
pub fn goto_defenition( pub fn goto_definition(
&self, &self,
position: FilePosition, position: FilePosition,
) -> Cancelable<Option<Vec<NavigationTarget>>> { ) -> 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. /// Finds all usages of the reference at point.
pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {

View file

@ -213,7 +213,7 @@ pub fn handle_goto_definition(
params: req::TextDocumentPositionParams, params: req::TextDocumentPositionParams,
) -> Result<Option<req::GotoDefinitionResponse>> { ) -> Result<Option<req::GotoDefinitionResponse>> {
let position = params.try_conv_with(&world)?; 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), None => return Ok(None),
Some(it) => it, Some(it) => it,
}; };