@@ -149,25 +149,24 @@ impl MinecraftShaderLanguageServer {
149149
150150 Some ( entry. into_path ( ) )
151151 } ) . for_each ( |path| {
152- // iterate all valid found files, search for includes, add a node into the graph for each
153- // file and add a file->includes KV into the map
152+ // iterate all valid found files, search for includes, add a node into the graph for each
153+ // file and add a file->includes KV into the map
154154 self . add_file_and_includes_to_graph ( & path) ;
155155 } ) ;
156156
157157 eprintln ! ( "finished building project include graph" ) ;
158- //std::thread::sleep(std::time::Duration::from_secs(1));
159158 }
160159
161160 fn add_file_and_includes_to_graph ( & self , path : & PathBuf ) {
162161 let includes = self . find_includes ( path) ;
163162
164163 let idx = self . graph . borrow_mut ( ) . add_node ( & path) ;
165164
166- //eprintln!("adding {} with\n{:?}", path.clone(), includes);
167- for include in includes {
168- self . add_include ( include, idx) ;
169- }
165+ //eprintln!("adding {:?} with {:?}", path, includes);
166+ for include in includes {
167+ self . add_include ( include, idx) ;
170168 }
169+ }
171170
172171 fn add_include ( & self , include : ( PathBuf , IncludePosition ) , node : NodeIndex ) {
173172 let child = self . graph . borrow_mut ( ) . add_node ( & include. 0 ) ;
@@ -191,17 +190,19 @@ impl MinecraftShaderLanguageServer {
191190 . unwrap ( )
192191 . get ( 1 )
193192 . unwrap ( ) ;
194- //eprintln!("{:?}", caps);
195193
196194 let start = cap. start ( ) ;
197195 let end = cap. end ( ) ;
198196 let mut path: String = cap. as_str ( ) . into ( ) ;
199197
200198 // TODO: difference between / and not
201- if path. starts_with ( '/' ) {
199+ let full_include = if path. starts_with ( '/' ) {
202200 path = path. strip_prefix ( '/' ) . unwrap ( ) . to_string ( ) ;
203- }
204- let full_include = self . root . join ( "shaders" ) . join ( PathBuf :: from_slash ( & path) ) ;
201+ self . root . join ( "shaders" ) . join ( PathBuf :: from_slash ( & path) )
202+ } else {
203+ file. parent ( ) . unwrap ( ) . join ( PathBuf :: from_slash ( & path) )
204+ } ;
205+
205206 includes. push ( (
206207 full_include,
207208 IncludePosition {
@@ -210,7 +211,6 @@ impl MinecraftShaderLanguageServer {
210211 end,
211212 }
212213 ) ) ;
213- //eprintln!("{} includes {}", file, full_include);
214214 } ) ;
215215
216216 includes
@@ -219,6 +219,8 @@ impl MinecraftShaderLanguageServer {
219219 fn update_includes ( & self , file : & PathBuf ) {
220220 let includes = self . find_includes ( file) ;
221221
222+ eprintln ! ( "updating {:?} with {:?}" , file, includes) ;
223+
222224 let idx = match self . graph . borrow_mut ( ) . find_node ( & file) {
223225 None => {
224226 return
@@ -232,6 +234,8 @@ impl MinecraftShaderLanguageServer {
232234 let to_be_added = new_children. difference ( & prev_children) ;
233235 let to_be_removed = prev_children. difference ( & new_children) ;
234236
237+ eprintln ! ( "removing:\n \t {:?}\n adding:\n \t {:?}" , to_be_removed, to_be_added) ;
238+
235239 for removal in to_be_removed {
236240 let child = self . graph . borrow_mut ( ) . find_node ( & removal. 0 ) . unwrap ( ) ;
237241 self . graph . borrow_mut ( ) . remove_edge ( idx, child) ;
@@ -367,7 +371,7 @@ impl MinecraftShaderLanguageServer {
367371
368372 eprintln ! ( "match {:?}" , diagnostic_capture) ;
369373
370- let msg = diagnostic_capture. name ( "output" ) . unwrap ( ) . as_str ( ) ; //.replace("'' : ", "");
374+ let msg = diagnostic_capture. name ( "output" ) . unwrap ( ) . as_str ( ) ;
371375
372376 let line = match diagnostic_capture. name ( "linenum" ) {
373377 Some ( c) => match c. as_str ( ) . parse :: < u32 > ( ) {
0 commit comments