Skip to content

Commit

Permalink
! F Adding IntelliJ Toolbox Windows support
Browse files Browse the repository at this point in the history
Co-Authored-By: Llewellyn Falco <llewellyn.falco@gmail.com>
  • Loading branch information
LarsEckart and isidore committed Oct 23, 2023
1 parent ce041e3 commit 50ee100
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ void testFindItOnLinux() {
"/home/lars/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/bin/idea.sh");
verifyPaths(IntelliJToolboxResolver::getDiffInfoLinux, "/home/lars", validPaths);
}

// "C:\Users\larse\AppData\Local\Programs\IntelliJ IDEA Ultimate\bin\idea64.exe"
@Test
void testFindItOnWindows() {
Queryable<String> validPaths = Queryable.as(
"C:\\Users\\larse\\AppData\\Local\\Programs\\IntelliJ IDEA Ultimate\\bin\\idea64.exe");
String[] programFiles = {"C:\\Users\\larse\\AppData\\Local\\Programs"};
for (String path : validPaths) {
DiffInfo diffInfo = IntelliJToolboxResolver.getDiffInfoWindows(programFiles, f -> f.equals(path));
assertNotEquals("", diffInfo.diffProgram, path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class IntelliJToolboxResolver
{
private interface Resolver extends Function2<String, Function1<String, Boolean>, DiffInfo>
{

}
public static DiffInfo findIt()
{
Expand Down Expand Up @@ -40,9 +41,18 @@ public static DiffInfo getDiffInfoLinux(String userHome, Function1<String, Boole
return getDiffInfo(fileExists, applications, locations, postfix);
}
private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations,
Queryable<String> list, String postfix)
Queryable<String> applications, String postfix)
{
Queryable<String> paths = locations.selectMany(a -> list.select(l -> a + "/" + l + 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);
}
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));
String matching = paths.first(fileExists);
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
}
Expand Down

0 comments on commit 50ee100

Please sign in to comment.