|
4 | 4 | import asyncio |
5 | 5 | import itertools |
6 | 6 | import os |
| 7 | +import shutil |
7 | 8 | import sys |
8 | 9 | import weakref |
9 | 10 | import zlib |
@@ -503,9 +504,10 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co |
503 | 504 |
|
504 | 505 | self._logger.trace(lambda: f"use {cache_base_path} as base for caching") |
505 | 506 |
|
| 507 | + self.cache_path = cache_base_path / ".robotcode_cache" |
| 508 | + |
506 | 509 | self.lib_doc_cache_path = ( |
507 | | - cache_base_path |
508 | | - / ".robotcode_cache" |
| 510 | + self.cache_path |
509 | 511 | / f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" |
510 | 512 | / get_robot_version_str() |
511 | 513 | / "libdoc" |
@@ -534,6 +536,11 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co |
534 | 536 | def environment(self) -> Mapping[str, str]: |
535 | 537 | return self._environment |
536 | 538 |
|
| 539 | + def clear_cache(self) -> None: |
| 540 | + if self.cache_path.exists(): |
| 541 | + shutil.rmtree(self.cache_path) |
| 542 | + self._logger.debug(f"Cleared cache {self.cache_path}") |
| 543 | + |
537 | 544 | @_logger.call |
538 | 545 | async def get_command_line_variables(self) -> List[VariableDefinition]: |
539 | 546 | from robot.utils.text import split_args_from_name_or_path |
@@ -940,7 +947,7 @@ async def _get_libdoc() -> LibraryDoc: |
940 | 947 | spec_file = Path(self.lib_doc_cache_path, meta.filepath_base.with_suffix(".spec.json")) |
941 | 948 | spec_file.write_text(as_json(result), "utf-8") |
942 | 949 | else: |
943 | | - self._logger.debug(lambda: f"Skip caching library {name}{args:r}") |
| 950 | + self._logger.debug(lambda: f"Skip caching library {name}{repr(args)}") |
944 | 951 | except (SystemExit, KeyboardInterrupt): |
945 | 952 | raise |
946 | 953 | except BaseException as e: |
|
0 commit comments