From 3a7ee46cd08586dacaa4618cb38eb740e647c911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Rag=C3=A1ny-N=C3=A9meth?= Date: Tue, 12 Nov 2024 17:09:21 +0100 Subject: [PATCH] [jetbrains_projects] Fix Rider config --- jetbrains_projects/__init__.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/jetbrains_projects/__init__.py b/jetbrains_projects/__init__.py index 39d69f0..670fecf 100644 --- a/jetbrains_projects/__init__.py +++ b/jetbrains_projects/__init__.py @@ -56,11 +56,21 @@ class Editor: config_dir_prefix: str binary: str - def __init__(self, name: str, icon: Path, config_dir_prefix: str, binaries: list[str]): + # Rider calls recentProjects.xml -> recentSolutions.xml and in it RecentProjectsManager -> RiderRecentProjectsManager + is_rider: bool + + def __init__( + self, + name: str, + icon: Path, + config_dir_prefix: str, + binaries: list[str], + is_rider = False): self.name = name self.icon = icon self.config_dir_prefix = config_dir_prefix self.binary = self._find_binary(binaries) + self.is_rider = is_rider def _find_binary(self, binaries: list[str]) -> Union[str, None]: for binary in binaries: @@ -77,12 +87,19 @@ def list_projects(self) -> list[Project]: if not dirs: return [] latest = sorted(dirs)[-1] - return self._parse_recent_projects(Path(latest) / "options" / "recentProjects.xml") + if not self.is_rider: + recent_projects_xml = "recentProjects.xml" + else: + recent_projects_xml = "recentSolutions.xml" + return self._parse_recent_projects(Path(latest) / "options" / recent_projects_xml) def _parse_recent_projects(self, recent_projects_file: Path) -> list[Project]: try: root = ElementTree.parse(recent_projects_file).getroot() - entries = root.findall(".//component[@name='RecentProjectsManager']//entry[@key]") + if not self.is_rider: + entries = root.findall(".//component[@name='RecentProjectsManager']//entry[@key]") + else: + entries = root.findall(".//component[@name='RiderRecentProjectsManager']//entry[@key]") projects = [] for entry in entries: @@ -172,7 +189,8 @@ def __init__(self): name="Rider", icon=plugin_dir / "icons" / "rider.svg", config_dir_prefix="JetBrains/Rider", - binaries=["rider", "rider-eap"]), + binaries=["rider", "rider-eap"], + is_rider=True), Editor( name="RubyMine", icon=plugin_dir / "icons" / "rubymine.svg",