(cls)
| 25 | |
| 26 | @classmethod |
| 27 | def initialize(cls) -> None: |
| 28 | c_sharp_library_path = cls._c_sharp_library_path() |
| 29 | if not os.path.exists(c_sharp_library_path): |
| 30 | c_sharp_library_folder_path = os.path.dirname(c_sharp_library_path) |
| 31 | log.debug(f"C# library not found at '{c_sharp_library_path}', building...") |
| 32 | |
| 33 | tree_sitter_csharp_folder_path = os.path.join(unifree.project_root, 'vendor', 'tree-sitter-c-sharp') |
| 34 | if not os.path.exists(tree_sitter_csharp_folder_path): |
| 35 | log.error(f"CSharp implementation of the tree sitter is not found at {tree_sitter_csharp_folder_path}") |
| 36 | raise RuntimeError(f"CSharp tree sitter not found in {tree_sitter_csharp_folder_path}") |
| 37 | |
| 38 | os.makedirs(c_sharp_library_folder_path, exist_ok=True) |
| 39 | tree_sitter.Language.build_library(c_sharp_library_path, [tree_sitter_csharp_folder_path]) |
| 40 | |
| 41 | def parse(self, file_path: str) -> tree_sitter.Tree: |
| 42 | if not os.path.exists(file_path) or not os.path.isfile(file_path): |
no test coverage detected