|
31 | 31 | from ....utils.async_cache import AsyncSimpleLRUCache |
32 | 32 | from ....utils.async_tools import Lock, async_tasking_event, create_sub_task, threaded |
33 | 33 | from ....utils.dataclasses import as_json, from_json |
34 | | -from ....utils.glob_path import iter_files |
| 34 | +from ....utils.glob_path import Pattern, iter_files |
35 | 35 | from ....utils.logging import LoggingDescriptor |
36 | 36 | from ....utils.path import path_is_relative_to |
37 | 37 | from ....utils.uri import Uri |
|
59 | 59 | KeywordDoc, |
60 | 60 | KeywordStore, |
61 | 61 | LibraryDoc, |
62 | | - LibraryType, |
63 | 62 | ModuleSpec, |
64 | 63 | VariablesDoc, |
65 | 64 | complete_library_import, |
@@ -521,6 +520,8 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co |
521 | 520 | / "libdoc" |
522 | 521 | ) |
523 | 522 | self.config = config |
| 523 | + |
| 524 | + self.ignored_libraries_patters = [Pattern(s) for s in config.analysis.cache.ignored_libraries] |
524 | 525 | self._libaries_lock = Lock() |
525 | 526 | self._libaries: OrderedDict[_LibrariesEntryKey, _LibrariesEntry] = OrderedDict() |
526 | 527 | self._resources_lock = Lock() |
@@ -788,7 +789,18 @@ async def get_library_meta( |
788 | 789 | module_spec.submodule_search_locations, |
789 | 790 | False, |
790 | 791 | ) |
| 792 | + |
791 | 793 | if result is not None: |
| 794 | + if any( |
| 795 | + (p.matches(result.name) if result.name is not None else False) |
| 796 | + or (p.matches(result.origin) if result.origin is not None else False) |
| 797 | + for p in self.ignored_libraries_patters |
| 798 | + ): |
| 799 | + self._logger.critical( |
| 800 | + lambda: f"Ignore library {result.name or ''} {result.origin or ''} for caching." # type: ignore |
| 801 | + ) |
| 802 | + return None, import_name |
| 803 | + |
792 | 804 | if result.origin is not None: |
793 | 805 | result.mtimes = {result.origin: Path(result.origin).resolve().stat().st_mtime_ns} |
794 | 806 |
|
@@ -954,7 +966,7 @@ async def _get_libdoc(name: str, args: Tuple[Any, ...], working_dir: str, base_d |
954 | 966 | lambda: f"stdout captured at loading library {name}{repr(args)}:\n{result.stdout}" |
955 | 967 | ) |
956 | 968 | try: |
957 | | - if meta is not None and result.library_type in [LibraryType.CLASS, LibraryType.MODULE]: |
| 969 | + if meta is not None: |
958 | 970 | meta_file = Path(self.lib_doc_cache_path, meta.filepath_base.with_suffix(".meta.json")) |
959 | 971 | meta_file.parent.mkdir(parents=True, exist_ok=True) |
960 | 972 | meta_file.write_text(as_json(meta), "utf-8") |
|
0 commit comments