mirror of
https://github.com/astro/deadnix.git
synced 2024-11-24 09:12:50 +03:00
binding: remove body_node
This commit is contained in:
parent
d3ec79ea26
commit
3c004edcdd
@ -17,8 +17,6 @@ const PRAGMA_SKIP: &str = "deadnix: skip";
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Binding {
|
||||
pub name: Ident,
|
||||
/// syntax node of body depending on declaration
|
||||
pub body_node: SyntaxNode<NixLanguage>,
|
||||
/// syntax node of declaration itself
|
||||
pub decl_node: SyntaxNode<NixLanguage>,
|
||||
mortal: bool,
|
||||
@ -27,13 +25,11 @@ pub struct Binding {
|
||||
impl Binding {
|
||||
pub fn new(
|
||||
name: Ident,
|
||||
body_node: SyntaxNode<NixLanguage>,
|
||||
decl_node: SyntaxNode<NixLanguage>,
|
||||
mortal: bool,
|
||||
) -> Self {
|
||||
Binding {
|
||||
name,
|
||||
body_node,
|
||||
decl_node,
|
||||
mortal,
|
||||
}
|
||||
|
17
src/scope.rs
17
src/scope.rs
@ -85,11 +85,11 @@ impl Scope {
|
||||
pattern
|
||||
.pat_bind()
|
||||
.and_then(|name| name.ident())
|
||||
.map(|name| Binding::new(name.clone(), name.syntax().clone(), name.syntax().clone(), true))
|
||||
.map(|name| Binding::new(name.clone(), name.syntax().clone(), true))
|
||||
.into_iter()
|
||||
.chain(pattern.pat_entries().map(move |entry| {
|
||||
let name = entry.ident().expect("entry.ident");
|
||||
Binding::new(name, entry.syntax().clone(), entry.syntax().clone(), true)
|
||||
Binding::new(name, entry.syntax().clone(), true)
|
||||
})),
|
||||
),
|
||||
|
||||
@ -99,7 +99,6 @@ impl Scope {
|
||||
Some(Binding::new(
|
||||
name.clone(),
|
||||
name.syntax().clone(),
|
||||
name.syntax().clone(),
|
||||
mortal,
|
||||
))
|
||||
.into_iter(),
|
||||
@ -110,11 +109,6 @@ impl Scope {
|
||||
let_in
|
||||
.inherits()
|
||||
.flat_map(|inherit| {
|
||||
let body_node = if let Some(from) = inherit.from() {
|
||||
from.syntax().clone()
|
||||
} else {
|
||||
inherit.syntax().clone()
|
||||
};
|
||||
inherit.attrs().filter_map(move |attr|
|
||||
match attr {
|
||||
Attr::Ident(ident) => Some(ident),
|
||||
@ -123,7 +117,6 @@ impl Scope {
|
||||
).map(move |ident| {
|
||||
Binding::new(
|
||||
ident.clone(),
|
||||
body_node.clone(),
|
||||
ident.syntax().clone(),
|
||||
true
|
||||
)
|
||||
@ -135,7 +128,7 @@ impl Scope {
|
||||
match attrpath.attrs().next() {
|
||||
Some(Attr::Ident(name)) =>
|
||||
Some(
|
||||
Binding::new(name, entry.syntax().clone(), entry.syntax().clone(), true)
|
||||
Binding::new(name, entry.syntax().clone(), true)
|
||||
),
|
||||
_ => None,
|
||||
}
|
||||
@ -150,7 +143,7 @@ impl Scope {
|
||||
match attr {
|
||||
Attr::Ident(ref name) =>
|
||||
Some(
|
||||
Binding::new(name.clone(), inherit.syntax().clone(), attr.syntax().clone(), false)
|
||||
Binding::new(name.clone(), attr.syntax().clone(), false)
|
||||
),
|
||||
_ =>
|
||||
None,
|
||||
@ -166,7 +159,7 @@ impl Scope {
|
||||
match key {
|
||||
Some(Attr::Ident(name)) =>
|
||||
Some(
|
||||
Binding::new(name, entry.syntax().clone(), entry.syntax().clone(), false)
|
||||
Binding::new(name, entry.syntax().clone(), false)
|
||||
),
|
||||
_ => None,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user