@@ -149,25 +149,24 @@ impl MinecraftShaderLanguageServer {
149
149
150
150
Some ( entry. into_path ( ) )
151
151
} ) . 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
154
154
self . add_file_and_includes_to_graph ( & path) ;
155
155
} ) ;
156
156
157
157
eprintln ! ( "finished building project include graph" ) ;
158
- //std::thread::sleep(std::time::Duration::from_secs(1));
159
158
}
160
159
161
160
fn add_file_and_includes_to_graph ( & self , path : & PathBuf ) {
162
161
let includes = self . find_includes ( path) ;
163
162
164
163
let idx = self . graph . borrow_mut ( ) . add_node ( & path) ;
165
164
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) ;
170
168
}
169
+ }
171
170
172
171
fn add_include ( & self , include : ( PathBuf , IncludePosition ) , node : NodeIndex ) {
173
172
let child = self . graph . borrow_mut ( ) . add_node ( & include. 0 ) ;
@@ -191,17 +190,19 @@ impl MinecraftShaderLanguageServer {
191
190
. unwrap ( )
192
191
. get ( 1 )
193
192
. unwrap ( ) ;
194
- //eprintln!("{:?}", caps);
195
193
196
194
let start = cap. start ( ) ;
197
195
let end = cap. end ( ) ;
198
196
let mut path: String = cap. as_str ( ) . into ( ) ;
199
197
200
198
// TODO: difference between / and not
201
- if path. starts_with ( '/' ) {
199
+ let full_include = if path. starts_with ( '/' ) {
202
200
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
+
205
206
includes. push ( (
206
207
full_include,
207
208
IncludePosition {
@@ -210,7 +211,6 @@ impl MinecraftShaderLanguageServer {
210
211
end,
211
212
}
212
213
) ) ;
213
- //eprintln!("{} includes {}", file, full_include);
214
214
} ) ;
215
215
216
216
includes
@@ -219,6 +219,8 @@ impl MinecraftShaderLanguageServer {
219
219
fn update_includes ( & self , file : & PathBuf ) {
220
220
let includes = self . find_includes ( file) ;
221
221
222
+ eprintln ! ( "updating {:?} with {:?}" , file, includes) ;
223
+
222
224
let idx = match self . graph . borrow_mut ( ) . find_node ( & file) {
223
225
None => {
224
226
return
@@ -232,6 +234,8 @@ impl MinecraftShaderLanguageServer {
232
234
let to_be_added = new_children. difference ( & prev_children) ;
233
235
let to_be_removed = prev_children. difference ( & new_children) ;
234
236
237
+ eprintln ! ( "removing:\n \t {:?}\n adding:\n \t {:?}" , to_be_removed, to_be_added) ;
238
+
235
239
for removal in to_be_removed {
236
240
let child = self . graph . borrow_mut ( ) . find_node ( & removal. 0 ) . unwrap ( ) ;
237
241
self . graph . borrow_mut ( ) . remove_edge ( idx, child) ;
@@ -367,7 +371,7 @@ impl MinecraftShaderLanguageServer {
367
371
368
372
eprintln ! ( "match {:?}" , diagnostic_capture) ;
369
373
370
- let msg = diagnostic_capture. name ( "output" ) . unwrap ( ) . as_str ( ) ; //.replace("'' : ", "");
374
+ let msg = diagnostic_capture. name ( "output" ) . unwrap ( ) . as_str ( ) ;
371
375
372
376
let line = match diagnostic_capture. name ( "linenum" ) {
373
377
Some ( c) => match c. as_str ( ) . parse :: < u32 > ( ) {
0 commit comments