@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; }
@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); }
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); } } }
@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()); }
@Nullable private Version getConfiguredClientVersion() { Version result = null; try { result = getVersionClient().getVersion(); } catch (Throwable e) { LOG.info(e); } return result; }
@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; }
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); }
@NotNull Version getVersion() throws SvnBindException;
@NotNull @Override public Version getVersion() throws SvnBindException { return parseVersion(runCommand(true)); }
@NotNull @Override public Version getVersion() { return WorkingCopyFormat.ONE_DOT_SEVEN.getVersion(); }
@Nullable private Notification validateVersion(@NotNull Version version) { return !myVcs.isSupportedByCommandLine(WorkingCopyFormat.from(version)) ? new ExecutableNotValidNotification( getOldExecutableMessage(version)) : null; }
private static String getOldExecutableMessage(@NotNull Version version) { return SvnBundle.message("subversion.executable.too.old", version); }
@Test public void testSvnOutput() throws Exception { Assert.assertEquals(new Version(1, 8, 0), CmdVersionClient.parseVersion("1.8.0")); }
@Test public void testSlikSvnOutput() throws Exception { Assert.assertEquals(new Version(1, 7, 8), CmdVersionClient.parseVersion("1.7.8-SlikSvn-1.7.8-WIN32")); }
@Test public void testMultilineFirstLineCorrect() throws Exception { Assert.assertEquals(new Version(10, 2, 15), CmdVersionClient.parseVersion("10.2.15fdsjkf\n8.10.3")); }
@Test(expected = VcsException.class) public void testMultilineSecondLineCorrect() throws Exception { Assert.assertEquals(new Version(8, 10, 3), CmdVersionClient.parseVersion("10.2.fdsjkf\n8.10.3")); }
@NotNull private static Version parseBundleVersion(@Nullable Sdk unityBundle) { String currentVersionString = unityBundle == null ? Unity3dBundleType.UNKNOWN_VERSION : unityBundle.getVersionString(); return parseVersion(currentVersionString); }
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); }
@NotNull public static Unity3dDefineByVersion getUnity3dDefineByVersion(@Nullable Sdk sdk) { Version currentBundleVersion = parseBundleVersion(sdk); return Unity3dDefineByVersion.find(currentBundleVersion.toString()); }
@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); }
public Unity3dPackage(@NotNull String id, @NotNull Version version, @NotNull String path) { myId = id; myVersion = version; myPath = path; }
@NotNull public Version getVersion() { return myVersion; }
@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; }