Java 类com.intellij.openapi.util.Version 实例源码

项目:intellij-ce-playground    文件:SvnExecutableChecker.java   
@Override
@Nullable
protected Notification validate(@NotNull String executable) {
  Notification result = createDefaultNotification();

  // Necessary executable path will be taken from settings while command execution
  final Version version = getConfiguredClientVersion();
  if (version != null) {
    try {
      result = validateVersion(version);

      if (result == null) {
        result = validateLocale();
      }
    }
    catch (Throwable e) {
      LOG.info(e);
    }
  }

  return result;
}
项目:consulo-unity3d    文件:Unity3dProjectImportUtil.java   
@NotNull
public static Version parseVersion(@Nullable String versionString)
{
    if(versionString == null)
    {
        return new Version(0, 0, 0);
    }
    List<String> list = StringUtil.split(versionString, ".");
    if(list.size() >= 3)
    {
        try
        {
            return new Version(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1)), Integer.parseInt(list.get(2)));
        }
        catch(NumberFormatException ignored)
        {
        }
    }
    return new Version(0, 0, 0);
}
项目:consulo-unity3d    文件:Unity3dRootModuleExtension.java   
private static void addUnityExtensions(List<String> list, @NotNull Version version, String baseDir)
{
    VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(baseDir);
    if(dir == null)
    {
        return;
    }

    for(VirtualFile virtualFile : dir.getChildren())
    {
        if(virtualFile.isDirectory())
        {
            addUnityExtension(list, virtualFile, version);
        }
    }
}
项目:intellij-ce-playground    文件:CmdVersionClient.java   
@NotNull
private static Version parseVersion(@NotNull ProcessOutput output) throws SvnBindException {
  // TODO: This or similar check should likely go to CommandRuntime - to be applied for all commands
  if (output.isTimeout()) {
    throw new SvnBindException(String.format("Exit code: %d, Error: %s", output.getExitCode(), output.getStderr()));
  }

  return parseVersion(output.getStdout());
}
项目:intellij-ce-playground    文件:SvnExecutableChecker.java   
@Nullable
private Version getConfiguredClientVersion() {
  Version result = null;

  try {
    result = getVersionClient().getVersion();
  }
  catch (Throwable e) {
    LOG.info(e);
  }

  return result;
}
项目:intellij-ce-playground    文件:CmdCheckoutClient.java   
@Override
public List<WorkingCopyFormat> getSupportedFormats() throws VcsException {
  ArrayList<WorkingCopyFormat> result = new ArrayList<WorkingCopyFormat>();

  Version version = myFactory.createVersionClient().getVersion();
  result.add(WorkingCopyFormat.from(version));

  return result;
}
项目:intellij-ce-playground    文件:UpdateInfoDialog.java   
protected static String formatVersion(String versionString, String build) {
  Version version = Version.parseVersion(versionString);
  String formattedVersion = version != null ? version.toString() : versionString;
  return IdeBundle.message("updates.version.info", formattedVersion, build);
}
项目:intellij-ce-playground    文件:VersionClient.java   
@NotNull
Version getVersion() throws SvnBindException;
项目:intellij-ce-playground    文件:CmdVersionClient.java   
@NotNull
@Override
public Version getVersion() throws SvnBindException {
  return parseVersion(runCommand(true));
}
项目:intellij-ce-playground    文件:SvnKitVersionClient.java   
@NotNull
@Override
public Version getVersion() {
  return WorkingCopyFormat.ONE_DOT_SEVEN.getVersion();
}
项目:intellij-ce-playground    文件:SvnExecutableChecker.java   
@Nullable
private Notification validateVersion(@NotNull Version version) {
  return !myVcs.isSupportedByCommandLine(WorkingCopyFormat.from(version)) ? new ExecutableNotValidNotification(
    getOldExecutableMessage(version)) : null;
}
项目:intellij-ce-playground    文件:SvnExecutableChecker.java   
private static String getOldExecutableMessage(@NotNull Version version) {
  return SvnBundle.message("subversion.executable.too.old", version);
}
项目:intellij-ce-playground    文件:ParseVersionTest.java   
@Test
public void testSvnOutput() throws Exception {
  Assert.assertEquals(new Version(1, 8, 0), CmdVersionClient.parseVersion("1.8.0"));
}
项目:intellij-ce-playground    文件:ParseVersionTest.java   
@Test
public void testSlikSvnOutput() throws Exception {
  Assert.assertEquals(new Version(1, 7, 8), CmdVersionClient.parseVersion("1.7.8-SlikSvn-1.7.8-WIN32"));
}
项目:intellij-ce-playground    文件:ParseVersionTest.java   
@Test
public void testMultilineFirstLineCorrect() throws Exception {
  Assert.assertEquals(new Version(10, 2, 15), CmdVersionClient.parseVersion("10.2.15fdsjkf\n8.10.3"));
}
项目:intellij-ce-playground    文件:ParseVersionTest.java   
@Test(expected = VcsException.class)
public void testMultilineSecondLineCorrect() throws Exception {
  Assert.assertEquals(new Version(8, 10, 3), CmdVersionClient.parseVersion("10.2.fdsjkf\n8.10.3"));
}
项目:consulo-unity3d    文件:Unity3dProjectImportUtil.java   
@NotNull
private static Version parseBundleVersion(@Nullable Sdk unityBundle)
{
    String currentVersionString = unityBundle == null ? Unity3dBundleType.UNKNOWN_VERSION : unityBundle.getVersionString();
    return parseVersion(currentVersionString);
}
项目:consulo-unity3d    文件:Unity3dProjectImportUtil.java   
private static boolean isVersionHigherOrEqual(@Nullable Sdk unityBundle, @NotNull String requiredVersionString)
{
    Version currentVersion = parseBundleVersion(unityBundle);
    Version requiredVersion = parseVersion(requiredVersionString);
    return currentVersion.isOrGreaterThan(requiredVersion.major, requiredVersion.minor, requiredVersion.bugfix);
}
项目:consulo-unity3d    文件:Unity3dProjectImportUtil.java   
@NotNull
public static Unity3dDefineByVersion getUnity3dDefineByVersion(@Nullable Sdk sdk)
{
    Version currentBundleVersion = parseBundleVersion(sdk);
    return Unity3dDefineByVersion.find(currentBundleVersion.toString());
}
项目:consulo-unity3d    文件:Unity3dPackageWatcher.java   
@NotNull
private Unity3dPackageIndex buildIndex()
{
    VirtualFile rootDir = LocalFileSystem.getInstance().findFileByPath(myPackageDirPath);
    if(rootDir == null)
    {
        return Unity3dPackageIndex.EMPTY;
    }

    MultiMap<String, Unity3dPackage> map = MultiMap.createOrderedSet();

    for(VirtualFile packageDir : rootDir.getChildren())
    {
        CharSequence name = packageDir.getNameSequence();

        List<CharSequence> split = StringUtil.split(name, "@");
        if(split.size() != 2)
        {
            continue;
        }

        CharSequence id = split.get(0);
        CharSequence version = split.get(1);

        Version parsedVersion = Version.parseVersion(version.toString());
        if(parsedVersion == null)
        {
            continue;
        }

        String idAsString = id.toString();
        map.putValue(idAsString, new Unity3dPackage(idAsString, parsedVersion, packageDir.getPath()));
    }

    if(map.isEmpty())
    {
        return Unity3dPackageIndex.EMPTY;
    }

    List<Unity3dPackage> topPackages = new ArrayList<>();
    for(Map.Entry<String, Collection<Unity3dPackage>> entry : map.entrySet())
    {
        // hack for get last element
        List<Unity3dPackage> value = (List<Unity3dPackage>) entry.getValue();

        Unity3dPackage lastItem = ContainerUtil.getLastItem(value);
        if(lastItem == null)
        {
            continue;
        }

        topPackages.add(lastItem);
    }

    return new Unity3dPackageIndex(topPackages);
}
项目:consulo-unity3d    文件:Unity3dPackage.java   
public Unity3dPackage(@NotNull String id, @NotNull Version version, @NotNull String path)
{
    myId = id;
    myVersion = version;
    myPath = path;
}
项目:consulo-unity3d    文件:Unity3dPackage.java   
@NotNull
public Version getVersion()
{
    return myVersion;
}
项目:consulo-unity3d    文件:Unity3dRootModuleExtension.java   
@NotNull
private List<String> getPathsForLibraries(String homePath, @NotNull Sdk sdk)
{
    Version version = Unity3dProjectImportUtil.parseVersion(sdk.getVersionString());

    List<String> list = new SmartList<>();
    if(SystemInfo.isMac)
    {
        list.add(homePath + "/Contents/Frameworks/Managed");
        list.add(homePath + "/Contents/Frameworks/Mono/lib/mono/2.0");

        // actual at unity5.4 beta
        list.add(homePath + "/Contents/Managed");
        list.add(homePath + "/Contents/Mono/lib/mono/2.0");

        // dead path?
        addUnityExtensions(list, version, homePath + "/Contents/Frameworks/UnityExtensions/Unity");
        // actual mac path
        addUnityExtensions(list, version, homePath + "/Contents/UnityExtensions/Unity");

        // try to resolve external PlaybackEngines
        File homeFile = new File(homePath);
        if(homeFile.exists())
        {
            File parentFile = homeFile.getParentFile();

            if(parentFile != null)
            {
                File playbackEngines = new File(parentFile, "PlaybackEngines/VuforiaSupport/Managed");
                if(playbackEngines.exists())
                {
                    list.add(playbackEngines.getPath() + "/Runtime");
                    list.add(playbackEngines.getPath() + "/Editor");
                }
            }
        }
    }
    else if(SystemInfo.isWindows || SystemInfo.isLinux)
    {
        list.add(homePath + "/Editor/Data/Managed");
        list.add(homePath + "/Editor/Data/Mono/lib/mono/2.0");

        addUnityExtensions(list, version, homePath + "/Editor/Data/UnityExtensions/Unity");
    }

    if(version.isOrGreaterThan(2017, 2))
    {
        File vuforiaSpport = new File(homePath, "/Editor/Data/PlaybackEngines/VuforiaSupport");
        if(vuforiaSpport.exists())
        {
            list.add(homePath + "/Editor/Data/PlaybackEngines/VuforiaSupport/Managed/Runtime");
            list.add(homePath + "/Editor/Data/PlaybackEngines/VuforiaSupport/Managed/Editor");
        }

        Unity3dPackageIndex index = Unity3dPackageWatcher.getInstance().getIndex();
        for(Unity3dPackage unity3dPackage : index.getTopPackages())
        {
            list.add(unity3dPackage.getPath());
        }
    }
    return list;
}