Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: lucasew <[email protected]>
  • Loading branch information
lucasew committed Jan 9, 2025
1 parent ae01368 commit b0edbd7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/files.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::problem::npv_169;
use crate::problem::npv_170;
use relative_path::RelativePath;
use relative_path::RelativePathBuf;
Expand All @@ -10,11 +11,50 @@ use crate::validation::ResultIteratorExt;
use crate::validation::Validation::Success;
use crate::{nix_file, ratchet, structure, validation};

fn find_invalid_withs(syntax: SyntaxNode<NixLanguage>) -> Option<SyntaxNode<NixLanguage>> {
syntax
.descendants()
.filter(|node| node.kind() == rnix::SyntaxKind::NODE_WITH)
.filter(|node| {
node.descendants()
.map(|child| {
if child == *node {
return None;
}
let node_if_invalid = match child.kind() {
SyntaxKind::NODE_WITH => Some(node),
SyntaxKind::NODE_LET_IN => Some(node),
SyntaxKind::NODE_ATTR_SET => Some(node),
_ => None,
};
println!(
"validate with={:?} subexpr={:?} invalid={:?}",
node.to_string(),
child.to_string(),
node_if_invalid
);
node_if_invalid
})
.any(|cond| cond != None)
})
.take(1)
.last()
}

pub fn check_files(
nixpkgs_path: &Path,
nix_file_store: &mut NixFileStore,
) -> validation::Result<BTreeMap<RelativePathBuf, ratchet::File>> {
process_nix_files(nixpkgs_path, nix_file_store, |nix_file| {
if let Some(open_scope_with_lib) = find_invalid_withs(nix_file.syntax_root) {
// TODO: what do I return
// return ratchet::RatchetState::Loose(
// npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new(
// nix_file.relative_path,
// )
// .into(),
// );
}
Ok(Success(ratchet::File {}))
})
}
Expand Down

0 comments on commit b0edbd7

Please sign in to comment.