Skip to content

Commit

Permalink
! F IntelliJ Toolbox Windows
Browse files Browse the repository at this point in the history
Co-Authored-By: Llewellyn Falco <[email protected]>
  • Loading branch information
LarsEckart and isidore committed Oct 23, 2023
1 parent 50ee100 commit 4023584
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static String[] getProgramFilesPaths()
paths.add(System.getenv("ProgramFiles(x86)"));
paths.add(System.getenv("ProgramFiles"));
paths.add(System.getenv("ProgramW6432"));
paths.add(System.getenv("LOCALAPPDATA") + "\\Programs");
return paths.stream().filter(Objects::nonNull).toArray(String[]::new);
}
public static class One
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static DiffInfo findIt()
if (!diffInfo.isEmpty())
{ return diffInfo; }
}
DiffInfo diffInfo = getDiffInfoWindows(DiffInfo.getProgramFilesPaths(), f -> new File(f).exists());
if (!diffInfo.isEmpty())
{ return diffInfo; }
return DiffInfo.getNull();
}
public static DiffInfo getDiffInfoMac(String userHome, Function1<String, Boolean> fileExists)
Expand All @@ -31,28 +34,26 @@ public static DiffInfo getDiffInfoMac(String userHome, Function1<String, Boolean
"IntelliJ IDEA Community Edition");
Queryable<String> applications = as("/Applications", userHome + "/Applications");
String postfix = ".app/Contents/MacOS/idea";
return getDiffInfo(fileExists, applications, locations, postfix);
return getDiffInfo(fileExists, applications, locations, postfix, "/");
}
public static DiffInfo getDiffInfoLinux(String userHome, Function1<String, Boolean> fileExists)
{
Queryable<String> locations = as("intellij-idea-ultimate", "intellij-idea-community-edition");
Queryable<String> applications = as(userHome + "/.local/share/JetBrains/Toolbox/apps");
String postfix = "/bin/idea.sh";
return getDiffInfo(fileExists, applications, locations, postfix);
}
private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations,
Queryable<String> applications, String postfix)
{
Queryable<String> paths = locations.selectMany(a -> applications.select(l -> a + "/" + l + postfix));
String matching = paths.first(fileExists);
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
return getDiffInfo(fileExists, applications, locations, postfix, "/");
}
public static DiffInfo getDiffInfoWindows(String[] programFiles, Function1<String, Boolean> fileExists) {
Queryable<String> applications = as("IntelliJ IDEA Ultimate", "IntelliJ IDEA", "IntelliJ IDEA Community",
"IntelliJ IDEA Community Edition");
Queryable<String> locations = Queryable.as(programFiles);
String postfix = "\\bin\\idea64.exe";
Queryable<String> paths = locations.selectMany(l -> applications.select(a -> l + "\\" + a + postfix));
return getDiffInfo(fileExists, locations, applications, postfix, "\\");
}
private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations,
Queryable<String> applications, String postfix, String pathSeparator)
{
Queryable<String> paths = locations.selectMany(l -> applications.select(a -> l + pathSeparator + a + postfix));
String matching = paths.first(fileExists);
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
}
Expand Down

0 comments on commit 4023584

Please sign in to comment.