Skip to content

New runnables #4710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 23 additions & 43 deletions crates/ra_ide/src/display/navigation_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ impl NavigationTarget {
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
if let Some(src) = module.declaration_source(db) {
let frange = original_range(db, src.as_ref().map(|it| it.syntax()));
return NavigationTarget::from_syntax(
let mut res = NavigationTarget::from_syntax(
frange.file_id,
name,
None,
frange.range,
src.value.syntax().kind(),
src.value.doc_comment_text(),
src.value.short_label(),
);
res.docs = src.value.doc_comment_text();
res.description = src.value.short_label();
return res;
}
module.to_nav(db)
}
Expand Down Expand Up @@ -130,11 +131,9 @@ impl NavigationTarget {
}

/// Allows `NavigationTarget` to be created from a `NameOwner`
fn from_named(
pub(crate) fn from_named(
db: &RootDatabase,
node: InFile<&dyn ast::NameOwner>,
docs: Option<String>,
description: Option<String>,
) -> NavigationTarget {
//FIXME: use `_` instead of empty string
let name = node.value.name().map(|it| it.text().clone()).unwrap_or_default();
Expand All @@ -148,8 +147,6 @@ impl NavigationTarget {
focus_range,
frange.range,
node.value.syntax().kind(),
docs,
description,
)
}

Expand All @@ -159,8 +156,6 @@ impl NavigationTarget {
focus_range: Option<TextRange>,
full_range: TextRange,
kind: SyntaxKind,
docs: Option<String>,
description: Option<String>,
) -> NavigationTarget {
NavigationTarget {
file_id,
Expand All @@ -169,8 +164,8 @@ impl NavigationTarget {
full_range,
focus_range,
container_name: None,
description,
docs,
description: None,
docs: None,
}
}
}
Expand Down Expand Up @@ -238,12 +233,11 @@ where
{
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db);
NavigationTarget::from_named(
db,
src.as_ref().map(|it| it as &dyn ast::NameOwner),
src.value.doc_comment_text(),
src.value.short_label(),
)
let mut res =
NavigationTarget::from_named(db, src.as_ref().map(|it| it as &dyn ast::NameOwner));
res.docs = src.value.doc_comment_text();
res.description = src.value.short_label();
res
}
}

Expand All @@ -258,15 +252,7 @@ impl ToNav for hir::Module {
}
};
let frange = original_range(db, src.with_value(syntax));
NavigationTarget::from_syntax(
frange.file_id,
name,
focus,
frange.range,
syntax.kind(),
None,
None,
)
NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, syntax.kind())
}
}

Expand All @@ -285,8 +271,6 @@ impl ToNav for hir::ImplDef {
None,
frange.range,
src.value.syntax().kind(),
None,
None,
)
}
}
Expand All @@ -296,12 +280,12 @@ impl ToNav for hir::Field {
let src = self.source(db);

match &src.value {
FieldSource::Named(it) => NavigationTarget::from_named(
db,
src.with_value(it),
it.doc_comment_text(),
it.short_label(),
),
FieldSource::Named(it) => {
let mut res = NavigationTarget::from_named(db, src.with_value(it));
res.docs = it.doc_comment_text();
res.description = it.short_label();
res
}
FieldSource::Pos(it) => {
let frange = original_range(db, src.with_value(it.syntax()));
NavigationTarget::from_syntax(
Expand All @@ -310,8 +294,6 @@ impl ToNav for hir::Field {
None,
frange.range,
it.syntax().kind(),
None,
None,
)
}
}
Expand All @@ -322,12 +304,10 @@ impl ToNav for hir::MacroDef {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db);
log::debug!("nav target {:#?}", src.value.syntax());
NavigationTarget::from_named(
db,
src.as_ref().map(|it| it as &dyn ast::NameOwner),
src.value.doc_comment_text(),
None,
)
let mut res =
NavigationTarget::from_named(db, src.as_ref().map(|it| it as &dyn ast::NameOwner));
res.docs = src.value.doc_comment_text();
res
}
}

Expand Down
Loading