Skip to content

Commit

Permalink
- r extract method
Browse files Browse the repository at this point in the history
Co-Authored-By: Llewellyn Falco <[email protected]>
Co-Authored-By: ssilverx <[email protected]>
Co-Authored-By: ollin <[email protected]>
  • Loading branch information
4 people committed Oct 16, 2023
1 parent 3e25d70 commit 33545a5
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ public static DiffInfo findIt()
}
public static DiffInfo getDiffInfo(String userHome, Function1<String, Boolean> fileExists)
{
Queryable<String> list = Queryable.as("IntelliJ IDEA Ultimate", "IntelliJ IDEA", "IntelliJ IDEA Community",
Queryable<String> locations = Queryable.as("IntelliJ IDEA Ultimate", "IntelliJ IDEA", "IntelliJ IDEA Community",
"IntelliJ IDEA Community Edition");
Queryable<String> applications = Queryable.as("/Applications", userHome + "/Applications");
String matching = applications.selectMany(a -> list.select(l -> a + "/" + l + ".app/Contents/MacOS/idea"))
.first(fileExists);
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
String postfix = ".app/Contents/MacOS/idea";
return getDiffInfo(fileExists, applications, locations, postfix);
}

public static DiffInfo getDiffInfoLinux(String userHome, Function1<String, Boolean> fileExists)
{
Queryable<String> list = Queryable.as("intellij-idea-ultimate");
Queryable<String> locations = Queryable.as("intellij-idea-ultimate");
Queryable<String> applications = Queryable.as( userHome + "/.local/share/JetBrains/Toolbox/apps");
Queryable<String> paths = applications.selectMany(a -> list.select(l -> a + "/" + l + "/bin/idea.sh"));
String postfix = "/bin/idea.sh";
return getDiffInfo(fileExists, applications, locations, postfix);
}

private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations, Queryable<String> list, String postfix) {
Queryable<String> paths = locations.selectMany(a -> list.select(l -> a + "/" + l + postfix));
String matching = paths.first(fileExists);
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
}
Expand Down

0 comments on commit 33545a5

Please sign in to comment.