forked from lix-project/lix
jade
0145d45806
package.nix previously needed this callPackage'd externally, which
didn't make a lot of sense to us since this is an internal dependency.
Thus we changed it to make it more self contained.
Change-Id: I4935bc0bc80e1a132bc9b1519e917791da95037c
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
// SPDX-FileCopyrightText: 2024 Jade Lovelace
|
|
//
|
|
// SPDX-License-Identifier: BSD-2-Clause OR MIT
|
|
|
|
use rnix::types::{Lambda, TypedNode};
|
|
use rnix::SyntaxKind::*;
|
|
|
|
/// Pretty-prints the arguments to a function
|
|
pub fn pprint_args(lambda: &Lambda) -> String {
|
|
// TODO: handle docs directly on NODE_IDENT args (uncommon case)
|
|
let mut lambda = lambda.clone();
|
|
let mut out = String::new();
|
|
loop {
|
|
let arg = lambda.arg().unwrap();
|
|
match arg.kind() {
|
|
NODE_IDENT => {
|
|
out += &format!("*{}*", &arg.to_string());
|
|
out.push_str(": ");
|
|
let body = lambda.body().unwrap();
|
|
if body.kind() == NODE_LAMBDA {
|
|
lambda = Lambda::cast(body).unwrap();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
NODE_PATTERN => {
|
|
out += &format!("*{}*", &arg.to_string());
|
|
out.push_str(": ");
|
|
break;
|
|
}
|
|
t => {
|
|
unreachable!("unhandled arg type {:?}", t);
|
|
}
|
|
}
|
|
}
|
|
out.push_str("...");
|
|
out
|
|
|
|
//pprint_arg(lambda.arg());
|
|
}
|