@@ -18,7 +18,7 @@ use lov::LocalPrefix;
1818use lsp_core:: {
1919 feature:: diagnostics:: publish_diagnostics,
2020 lang:: { Lang , LangHelper } ,
21- lsp_types:: { SemanticTokenType , Url } ,
21+ lsp_types:: { SemanticTokenType , TextDocumentItem , Url } ,
2222 prelude:: * ,
2323 CreateEvent ,
2424} ;
@@ -73,7 +73,10 @@ pub fn setup_world<C: Client + ClientSync + Resource + Clone>(world: &mut World)
7373 } ) ;
7474
7575 world. schedule_scope ( lsp_core:: Startup , |_, schedule| {
76- schedule. add_systems ( extract_known_prefixes_from_config :: < C > ) ;
76+ schedule. add_systems ( (
77+ extract_known_prefixes_from_config :: < C > ,
78+ extract_known_shapes_from_config :: < C > ,
79+ ) ) ;
7780 } ) ;
7881
7982 setup_parsing ( world) ;
@@ -248,6 +251,71 @@ fn prefix_from_source(url: &Url, source: &str) -> Option<(Cow<'static, str>, Cow
248251 prefix_from_declaration ( & triples) . or_else ( || prefix_from_prefixes ( & turtle, & triples) )
249252}
250253
254+ pub fn extract_known_shapes_from_config < C : Client + ClientSync + Resource + Clone > (
255+ config : Res < ServerConfig > ,
256+ client : Res < C > ,
257+ fs : Res < Fs > ,
258+ sender : Res < CommandSender > ,
259+ ) {
260+ for on in config. config . local . shapes . iter ( ) . cloned ( ) {
261+ let c = client. clone ( ) ;
262+ let fs = fs. clone ( ) ;
263+
264+ let sender = sender. 0 . clone ( ) ;
265+
266+ let fut = async move {
267+ let Some ( files) = find ( & on, & fs, & c) . await else {
268+ return ;
269+ } ;
270+
271+ for ( content, url) in files {
272+ let mut command_queue = CommandQueue :: default ( ) ;
273+ let item = TextDocumentItem {
274+ version : 1 ,
275+ uri : url. clone ( ) ,
276+ language_id : String :: from ( "turtle" ) ,
277+ text : String :: new ( ) ,
278+ } ;
279+
280+ let spawn = spawn_or_insert (
281+ url. clone ( ) ,
282+ (
283+ RopeC ( ropey:: Rope :: from_str ( & content) ) ,
284+ Source ( content. clone ( ) ) ,
285+ Label ( url. clone ( ) ) , // this might crash
286+ Wrapped ( item) ,
287+ Types ( HashMap :: new ( ) ) ,
288+ ) ,
289+ Some ( "turtle" . into ( ) ) ,
290+ ( Global , ) ,
291+ ) ;
292+
293+ command_queue. push ( move |world : & mut World | {
294+ let span = tracing:: span!( tracing:: Level :: INFO , "span shapes" ) ;
295+ let _enter = span. enter ( ) ;
296+ spawn ( world) ;
297+ world. run_schedule ( ParseLabel ) ;
298+ } ) ;
299+
300+ let _ = sender. unbounded_send ( command_queue) ;
301+ }
302+
303+ // This is the plan of approach: - add these ontologies to the predefined LOV things - need prefered prefix:
304+ // - filename.ttl -> filename
305+ // - parse and look for things?
306+ // - let the lov things also add prefixes to the prefix thing
307+ // - Profit
308+
309+ // spawn_or_insert(url, bundle, language_id, extra)
310+ // we have the turtle files!
311+ // we have 2 choices now:
312+ // add it to the ecs without links
313+ } ;
314+
315+ client. spawn ( fut) ;
316+ }
317+ }
318+
251319pub fn extract_known_prefixes_from_config < C : Client + ClientSync + Resource + Clone > (
252320 config : Res < ServerConfig > ,
253321 client : Res < C > ,
0 commit comments