feat(xatu): add manual inherit from lint

This commit was merged in pull request #87.
This commit is contained in:
2026-09-19 23:30:56 -04:00
parent 4b7d3834ab
commit f9aff6839e
9 changed files with 105 additions and 11 deletions

View File

@@ -67,15 +67,24 @@ impl TryFrom<rnix::ast::AttrpathValue> for ast::Binding {
return Err(());
}
let value = match binding.value().ok_or(())? {
rnix::ast::Expr::Ident(ident) => ident.into(),
_ => return Err(()),
};
let value = binding.value().ok_or(())?.try_into()?;
Ok(Self { key, value })
}
}
impl TryFrom<rnix::ast::Expr> for ast::Expr {
type Error = ();
fn try_from(expr: rnix::ast::Expr) -> Result<Self, Self::Error> {
match expr {
rnix::ast::Expr::Ident(ident) => Ok(Self::Ident(ident.into())),
rnix::ast::Expr::Select(select) => Ok(Self::Select(select.try_into()?)),
_ => Err(()),
}
}
}
impl From<rnix::ast::Ident> for ast::Ident {
fn from(ident: rnix::ast::Ident) -> Self {
Self {
@@ -84,6 +93,31 @@ impl From<rnix::ast::Ident> for ast::Ident {
}
}
impl TryFrom<rnix::ast::Select> for ast::Select {
type Error = ();
fn try_from(select: rnix::ast::Select) -> Result<Self, Self::Error> {
if select.or_token().is_some() {
return Err(());
}
let mut attrs = select.attrpath().ok_or(())?.attrs();
let attr = match attrs.next().ok_or(())? {
Attr::Ident(ident) => ident.into(),
_ => return Err(()),
};
if attrs.next().is_some() {
return Err(());
}
Ok(Self {
receiver: select.expr().ok_or(())?.syntax().to_string(),
attr,
})
}
}
fn convert_token(token: rnix::SyntaxToken) -> Option<ast::Token> {
match token.kind() {
rnix::SyntaxKind::TOKEN_URI => Some(ast::Token {