com.intellij.openapi.util.Version Java Examples

The following examples show how to use com.intellij.openapi.util.Version. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IncompatibleDartPluginNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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) {
    return null; // Running from sources.
  }
  return dartVersion.compareTo(minimumVersion) < 0 ? createUpdateDartPanel(myProject, module, dartVersion.toCompactString(),
                                                                           getPrintableRequiredDartVersion()) : null;
}
 
Example #2
Source File: IncompatibleDartPluginNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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) {
    return null; // Running from sources.
  }
  return dartVersion.compareTo(minimumVersion) < 0 ? createUpdateDartPanel(myProject, module, dartVersion.toCompactString(),
                                                                           getPrintableRequiredDartVersion()) : null;
}
 
Example #3
Source File: Unity3dProjectImportUtil.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
@Nonnull
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);
}
 
Example #4
Source File: Unity3dRootModuleExtension.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
private static void addUnityExtensions(List<String> list, @Nonnull 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);
		}
	}
}
 
Example #5
Source File: DartPlugin.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @return the version of the currently installed Dart Plugin
 */
public Version getVersion() {
  if (myVersion == null) {
    final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(PluginId.getId("Dart"));
    assert (descriptor != null);
    myVersion = Version.parseVersion(descriptor.getVersion());
  }
  return myVersion;
}
 
Example #6
Source File: DartPlugin.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @return the version of the currently installed Dart Plugin
 */
public Version getVersion() {
  if (myVersion == null) {
    final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(PluginId.getId("Dart"));
    assert (descriptor != null);
    myVersion = Version.parseVersion(descriptor.getVersion());
  }
  return myVersion;
}
 
Example #7
Source File: DartPlugin.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @return the minimum required version of the Dart Plugin
 */
public Version getMinimumVersion() {
  return MINIMUM_VERSION;
}
 
Example #8
Source File: FlutterSdkVersion.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@VisibleForTesting
public FlutterSdkVersion(@NotNull String versionString) {
  version = Version.parseVersion(versionString);
}
 
Example #9
Source File: DartPlugin.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @return the minimum required version of the Dart Plugin
 */
public Version getMinimumVersion() {
  return MINIMUM_VERSION;
}
 
Example #10
Source File: FlutterSdkVersion.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@VisibleForTesting
public FlutterSdkVersion(@NotNull String versionString) {
  version = Version.parseVersion(versionString);
}
 
Example #11
Source File: Unity3dProjectImportUtil.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Version parseBundleVersion(@Nullable Sdk unityBundle)
{
	String currentVersionString = unityBundle == null ? Unity3dBundleType.UNKNOWN_VERSION : unityBundle.getVersionString();
	return parseVersion(currentVersionString);
}
 
Example #12
Source File: Unity3dProjectImportUtil.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
private static boolean isVersionHigherOrEqual(@Nullable Sdk unityBundle, @Nonnull String requiredVersionString)
{
	Version currentVersion = parseBundleVersion(unityBundle);
	Version requiredVersion = parseVersion(requiredVersionString);
	return currentVersion.isOrGreaterThan(requiredVersion.major, requiredVersion.minor, requiredVersion.bugfix);
}
 
Example #13
Source File: Unity3dProjectImportUtil.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static Unity3dDefineByVersion getUnity3dDefineByVersion(@Nullable Sdk sdk)
{
	Version currentBundleVersion = parseBundleVersion(sdk);
	return Unity3dDefineByVersion.find(currentBundleVersion.toString());
}
 
Example #14
Source File: Unity3dRootModuleExtension.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
private List<String> getPathsForLibraries(String homePath, @Nonnull Sdk sdk)
{
	Version version = Unity3dProjectImportUtil.parseVersion(sdk.getVersionString());

	Platform.OperatingSystem os = Platform.current().os();

	List<String> list = new SmartList<>();
	if(os.isMac())
	{
		list.add(homePath + "/Contents/Frameworks/Managed");
		switch(scriptRuntimeVersion)
		{
			case NET_2_TO_3_5:
				list.add(homePath + "/Contents/Frameworks/Mono/lib/mono/2.0");
				// actual at unity5.4 beta
				list.add(homePath + "/Contents/Mono/lib/mono/2.0");
				break;
			case NET_4_6:
				list.add(homePath + "/Contents/MonoBleedingEdge/lib/mono/4.5");
				break;
		}

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

		// 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(os.isWindows() || os.isLinux())
	{
		list.add(homePath + "/Editor/Data/Managed");
		switch(scriptRuntimeVersion)
		{
			case NET_2_TO_3_5:
				list.add(homePath + "/Editor/Data/Mono/lib/mono/2.0");
				break;
			case NET_4_6:
				list.add(homePath + "/Editor/Data/MonoBleedingEdge/lib/mono/4.5");
				break;
		}

		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");
		}
	}
	return list;
}