feat(xatu): report empty let expressions
This commit was merged in pull request #83.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use rnix::ast::HasEntry;
|
||||
use rowan::ast::AstNode;
|
||||
|
||||
use crate::{FileId, ast};
|
||||
@@ -37,6 +38,7 @@ fn convert_syntax(syntax: rnix::SyntaxNode) -> (Vec<ast::Node>, Vec<ast::Token>)
|
||||
fn convert_node(node: rnix::SyntaxNode) -> Option<ast::Node> {
|
||||
match node.kind() {
|
||||
rnix::SyntaxKind::NODE_APPLY => convert_apply(node),
|
||||
rnix::SyntaxKind::NODE_LET_IN => convert_let_in(node),
|
||||
rnix::SyntaxKind::NODE_INHERIT => convert_inherit(node),
|
||||
_ => None,
|
||||
}
|
||||
@@ -102,6 +104,27 @@ impl TryFrom<rnix::ast::Select> for ast::Select {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_let_in(node: rnix::SyntaxNode) -> Option<ast::Node> {
|
||||
let let_in = rnix::ast::LetIn::cast(node)?;
|
||||
|
||||
Some(ast::Node {
|
||||
range: let_in.syntax().text_range().into(),
|
||||
data: ast::NodeData::LetIn(let_in.into()),
|
||||
})
|
||||
}
|
||||
|
||||
impl From<rnix::ast::LetIn> for ast::LetIn {
|
||||
fn from(let_in: rnix::ast::LetIn) -> Self {
|
||||
Self {
|
||||
binding_count: let_in.attrpath_values().count()
|
||||
+ let_in
|
||||
.inherits()
|
||||
.map(|inherit| inherit.attrs().count())
|
||||
.sum::<usize>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_inherit(node: rnix::SyntaxNode) -> Option<ast::Node> {
|
||||
let inherit = rnix::ast::Inherit::cast(node)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user