Search in sources :

Example 16 with Version

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;
}
Also used : Version(com.intellij.openapi.util.Version) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 17 with Version

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;
}
Also used : Version(com.intellij.openapi.util.Version) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 18 with Version

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;
}
Also used : Version(com.intellij.openapi.util.Version) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module)

Example 19 with Version

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());
                    }
                }
            }
        }
    }
}
Also used : Version(com.intellij.openapi.util.Version) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Version (com.intellij.openapi.util.Version)19 File (java.io.File)10 NotNull (org.jetbrains.annotations.NotNull)4 Matcher (java.util.regex.Matcher)3 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Test (org.junit.Test)2 GroupDescriptor (com.intellij.internal.statistic.beans.GroupDescriptor)1 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1 Notification (com.intellij.notification.Notification)1 Module (com.intellij.openapi.module.Module)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 PsiFile (com.intellij.psi.PsiFile)1 RequestFailedException (com.intellij.tasks.impl.RequestFailedException)1 JdkBundle (com.intellij.util.JdkBundle)1 Plist (com.jetbrains.cidr.xcode.plist.Plist)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1