@@ -635,30 +635,51 @@ async def imports_changed(self, sender: Any, uri: DocumentUri) -> None: # NOSON
635635
636636 @_logger .call
637637 async def libraries_changed (self , sender : Any , libraries : List [LibraryDoc ]) -> None :
638- for p in libraries :
639- if any (e for e in self ._libraries .values () if e .library_doc == p ):
640- if self .document is not None :
641- self .document .set_data (Namespace .DataEntry , None )
642- await self .invalidate ()
643- break
638+ invalidate = False
639+
640+ async with self ._initialize_lock , self ._library_doc_lock , self ._analyze_lock :
641+ for p in libraries :
642+ if any (e for e in self ._libraries .values () if e .library_doc == p ):
643+ invalidate = True
644+ break
645+
646+ if invalidate :
647+ if self .document is not None :
648+ self .document .set_data (Namespace .DataEntry , None )
649+
650+ await self .invalidate ()
644651
645652 @_logger .call
646653 async def resources_changed (self , sender : Any , resources : List [LibraryDoc ]) -> None :
647- for p in resources :
648- if any (e for e in self ._resources .values () if e .library_doc .source == p .source ):
649- if self .document is not None :
650- self .document .set_data (Namespace .DataEntry , None )
651- await self .invalidate ()
652- break
654+ invalidate = False
655+
656+ async with self ._initialize_lock , self ._library_doc_lock , self ._analyze_lock :
657+ for p in resources :
658+ if any (e for e in self ._resources .values () if e .library_doc .source == p .source ):
659+ invalidate = True
660+ break
661+
662+ if invalidate :
663+ if self .document is not None :
664+ self .document .set_data (Namespace .DataEntry , None )
665+
666+ await self .invalidate ()
653667
654668 @_logger .call
655669 async def variables_changed (self , sender : Any , variables : List [LibraryDoc ]) -> None :
656- for p in variables :
657- if any (e for e in self ._variables .values () if e .library_doc .source == p .source ):
658- if self .document is not None :
659- self .document .set_data (Namespace .DataEntry , None )
660- await self .invalidate ()
661- break
670+ invalidate = False
671+
672+ async with self ._initialize_lock , self ._library_doc_lock , self ._analyze_lock :
673+ for p in variables :
674+ if any (e for e in self ._variables .values () if e .library_doc .source == p .source ):
675+ invalidate = True
676+ break
677+
678+ if invalidate :
679+ if self .document is not None :
680+ self .document .set_data (Namespace .DataEntry , None )
681+
682+ await self .invalidate ()
662683
663684 async def is_initialized (self ) -> bool :
664685 async with self ._initialize_lock :
@@ -753,7 +774,7 @@ async def get_imported_variables(self) -> OrderedDict[str, VariablesEntry]:
753774 async def get_library_doc (self ) -> LibraryDoc :
754775 async with self ._library_doc_lock :
755776 if self ._library_doc is None :
756- self ._library_doc = await self .imports_manager .get_libdoc_from_model (
777+ self ._library_doc = self .imports_manager .get_libdoc_from_model (
757778 self .model ,
758779 self .source ,
759780 model_type = "RESOURCE" ,
0 commit comments