Skip to content

Commit 41fba0e

Browse files
author
Kirill Asyamolov
committed
support paths for Idea 20.x and above preferences
1 parent dddfd26 commit 41fba0e

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/hxmake/idea/IdeaContext.hx

+28-6
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,28 @@ class IdeaContext {
9595

9696
static function findLatestPreferences():Array<String> {
9797
var result = [];
98-
var prefsPath = getUserPreferencesPath();
99-
var ideaPathName = CL.platform.isMac ? "IntelliJIdea" : ".IntelliJIdea";
100-
var versions = getVersions();
10198

102-
MakeLog.trace('Search IntelliJ IDEA Preferences in: $prefsPath');
99+
// check versions 20.x and above
100+
var prefsPath = Path.join([getUserAppDataPath(), "JetBrains"]);
101+
var ideaPathName = "IntelliJIdea";
102+
var versions = getVersions(20, 21);
103+
104+
MakeLog.trace('Search IntelliJ IDEA 20.x Preferences in: $prefsPath');
105+
106+
versions.reverse();
107+
for (version in versions) {
108+
var path = Path.join([prefsPath, ideaPathName + version]);
109+
if (vefiryPreferencesPath(path)) {
110+
result.push(path);
111+
}
112+
}
113+
114+
// check versions 19.x and below
115+
prefsPath = getUserPreferencesPath();
116+
ideaPathName = CL.platform.isMac ? "IntelliJIdea" : ".IntelliJIdea";
117+
versions = getVersions(16, 19);
118+
119+
MakeLog.trace('Search IntelliJ IDEA 19.x Preferences in: $prefsPath');
103120

104121
versions.reverse();
105122
for (version in versions) {
@@ -122,14 +139,19 @@ class IdeaContext {
122139
return Path.join([path, "options", "jdk.table.xml"]);
123140
}
124141

142+
static function getUserAppDataPath():String {
143+
var userHome = CL.getUserHome();
144+
return CL.platform.isMac ? Path.join([userHome, "Application Support"]) : Path.join([userHome, "AppData", "Roaming"]);
145+
}
146+
125147
static function getUserPreferencesPath():String {
126148
var userHome = CL.getUserHome();
127149
return CL.platform.isMac ? Path.join([userHome, "Library", "Preferences"]) : userHome;
128150
}
129151

130-
static function getVersions():Array<String> {
152+
static function getVersions(from:Int, to:Int):Array<String> {
131153
var result = [];
132-
for (major in 16...20) {
154+
for (major in from...to) {
133155
result.push('20$major');
134156
for (minor in 1...10) {
135157
result.push('20$major.$minor');

0 commit comments

Comments
 (0)