1
+ use crate :: problem:: npv_169;
1
2
use crate :: problem:: npv_170;
2
3
use relative_path:: RelativePath ;
3
4
use relative_path:: RelativePathBuf ;
@@ -10,11 +11,50 @@ use crate::validation::ResultIteratorExt;
10
11
use crate :: validation:: Validation :: Success ;
11
12
use crate :: { nix_file, ratchet, structure, validation} ;
12
13
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
+
13
44
pub fn check_files (
14
45
nixpkgs_path : & Path ,
15
46
nix_file_store : & mut NixFileStore ,
16
47
) -> validation:: Result < BTreeMap < RelativePathBuf , ratchet:: File > > {
17
48
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
+ }
18
58
Ok ( Success ( ratchet:: File { } ) )
19
59
} )
20
60
}
0 commit comments