Skip to content

Commit eb8ae04

Browse files
committed
checkpoint
Signed-off-by: lucasew <lucas59356@gmail.com>
1 parent 43e090c commit eb8ae04

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

src/references.rs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::ffi::OsStr;
2+
use std::hash::Hash;
23
use std::path::Path;
34

45
use anyhow::Context;
@@ -7,7 +8,7 @@ use rnix::SyntaxNode;
78
use rowan::ast::AstNode;
89

910
use crate::nix_file::{NixFile, ResolvedPath};
10-
use crate::problem::{npv_121, npv_122, npv_123, npv_124, npv_125, npv_126};
11+
use crate::problem::{npv_121, npv_122, npv_123, npv_124, npv_125, npv_126, npv_169};
1112
use crate::structure::read_dir_sorted;
1213
use crate::validation::{self, ResultIteratorExt, Validation::Success};
1314
use crate::NixFileStore;
@@ -113,7 +114,7 @@ fn check_path(
113114
}
114115

115116
fn check_nix_path(
116-
node: SyntaxNode,
117+
node: &SyntaxNode,
117118
nix_file: &NixFile,
118119
relative_package_dir: &RelativePath,
119120
absolute_package_dir: &Path,
@@ -122,7 +123,7 @@ fn check_nix_path(
122123
let line = nix_file.line_index.line(node.text_range().start().into());
123124
let text = node.text().to_string();
124125
// We're only interested in Path expressions
125-
let Some(path) = rnix::ast::Path::cast(node) else {
126+
let Some(path) = rnix::ast::Path::cast(node.clone()) else {
126127
return Success(());
127128
};
128129

@@ -160,6 +161,26 @@ fn check_nix_path(
160161
}
161162
}
162163
}
164+
fn check_nix_with(
165+
node: &SyntaxNode,
166+
nix_file: &NixFile,
167+
_relative_package_dir: &RelativePath,
168+
_absolute_package_dir: &Path,
169+
subpath: &RelativePath,
170+
) -> validation::Validation<()> {
171+
let _line = nix_file.line_index.line(node.text_range().start().into());
172+
let _text = node.text().to_string();
173+
// We're only interested in Path expressions
174+
let Some(with) = rnix::ast::With::cast(node.clone()) else {
175+
return Success(());
176+
};
177+
// let Some(with_body) = with.body() else {
178+
// return Success(());
179+
// };
180+
// println!("{}", with_body.syntax());
181+
182+
npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new(subpath).into()
183+
}
163184

164185
/// Check whether a Nix file contains path expression references pointing outside the package
165186
/// directory.
@@ -176,7 +197,17 @@ fn check_nix_file(
176197
Ok(validation::sequence_(
177198
nix_file.syntax_root.syntax().descendants().map(|node| {
178199
match check_nix_path(
179-
node,
200+
&node,
201+
nix_file,
202+
relative_package_dir,
203+
absolute_package_dir,
204+
subpath,
205+
) {
206+
Success(()) => Success(()),
207+
value => return value,
208+
};
209+
match check_nix_with(
210+
&node,
180211
nix_file,
181212
relative_package_dir,
182213
absolute_package_dir,

0 commit comments

Comments
 (0)