Check version in new format
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.openapi.roots.*;
|
import com.intellij.openapi.roots.*;
|
||||||
import com.intellij.openapi.roots.libraries.Library;
|
import com.intellij.openapi.roots.libraries.Library;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.JarFileSystem;
|
import com.intellij.openapi.vfs.JarFileSystem;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
@@ -225,11 +226,23 @@ public class KotlinRuntimeLibraryUtil {
|
|||||||
public static String bundledRuntimeVersion(@NotNull String pluginVersion) {
|
public static String bundledRuntimeVersion(@NotNull String pluginVersion) {
|
||||||
int placeToSplit = -1;
|
int placeToSplit = -1;
|
||||||
|
|
||||||
for (int i = 1; i < pluginVersion.length(); i++) {
|
int ideaPatternIndex = StringUtil.indexOf(pluginVersion, "Idea");
|
||||||
char ch = pluginVersion.charAt(i);
|
if (ideaPatternIndex >= 2 && Character.isDigit(pluginVersion.charAt(ideaPatternIndex - 2))) {
|
||||||
if (Character.isLetter(ch) && pluginVersion.charAt(i - 1) == '.') {
|
placeToSplit = ideaPatternIndex - 1;
|
||||||
placeToSplit = i - 1;
|
}
|
||||||
break;
|
|
||||||
|
int ijPatternIndex = StringUtil.indexOf(pluginVersion, "IJ");
|
||||||
|
if (ijPatternIndex >= 2 && Character.isDigit(pluginVersion.charAt(ijPatternIndex - 2))) {
|
||||||
|
placeToSplit = ijPatternIndex - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (placeToSplit == -1) {
|
||||||
|
for (int i = 1; i < pluginVersion.length(); i++) {
|
||||||
|
char ch = pluginVersion.charAt(i);
|
||||||
|
if (Character.isLetter(ch) && pluginVersion.charAt(i - 1) == '.') {
|
||||||
|
placeToSplit = i - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -246,9 +246,7 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
|
|
||||||
String runtimeVersion = KotlinRuntimeLibraryUtil.bundledRuntimeVersion();
|
String runtimeVersion = KotlinRuntimeLibraryUtil.bundledRuntimeVersion();
|
||||||
|
|
||||||
boolean isOutdated = libraryVersion == null
|
boolean isOutdated = isRuntimeOutdated(libraryVersion, runtimeVersion);
|
||||||
|| libraryVersion.startsWith("internal-") != runtimeVersion.startsWith("internal-")
|
|
||||||
|| VersionComparatorUtil.compare(runtimeVersion, libraryVersion) > 0;
|
|
||||||
|
|
||||||
if (isOutdated) {
|
if (isOutdated) {
|
||||||
outdatedLibraries.add(new VersionedLibrary(library, libraryVersion));
|
outdatedLibraries.add(new VersionedLibrary(library, libraryVersion));
|
||||||
@@ -258,6 +256,12 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
return outdatedLibraries;
|
return outdatedLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isRuntimeOutdated(String libraryVersion, String runtimeVersion) {
|
||||||
|
return libraryVersion == null
|
||||||
|
|| libraryVersion.startsWith("internal-") != runtimeVersion.startsWith("internal-")
|
||||||
|
|| VersionComparatorUtil.compare(runtimeVersion, libraryVersion) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Runnable showRuntimeJarNotFoundDialog(@NotNull final Project project, final @NotNull String jarName) {
|
public static Runnable showRuntimeJarNotFoundDialog(@NotNull final Project project, final @NotNull String jarName) {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
|
|||||||
@@ -34,6 +34,50 @@ public class KotlinRuntimeLibraryUtilTest : TestCase() {
|
|||||||
test("internal-0.1.2", "internal-0.1.2")
|
test("internal-0.1.2", "internal-0.1.2")
|
||||||
test(".0.1.2", ".0.1.2")
|
test(".0.1.2", ".0.1.2")
|
||||||
test("0.1.2.", "0.1.2.")
|
test("0.1.2.", "0.1.2.")
|
||||||
|
|
||||||
|
test("1.0.0-beta1-001-Idea141-12", "1.0.0-beta1-001")
|
||||||
|
test("1.0.1-beta5-013-Idea143-1", "1.0.1-beta5-013")
|
||||||
|
test("1.0.1-beta1-2-Idea143-1", "1.0.1-beta1-2")
|
||||||
|
test("1.0.3-beta1-2", "1.0.3-beta1-2")
|
||||||
|
|
||||||
|
test("1.0.0-beta1-001-IJ143-12", "1.0.0-beta1-001")
|
||||||
|
test("1.0.1-beta5-013-IJ142-1", "1.0.1-beta5-013")
|
||||||
|
test("1.0.1-beta1-2-IJ-2-1", "1.0.1-beta1-2")
|
||||||
|
test("1.0.3-beta1-2-IJ", "1.0.3-beta1-2")
|
||||||
|
|
||||||
|
test("2.15.789-Idea147-14", "2.15.789")
|
||||||
|
|
||||||
|
test("1.0.0-alpha", "1.0.0-alpha")
|
||||||
|
test("1.2.2123-alpha-023", "1.2.2123-alpha-023")
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun testOutdatedRuntime() {
|
||||||
|
outdated("1.0.0-beta1-001-Idea141-12", "0.12.15")
|
||||||
|
outdated("1.0.0-beta1-001-Idea141-1", "0.152.16")
|
||||||
|
outdated("1.0.0-beta1-001-Idea141-1", "0.152.16")
|
||||||
|
|
||||||
|
notOutdated("1.0.0-beta1-001-Idea141-12", "1.0.0-beta1-001")
|
||||||
|
notOutdated("1.0.0-beta1-001-Idea143-14", "1.0.0-beta1-001")
|
||||||
|
notOutdated("1.0.0-beta1-001", "1.0.0-beta1-001")
|
||||||
|
notOutdated("1.0.0-beta1-001-Idea3-1", "1.0.0-beta1-001")
|
||||||
|
notOutdated("1.0.0-beta1-001-Idea3-(1)", "1.0.0-beta1-001")
|
||||||
|
|
||||||
|
outdated("1.0.0-beta1-002-Idea141-1", "1.0.0-beta1-001")
|
||||||
|
outdated("1.0.0-beta1-010-Idea141-1", "1.0.0-beta1-009")
|
||||||
|
outdated("1.0.0-beta1-100-Idea141-1", "1.0.0-beta1-099")
|
||||||
|
outdated("1.0.0-beta2-000-Idea141-1", "1.0.0-beta1-999")
|
||||||
|
outdated("1.1.0-beta1-000-Idea141-1", "1.0.9-beta9-999")
|
||||||
|
outdated("2.0.0-beta1-000-Idea141-1", "1.9.9-beta9-999")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun outdated(plugin: String, library: String) {
|
||||||
|
Assert.assertTrue("Should be outdated: plugin=$plugin, library=$library",
|
||||||
|
OutdatedKotlinRuntimeNotification.isRuntimeOutdated(library, KotlinRuntimeLibraryUtil.bundledRuntimeVersion(plugin)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notOutdated(plugin: String, library: String) {
|
||||||
|
Assert.assertFalse("Should NOT be outdated: plugin=$plugin, library=$library",
|
||||||
|
OutdatedKotlinRuntimeNotification.isRuntimeOutdated(library, KotlinRuntimeLibraryUtil.bundledRuntimeVersion(plugin)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun test(version: String, expected: String) {
|
private fun test(version: String, expected: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user