File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed
Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,10 @@ impl DesignRoot {
331331 FindAllReferences :: search ( self , ent)
332332 }
333333
334+ pub fn find_all_unresolved ( & self ) -> ( usize , Vec < SrcPos > ) {
335+ FindAllUnresolved :: search ( self )
336+ }
337+
334338 #[ cfg( test) ]
335339 pub fn find_all_references_pos ( & self , decl_pos : & SrcPos ) -> Vec < SrcPos > {
336340 if let Some ( ent) = ItemAtCursor :: search ( self , decl_pos. source ( ) , decl_pos. start ( ) ) {
Original file line number Diff line number Diff line change @@ -1471,3 +1471,29 @@ impl std::fmt::Display for FoundDeclaration<'_> {
14711471 }
14721472 }
14731473}
1474+
1475+ pub struct FindAllUnresolved {
1476+ pub count : usize ,
1477+ pub unresolved : Vec < SrcPos > ,
1478+ }
1479+
1480+ impl Searcher for FindAllUnresolved {
1481+ fn search_pos_with_ref ( & mut self , pos : & SrcPos , reference : & Reference ) -> SearchState {
1482+ self . count += 1 ;
1483+ if reference. is_none ( ) {
1484+ self . unresolved . push ( pos. clone ( ) ) ;
1485+ }
1486+ NotFinished
1487+ }
1488+ }
1489+
1490+ impl FindAllUnresolved {
1491+ pub fn search ( searchable : & impl Search ) -> ( usize , Vec < SrcPos > ) {
1492+ let mut searcher = Self {
1493+ count : 0 ,
1494+ unresolved : Default :: default ( ) ,
1495+ } ;
1496+ let _ = searchable. search ( & mut searcher) ;
1497+ ( searcher. count , searcher. unresolved )
1498+ }
1499+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ struct Args {
2929 /// Config file in TOML format containing libraries and settings
3030 #[ arg( short, long) ]
3131 config : String ,
32+
33+ /// Dump items that are not resolved into an unique reference
34+ /// This is used for development to test where the language server is blind
35+ #[ arg( long) ]
36+ dump_unresolved : bool ,
3237}
3338
3439fn main ( ) {
@@ -72,6 +77,14 @@ fn main() {
7277 ) ;
7378 }
7479
80+ if args. dump_unresolved {
81+ let ( total, unresolved) = project. find_all_unresolved ( ) ;
82+ for pos in unresolved. iter ( ) {
83+ println ! ( "{}" , pos. show( "Unresolved" ) ) ;
84+ }
85+ println ! ( "{} out of {} positions unresolved" , unresolved. len( ) , total) ;
86+ }
87+
7588 // Exit without running Drop on entire allocated AST
7689 std:: process:: exit ( 0 ) ;
7790}
Original file line number Diff line number Diff line change @@ -237,6 +237,12 @@ impl Project {
237237 self . root . find_all_references ( ent)
238238 }
239239
240+ /// Get source positions that are not resolved to a declaration
241+ /// This is used for development to test where the language server is blind
242+ pub fn find_all_unresolved ( & self ) -> ( usize , Vec < SrcPos > ) {
243+ self . root . find_all_unresolved ( )
244+ }
245+
240246 pub fn files ( & self ) -> impl Iterator < Item = & SourceFile > {
241247 self . files . values ( )
242248 }
You can’t perform that action at this time.
0 commit comments