rust-analyzer/crates/ide/src/navigation_target.rs

600 lines
20 KiB
Rust
Raw Normal View History

2021-05-22 13:53:47 +00:00
//! See [`NavigationTarget`].
2020-12-18 18:26:47 +00:00
use std::fmt;
use either::Either;
2021-03-15 16:58:42 +00:00
use hir::{
AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource,
Semantics,
2021-03-15 16:58:42 +00:00
};
use ide_db::{
2021-03-16 14:44:31 +00:00
base_db::{FileId, FileRange},
symbol_index::FileSymbolKind,
2021-01-20 14:25:34 +00:00
SymbolKind,
};
2020-08-13 14:39:16 +00:00
use ide_db::{defs::Definition, RootDatabase};
2020-08-12 16:26:51 +00:00
use syntax::{
2021-09-27 10:54:24 +00:00
ast::{self, HasName},
match_ast, AstNode, SmolStr, TextRange,
2019-01-11 10:28:59 +00:00
};
2019-01-11 10:01:35 +00:00
2020-06-30 11:27:13 +00:00
use crate::FileSymbol;
/// `NavigationTarget` represents an element in the editor's UI which you can
2019-01-11 11:00:54 +00:00
/// click on to navigate to a particular piece of code.
///
/// Typically, a `NavigationTarget` corresponds to some element in the source
/// code, like a function or a struct, but this is not strictly required.
2020-12-18 18:26:47 +00:00
#[derive(Clone, PartialEq, Eq, Hash)]
2019-01-11 11:00:54 +00:00
pub struct NavigationTarget {
2020-07-17 10:42:48 +00:00
pub file_id: FileId,
/// Range which encompasses the whole element.
///
/// Should include body, doc comments, attributes, etc.
///
/// Clients should use this range to answer "is the cursor inside the
/// element?" question.
pub full_range: TextRange,
/// A "most interesting" range within the `full_range`.
2020-07-17 10:42:48 +00:00
///
/// Typically, `full_range` is the whole syntax node, including doc
/// comments, and `focus_range` is the range of the identifier.
2020-07-17 10:42:48 +00:00
///
/// Clients should place the cursor on this range when navigating to this target.
pub focus_range: Option<TextRange>,
pub name: SmolStr,
pub kind: Option<SymbolKind>,
2020-07-17 10:42:48 +00:00
pub container_name: Option<SmolStr>,
pub description: Option<String>,
pub docs: Option<Documentation>,
2019-01-11 11:00:54 +00:00
}
2019-01-11 10:01:35 +00:00
2020-12-18 18:26:47 +00:00
impl fmt::Debug for NavigationTarget {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("NavigationTarget");
macro_rules! opt {
($($name:ident)*) => {$(
if let Some(it) = &self.$name {
f.field(stringify!($name), it);
}
)*}
}
f.field("file_id", &self.file_id).field("full_range", &self.full_range);
opt!(focus_range);
f.field("name", &self.name);
opt!(kind container_name description docs);
f.finish()
}
}
2019-11-11 08:15:19 +00:00
pub(crate) trait ToNav {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget;
}
2020-02-22 15:57:29 +00:00
pub(crate) trait TryToNav {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget>;
}
impl<T: TryToNav, U: TryToNav> TryToNav for Either<T, U> {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
match self {
Either::Left(it) => it.try_to_nav(db),
Either::Right(it) => it.try_to_nav(db),
}
}
}
2019-01-11 10:01:35 +00:00
impl NavigationTarget {
2020-07-17 10:42:48 +00:00
pub fn focus_or_full_range(&self) -> TextRange {
self.focus_range.unwrap_or(self.full_range)
}
pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
let name = module.name(db).map(|it| it.to_smol_str()).unwrap_or_default();
2019-06-11 14:48:27 +00:00
if let Some(src) = module.declaration_source(db) {
2021-08-16 14:12:20 +00:00
let node = src.syntax();
2021-02-09 15:21:09 +00:00
let full_range = node.original_file_range(db);
let focus_range = src
.value
.name()
.map(|name| src.with_value(name.syntax()).original_file_range(db).range);
2020-06-02 15:22:23 +00:00
let mut res = NavigationTarget::from_syntax(
2021-02-09 15:21:09 +00:00
full_range.file_id,
2019-06-08 19:27:01 +00:00
name,
2021-02-09 15:21:09 +00:00
focus_range,
full_range.range,
SymbolKind::Module,
2019-06-08 19:27:01 +00:00
);
res.docs = module.attrs(db).docs();
2021-03-15 16:58:42 +00:00
res.description = Some(module.display(db).to_string());
2020-06-02 15:22:23 +00:00
return res;
2019-01-13 18:56:20 +00:00
}
2019-11-11 08:15:19 +00:00
module.to_nav(db)
}
2019-01-11 15:17:20 +00:00
#[cfg(test)]
pub(crate) fn debug_render(&self) -> String {
let mut buf = format!(
"{} {:?} {:?} {:?}",
self.name,
self.kind.unwrap(),
self.file_id,
self.full_range
);
2020-07-17 10:42:48 +00:00
if let Some(focus_range) = self.focus_range {
2019-01-11 15:17:20 +00:00
buf.push_str(&format!(" {:?}", focus_range))
}
2020-07-17 10:42:48 +00:00
if let Some(container_name) = &self.container_name {
buf.push_str(&format!(" {}", container_name))
}
2019-01-11 15:17:20 +00:00
buf
}
/// Allows `NavigationTarget` to be created from a `NameOwner`
2020-06-02 15:22:23 +00:00
pub(crate) fn from_named(
db: &RootDatabase,
2021-09-27 10:54:24 +00:00
node: InFile<&dyn ast::HasName>,
kind: SymbolKind,
2019-06-08 19:27:01 +00:00
) -> NavigationTarget {
2021-01-19 22:56:11 +00:00
let name = node.value.name().map(|it| it.text().into()).unwrap_or_else(|| "_".into());
let focus_range = node
.value
.name()
.and_then(|it| node.with_value(it.syntax()).original_file_range_opt(db))
.map(|it| it.range);
let frange = node.map(|it| it.syntax()).original_file_range(db);
NavigationTarget::from_syntax(frange.file_id, name, focus_range, frange.range, kind)
2019-01-11 10:28:59 +00:00
}
2019-01-11 11:00:54 +00:00
fn from_syntax(
file_id: FileId,
name: SmolStr,
focus_range: Option<TextRange>,
full_range: TextRange,
kind: SymbolKind,
2019-01-11 11:00:54 +00:00
) -> NavigationTarget {
2019-01-11 10:05:45 +00:00
NavigationTarget {
file_id,
2019-01-11 10:28:59 +00:00
name,
kind: Some(kind),
full_range,
2019-01-11 11:00:54 +00:00
focus_range,
container_name: None,
2020-06-02 15:22:23 +00:00
description: None,
docs: None,
2019-01-11 10:05:45 +00:00
}
}
2019-06-08 14:26:27 +00:00
}
2021-11-28 00:42:42 +00:00
impl TryToNav for FileSymbol {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
2021-11-30 04:50:09 +00:00
let full_range = self.loc.original_range(db)?;
let name_range = self.loc.original_name_range(db)?;
2021-11-28 00:42:42 +00:00
Some(NavigationTarget {
file_id: full_range.file_id,
2019-11-11 08:15:19 +00:00
name: self.name.clone(),
kind: Some(match self.kind {
FileSymbolKind::Function => SymbolKind::Function,
FileSymbolKind::Struct => SymbolKind::Struct,
FileSymbolKind::Enum => SymbolKind::Enum,
FileSymbolKind::Trait => SymbolKind::Trait,
FileSymbolKind::Module => SymbolKind::Module,
FileSymbolKind::TypeAlias => SymbolKind::TypeAlias,
FileSymbolKind::Const => SymbolKind::Const,
FileSymbolKind::Static => SymbolKind::Static,
FileSymbolKind::Macro => SymbolKind::Macro,
2021-01-24 00:32:52 +00:00
FileSymbolKind::Union => SymbolKind::Union,
}),
2021-11-28 00:42:42 +00:00
full_range: full_range.range,
focus_range: Some(name_range.range),
2019-11-11 08:15:19 +00:00
container_name: self.container_name.clone(),
description: description_from_symbol(db, self),
2020-12-17 14:45:26 +00:00
docs: None,
2021-11-28 00:42:42 +00:00
})
2019-11-11 08:15:19 +00:00
}
}
2020-03-03 17:36:39 +00:00
impl TryToNav for Definition {
2020-02-22 15:57:29 +00:00
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
match self {
Definition::Local(it) => Some(it.to_nav(db)),
Definition::Label(it) => Some(it.to_nav(db)),
Definition::Module(it) => Some(it.to_nav(db)),
Definition::Macro(it) => it.try_to_nav(db),
Definition::Field(it) => it.try_to_nav(db),
Definition::SelfType(it) => it.try_to_nav(db),
Definition::GenericParam(it) => it.try_to_nav(db),
Definition::Function(it) => it.try_to_nav(db),
Definition::Adt(it) => it.try_to_nav(db),
Definition::Variant(it) => it.try_to_nav(db),
Definition::Const(it) => it.try_to_nav(db),
Definition::Static(it) => it.try_to_nav(db),
Definition::Trait(it) => it.try_to_nav(db),
Definition::TypeAlias(it) => it.try_to_nav(db),
Definition::BuiltinType(_) => None,
2020-02-22 15:57:29 +00:00
}
}
}
impl TryToNav for hir::ModuleDef {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
match self {
hir::ModuleDef::Module(it) => Some(it.to_nav(db)),
hir::ModuleDef::Function(it) => it.try_to_nav(db),
hir::ModuleDef::Adt(it) => it.try_to_nav(db),
hir::ModuleDef::Variant(it) => it.try_to_nav(db),
hir::ModuleDef::Const(it) => it.try_to_nav(db),
hir::ModuleDef::Static(it) => it.try_to_nav(db),
hir::ModuleDef::Trait(it) => it.try_to_nav(db),
hir::ModuleDef::TypeAlias(it) => it.try_to_nav(db),
hir::ModuleDef::BuiltinType(_) => None,
}
2020-02-22 15:57:29 +00:00
}
}
pub(crate) trait ToNavFromAst {
const KIND: SymbolKind;
}
impl ToNavFromAst for hir::Function {
const KIND: SymbolKind = SymbolKind::Function;
}
impl ToNavFromAst for hir::Const {
const KIND: SymbolKind = SymbolKind::Const;
}
impl ToNavFromAst for hir::Static {
const KIND: SymbolKind = SymbolKind::Static;
}
impl ToNavFromAst for hir::Struct {
const KIND: SymbolKind = SymbolKind::Struct;
}
impl ToNavFromAst for hir::Enum {
const KIND: SymbolKind = SymbolKind::Enum;
}
2020-12-20 07:05:24 +00:00
impl ToNavFromAst for hir::Variant {
const KIND: SymbolKind = SymbolKind::Variant;
}
impl ToNavFromAst for hir::Union {
const KIND: SymbolKind = SymbolKind::Union;
}
impl ToNavFromAst for hir::TypeAlias {
const KIND: SymbolKind = SymbolKind::TypeAlias;
}
impl ToNavFromAst for hir::Trait {
const KIND: SymbolKind = SymbolKind::Trait;
}
2019-11-11 08:15:19 +00:00
impl<D> TryToNav for D
2019-11-11 08:15:19 +00:00
where
2021-03-15 16:58:42 +00:00
D: HasSource + ToNavFromAst + Copy + HasAttrs + HirDisplay,
2021-09-27 10:54:24 +00:00
D::Ast: ast::HasName,
2019-11-11 08:15:19 +00:00
{
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
let mut res = NavigationTarget::from_named(
db,
2021-09-27 10:54:24 +00:00
src.as_ref().map(|it| it as &dyn ast::HasName),
D::KIND,
);
res.docs = self.docs(db);
2021-03-15 16:58:42 +00:00
res.description = Some(self.display(db).to_string());
Some(res)
2019-11-11 08:15:19 +00:00
}
}
impl ToNav for hir::Module {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.definition_source(db);
let name = self.name(db).map(|it| it.to_smol_str()).unwrap_or_default();
2020-02-22 15:57:29 +00:00
let (syntax, focus) = match &src.value {
ModuleSource::SourceFile(node) => (node.syntax(), None),
ModuleSource::Module(node) => {
(node.syntax(), node.name().map(|it| it.syntax().text_range()))
}
ModuleSource::BlockExpr(node) => (node.syntax(), None),
2019-12-03 20:24:02 +00:00
};
let frange = src.with_value(syntax).original_file_range(db);
NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module)
2019-11-11 08:15:19 +00:00
}
}
impl TryToNav for hir::Impl {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
2020-06-30 11:20:16 +00:00
let derive_attr = self.is_builtin_derive(db);
let frange = match &derive_attr {
Some(item) => item.syntax().original_file_range(db),
None => src.syntax().original_file_range(db),
};
2020-06-30 11:20:16 +00:00
let focus_range = if derive_attr.is_some() {
None
} else {
src.value.self_ty().map(|ty| src.with_value(ty.syntax()).original_file_range(db).range)
2020-06-30 11:20:16 +00:00
};
2019-11-11 08:15:19 +00:00
Some(NavigationTarget::from_syntax(
frange.file_id,
2019-11-11 08:15:19 +00:00
"impl".into(),
2020-06-30 11:03:08 +00:00
focus_range,
frange.range,
SymbolKind::Impl,
))
2019-11-11 08:15:19 +00:00
}
}
impl TryToNav for hir::Field {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
2019-11-11 08:15:19 +00:00
let field_source = match &src.value {
2020-06-02 15:22:23 +00:00
FieldSource::Named(it) => {
let mut res =
NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field);
res.docs = self.docs(db);
2021-03-15 16:58:42 +00:00
res.description = Some(self.display(db).to_string());
2020-06-02 15:22:23 +00:00
res
}
2019-11-11 08:15:19 +00:00
FieldSource::Pos(it) => {
let frange = src.with_value(it.syntax()).original_file_range(db);
2019-11-11 08:15:19 +00:00
NavigationTarget::from_syntax(
frange.file_id,
2019-11-11 08:15:19 +00:00
"".into(),
None,
frange.range,
SymbolKind::Field,
2019-11-11 08:15:19 +00:00
)
}
};
Some(field_source)
2019-11-11 08:15:19 +00:00
}
}
impl TryToNav for hir::MacroDef {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
2021-09-27 10:54:24 +00:00
let name_owner: &dyn ast::HasName = match &src.value {
2021-03-18 15:11:18 +00:00
Either::Left(it) => it,
Either::Right(it) => it,
};
2021-08-15 12:46:13 +00:00
tracing::debug!("nav target {:#?}", name_owner.syntax());
let mut res = NavigationTarget::from_named(
db,
2021-03-18 15:11:18 +00:00
src.as_ref().with_value(name_owner),
SymbolKind::Macro,
);
res.docs = self.docs(db);
Some(res)
2019-11-11 08:15:19 +00:00
}
}
impl TryToNav for hir::Adt {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
2019-11-11 08:15:19 +00:00
match self {
hir::Adt::Struct(it) => it.try_to_nav(db),
hir::Adt::Union(it) => it.try_to_nav(db),
hir::Adt::Enum(it) => it.try_to_nav(db),
2019-11-11 08:15:19 +00:00
}
}
}
impl TryToNav for hir::AssocItem {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
2019-11-11 08:15:19 +00:00
match self {
AssocItem::Function(it) => it.try_to_nav(db),
AssocItem::Const(it) => it.try_to_nav(db),
AssocItem::TypeAlias(it) => it.try_to_nav(db),
2019-11-11 08:15:19 +00:00
}
}
}
impl TryToNav for hir::GenericParam {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
match self {
hir::GenericParam::TypeParam(it) => it.try_to_nav(db),
hir::GenericParam::ConstParam(it) => it.try_to_nav(db),
hir::GenericParam::LifetimeParam(it) => it.try_to_nav(db),
}
}
}
2019-11-09 21:32:00 +00:00
impl ToNav for hir::Local {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db);
let (node, name) = match &src.value {
Either::Left(bind_pat) => (bind_pat.syntax().clone(), bind_pat.name()),
Either::Right(it) => (it.syntax().clone(), it.name()),
2019-11-09 21:32:00 +00:00
};
let focus_range =
name.map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range);
let full_range = src.with_value(&node).original_file_range(db);
2019-11-09 21:32:00 +00:00
let name = match self.name(db) {
Some(it) => it.to_smol_str(),
2019-11-09 21:32:00 +00:00
None => "".into(),
};
let kind = if self.is_self(db) {
SymbolKind::SelfParam
} else if self.is_param(db) {
SymbolKind::ValueParam
} else {
SymbolKind::Local
};
2019-11-09 21:32:00 +00:00
NavigationTarget {
file_id: full_range.file_id,
2019-11-09 21:32:00 +00:00
name,
kind: Some(kind),
full_range: full_range.range,
focus_range,
2019-11-09 21:32:00 +00:00
container_name: None,
description: None,
docs: None,
}
}
}
2020-12-23 16:15:01 +00:00
impl ToNav for hir::Label {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db);
let node = src.value.syntax();
let FileRange { file_id, range } = src.with_value(node).original_file_range(db);
let focus_range =
src.value.lifetime().and_then(|lt| lt.lifetime_ident_token()).map(|lt| lt.text_range());
let name = self.name(db).to_smol_str();
2020-12-23 16:15:01 +00:00
NavigationTarget {
file_id,
name,
kind: Some(SymbolKind::Label),
full_range: range,
focus_range,
container_name: None,
description: None,
docs: None,
}
}
}
impl TryToNav for hir::TypeParam {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
let full_range = match &src.value {
Either::Left(type_param) => type_param.syntax().text_range(),
Either::Right(trait_) => trait_
.name()
.map_or_else(|| trait_.syntax().text_range(), |name| name.syntax().text_range()),
2019-12-07 17:48:35 +00:00
};
let focus_range = match &src.value {
Either::Left(it) => it.name(),
Either::Right(it) => it.name(),
}
.map(|it| it.syntax().text_range());
Some(NavigationTarget {
2019-12-07 17:48:35 +00:00
file_id: src.file_id.original_file(db),
name: self.name(db).to_smol_str(),
kind: Some(SymbolKind::TypeParam),
full_range,
focus_range,
2019-12-07 17:48:35 +00:00
container_name: None,
description: None,
docs: None,
})
2020-12-16 20:35:15 +00:00
}
}
impl TryToNav for hir::LifetimeParam {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
2020-12-16 20:35:15 +00:00
let full_range = src.value.syntax().text_range();
Some(NavigationTarget {
2020-12-16 20:35:15 +00:00
file_id: src.file_id.original_file(db),
name: self.name(db).to_smol_str(),
kind: Some(SymbolKind::LifetimeParam),
2020-12-16 20:35:15 +00:00
full_range,
focus_range: Some(full_range),
container_name: None,
description: None,
docs: None,
})
2019-12-07 17:48:35 +00:00
}
}
impl TryToNav for hir::ConstParam {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
2021-01-01 09:07:01 +00:00
let full_range = src.value.syntax().text_range();
Some(NavigationTarget {
2021-01-01 09:07:01 +00:00
file_id: src.file_id.original_file(db),
name: self.name(db).to_smol_str(),
2021-01-01 09:07:01 +00:00
kind: Some(SymbolKind::ConstParam),
full_range,
focus_range: src.value.name().map(|n| n.syntax().text_range()),
container_name: None,
description: None,
docs: None,
})
2021-01-01 09:07:01 +00:00
}
}
2019-06-09 15:59:59 +00:00
/// Get a description of a symbol.
2019-06-08 14:26:27 +00:00
///
/// e.g. `struct Name`, `enum Name`, `fn Name`
2019-06-10 16:34:43 +00:00
pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> {
2021-03-16 14:44:31 +00:00
let sema = Semantics::new(db);
2021-11-28 00:42:42 +00:00
let node = symbol.loc.syntax(&sema)?;
2019-10-05 14:03:03 +00:00
match_ast! {
match node {
2021-03-16 14:44:31 +00:00
ast::Fn(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Struct(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Enum(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Trait(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Module(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::TypeAlias(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Const(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Static(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::RecordField(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Variant(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
2021-08-14 16:02:51 +00:00
ast::Union(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
2019-10-05 14:03:03 +00:00
_ => None,
}
}
2019-01-11 10:01:35 +00:00
}
2020-07-17 11:28:21 +00:00
#[cfg(test)]
mod tests {
2020-08-21 11:19:31 +00:00
use expect_test::expect;
2020-07-17 11:28:21 +00:00
2020-10-02 15:34:31 +00:00
use crate::{fixture, Query};
2020-07-17 11:28:21 +00:00
#[test]
fn test_nav_for_symbol() {
2020-10-02 15:34:31 +00:00
let (analysis, _) = fixture::file(
2020-07-17 11:28:21 +00:00
r#"
enum FooInner { }
fn foo() { enum FooInner { } }
"#,
);
let navs = analysis.symbol_search(Query::new("FooInner".to_string())).unwrap();
expect![[r#"
[
NavigationTarget {
file_id: FileId(
2020-10-02 14:13:48 +00:00
0,
2020-07-17 11:28:21 +00:00
),
full_range: 0..17,
2020-12-18 18:26:47 +00:00
focus_range: 5..13,
2020-07-17 11:28:21 +00:00
name: "FooInner",
2020-12-18 18:26:47 +00:00
kind: Enum,
description: "enum FooInner",
2020-07-17 11:28:21 +00:00
},
NavigationTarget {
file_id: FileId(
2020-10-02 14:13:48 +00:00
0,
2020-07-17 11:28:21 +00:00
),
full_range: 29..46,
2020-12-18 18:26:47 +00:00
focus_range: 34..42,
2020-07-17 11:28:21 +00:00
name: "FooInner",
2020-12-18 18:26:47 +00:00
kind: Enum,
container_name: "foo",
description: "enum FooInner",
2020-07-17 11:28:21 +00:00
},
]
"#]]
.assert_debug_eq(&navs);
}
#[test]
fn test_world_symbols_are_case_sensitive() {
2020-10-02 15:34:31 +00:00
let (analysis, _) = fixture::file(
2020-07-17 11:28:21 +00:00
r#"
fn foo() {}
struct Foo;
"#,
);
let navs = analysis.symbol_search(Query::new("foo".to_string())).unwrap();
assert_eq!(navs.len(), 2)
}
}