use of com.intellij.openapi.util.Version in project intellij-elixir by KronicDeth.
the class ElixirSdkType method homePathByVersion.
/**
* Map of home paths to versions in descending version order so that newer versions are favored.
*
* @return Map
*/
private Map<Version, String> homePathByVersion() {
Map<Version, String> homePathByVersion = new TreeMap<Version, String>(new Comparator<Version>() {
@Override
public int compare(Version version1, Version version2) {
// compare version2 to version1 to produce descending instead of ascending order.
return version2.compareTo(version1);
}
});
if (SystemInfo.isMac) {
File homebrewRoot = new File("/usr/local/Cellar/elixir");
if (homebrewRoot.isDirectory()) {
File[] files = homebrewRoot.listFiles();
if (files != null) {
for (File child : files) {
if (child.isDirectory()) {
String versionString = child.getName();
String[] versionParts = versionString.split("\\.", 3);
int major = Integer.parseInt(versionParts[0]);
int minor = Integer.parseInt(versionParts[1]);
int bugfix = Integer.parseInt(versionParts[2]);
Version version = new Version(major, minor, bugfix);
homePathByVersion.put(version, child.getAbsolutePath());
}
}
}
}
} else {
Version version = new Version(0, 0, 0);
String sdkPath = "";
if (SystemInfo.isWindows) {
if (SystemInfo.is32Bit) {
sdkPath = "C:\\Program Files\\Elixir";
} else {
sdkPath = "C:\\Program Files (x86)\\Elixir";
}
} else if (SystemInfo.isLinux) {
sdkPath = "/usr/local/lib/elixir";
}
homePathByVersion.put(version, sdkPath);
}
return homePathByVersion;
}
use of com.intellij.openapi.util.Version in project intellij-elixir by KronicDeth.
the class SdkType method homePathByVersion.
/*
* Private
*/
/**
* Map of home paths to versions in descending version order so that newer versions are favored.
*
* @return
*/
private Map<Version, String> homePathByVersion() {
Map<Version, String> homePathByVersion = new TreeMap<Version, String>(new Comparator<Version>() {
@Override
public int compare(Version version1, Version version2) {
// compare version2 to version1 to produce descending instead of ascending order.
return version2.compareTo(version1);
}
});
if (SystemInfo.isMac) {
File homebrewRoot = new File("/usr/local/Cellar/elixir");
if (homebrewRoot.isDirectory()) {
//noinspection ConstantConditions
for (File child : homebrewRoot.listFiles()) {
if (child.isDirectory()) {
String versionString = child.getName();
String[] versionParts = versionString.split("\\.", 3);
int major = Integer.parseInt(versionParts[0]);
int minor = Integer.parseInt(versionParts[1]);
int bugfix = Integer.parseInt(versionParts[2]);
Version version = new Version(major, minor, bugfix);
homePathByVersion.put(version, child.getAbsolutePath());
}
}
}
}
return homePathByVersion;
}
use of com.intellij.openapi.util.Version in project flutter-intellij by flutter.
the class IncompatibleDartPluginNotificationProvider method createNotificationPanel.
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!FlutterUtils.isFlutteryFile(file))
return null;
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile == null)
return null;
if (psiFile.getLanguage() != DartLanguage.INSTANCE)
return null;
final Module module = ModuleUtilCore.findModuleForPsiElement(psiFile);
if (module == null)
return null;
if (!FlutterModuleUtils.isFlutterModule(module))
return null;
final Version minimumVersion = DartPlugin.getInstance().getMinimumVersion();
final Version dartVersion = DartPlugin.getInstance().getVersion();
if (dartVersion.minor == 0 && dartVersion.bugfix == 0) {
// Running from sources.
return null;
}
return dartVersion.compareTo(minimumVersion) < 0 ? createUpdateDartPanel(myProject, module, dartVersion.toCompactString(), getPrintableRequiredDartVersion()) : null;
}
use of com.intellij.openapi.util.Version in project intellij-elixir by KronicDeth.
the class HomePath method mergeNameSubdirectories.
private static void mergeNameSubdirectories(@NotNull Map<Version, String> homePathByVersion, @NotNull File parent, @NotNull String name, @NotNull Function<File, File> versionPathToHomePath) {
if (parent.isDirectory()) {
File nameDirectory = new File(parent, name);
if (nameDirectory.isDirectory()) {
File[] files = nameDirectory.listFiles();
if (files != null) {
for (File child : files) {
if (child.isDirectory()) {
String versionString = child.getName();
@NotNull Version version = parseVersion(versionString);
File homePath = versionPathToHomePath.apply(child);
homePathByVersion.put(version, homePath.getAbsolutePath());
}
}
}
}
}
}
Aggregations