Skip to content

Commit b0edbd7

Browse files
committed
checkpoint
Signed-off-by: lucasew <[email protected]>
1 parent ae01368 commit b0edbd7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/files.rs

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::problem::npv_169;
12
use crate::problem::npv_170;
23
use relative_path::RelativePath;
34
use relative_path::RelativePathBuf;
@@ -10,11 +11,50 @@ use crate::validation::ResultIteratorExt;
1011
use crate::validation::Validation::Success;
1112
use crate::{nix_file, ratchet, structure, validation};
1213

14+
fn find_invalid_withs(syntax: SyntaxNode<NixLanguage>) -> Option<SyntaxNode<NixLanguage>> {
15+
syntax
16+
.descendants()
17+
.filter(|node| node.kind() == rnix::SyntaxKind::NODE_WITH)
18+
.filter(|node| {
19+
node.descendants()
20+
.map(|child| {
21+
if child == *node {
22+
return None;
23+
}
24+
let node_if_invalid = match child.kind() {
25+
SyntaxKind::NODE_WITH => Some(node),
26+
SyntaxKind::NODE_LET_IN => Some(node),
27+
SyntaxKind::NODE_ATTR_SET => Some(node),
28+
_ => None,
29+
};
30+
println!(
31+
"validate with={:?} subexpr={:?} invalid={:?}",
32+
node.to_string(),
33+
child.to_string(),
34+
node_if_invalid
35+
);
36+
node_if_invalid
37+
})
38+
.any(|cond| cond != None)
39+
})
40+
.take(1)
41+
.last()
42+
}
43+
1344
pub fn check_files(
1445
nixpkgs_path: &Path,
1546
nix_file_store: &mut NixFileStore,
1647
) -> validation::Result<BTreeMap<RelativePathBuf, ratchet::File>> {
1748
process_nix_files(nixpkgs_path, nix_file_store, |nix_file| {
49+
if let Some(open_scope_with_lib) = find_invalid_withs(nix_file.syntax_root) {
50+
// TODO: what do I return
51+
// return ratchet::RatchetState::Loose(
52+
// npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new(
53+
// nix_file.relative_path,
54+
// )
55+
// .into(),
56+
// );
57+
}
1858
Ok(Success(ratchet::File {}))
1959
})
2060
}

0 commit comments

Comments
 (0)