Consider bundled library version to be plugin version without identifier parts
This commit is contained in:
@@ -21,7 +21,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
|||||||
import com.intellij.ui.SeparatorWithText;
|
import com.intellij.ui.SeparatorWithText;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.idea.JetPluginUtil;
|
import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -49,7 +49,7 @@ public abstract class CreateLibraryDialogBase extends DialogWrapper {
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
compilerTextLabel.setText(compilerTextLabel.getText() + " - " + JetPluginUtil.getPluginVersion());
|
compilerTextLabel.setText(compilerTextLabel.getText() + " - " + KotlinRuntimeLibraryUtil.bundledRuntimeVersion());
|
||||||
|
|
||||||
pathPanel = new ChooseLibraryPathPanel(defaultPath);
|
pathPanel = new ChooseLibraryPathPanel(defaultPath);
|
||||||
pathPanel.addValidityListener(new ValidityListener() {
|
pathPanel.addValidityListener(new ValidityListener() {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.intellij.util.indexing.FileBasedIndex;
|
|||||||
import com.intellij.util.indexing.ID;
|
import com.intellij.util.indexing.ID;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.idea.JetPluginUtil;
|
||||||
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtils;
|
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtils;
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinJavaModuleConfigurator;
|
import org.jetbrains.kotlin.idea.configuration.KotlinJavaModuleConfigurator;
|
||||||
import org.jetbrains.kotlin.idea.framework.JSLibraryStdPresentationProvider;
|
import org.jetbrains.kotlin.idea.framework.JSLibraryStdPresentationProvider;
|
||||||
@@ -248,6 +249,26 @@ public class KotlinRuntimeLibraryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String bundledRuntimeVersion() {
|
||||||
|
return bundledRuntimeVersion(JetPluginUtil.getPluginVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String bundledRuntimeVersion(@NotNull String pluginVersion) {
|
||||||
|
int placeToSplit = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < pluginVersion.toCharArray().length; i++) {
|
||||||
|
char ch = pluginVersion.charAt(i);
|
||||||
|
if (Character.isLetter(ch) && i > 0 && pluginVersion.charAt(i - 1) == '.') {
|
||||||
|
placeToSplit = i - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return placeToSplit != - 1 ? pluginVersion.substring(0, placeToSplit) : pluginVersion;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static VirtualFile getLocalJar(@Nullable VirtualFile kotlinRuntimeJar) {
|
public static VirtualFile getLocalJar(@Nullable VirtualFile kotlinRuntimeJar) {
|
||||||
if (kotlinRuntimeJar == null) return null;
|
if (kotlinRuntimeJar == null) return null;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
// user already clicked suppress
|
// user already clicked suppress
|
||||||
if (pluginVersion.equals(PropertiesComponent.getInstance(myProject).getValue(SUPPRESSED_PROPERTY_NAME))) return;
|
if (pluginVersion.equals(PropertiesComponent.getInstance(myProject).getValue(SUPPRESSED_PROPERTY_NAME))) return;
|
||||||
|
|
||||||
Collection<VersionedLibrary> versionedOutdatedLibraries = findOutdatedKotlinLibraries(myProject, pluginVersion);
|
Collection<VersionedLibrary> versionedOutdatedLibraries = findOutdatedKotlinLibraries(myProject);
|
||||||
if (versionedOutdatedLibraries.isEmpty()) {
|
if (versionedOutdatedLibraries.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||||
if ("update".equals(event.getDescription())) {
|
if ("update".equals(event.getDescription())) {
|
||||||
Collection<VersionedLibrary> versionedOutdatedLibraries = findOutdatedKotlinLibraries(myProject, pluginVersion);
|
Collection<VersionedLibrary> versionedOutdatedLibraries = findOutdatedKotlinLibraries(myProject);
|
||||||
Collection<Library> outdatedLibraries = extractLibraries(versionedOutdatedLibraries);
|
Collection<Library> outdatedLibraries = extractLibraries(versionedOutdatedLibraries);
|
||||||
KotlinRuntimeLibraryUtil.updateLibraries(myProject, outdatedLibraries);
|
KotlinRuntimeLibraryUtil.updateLibraries(myProject, outdatedLibraries);
|
||||||
suggestDeleteKotlinJsIfNeeded(outdatedLibraries);
|
suggestDeleteKotlinJsIfNeeded(outdatedLibraries);
|
||||||
@@ -229,7 +229,7 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Collection<VersionedLibrary> findOutdatedKotlinLibraries(@NotNull Project project, @NotNull String pluginVersion) {
|
private static Collection<VersionedLibrary> findOutdatedKotlinLibraries(@NotNull Project project) {
|
||||||
List<VersionedLibrary> outdatedLibraries = Lists.newArrayList();
|
List<VersionedLibrary> outdatedLibraries = Lists.newArrayList();
|
||||||
|
|
||||||
for (Library library : KotlinRuntimeLibraryUtil.findKotlinLibraries(project)) {
|
for (Library library : KotlinRuntimeLibraryUtil.findKotlinLibraries(project)) {
|
||||||
@@ -244,10 +244,11 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
}
|
}
|
||||||
String libraryVersion = libraryVersionProperties.getVersionString();
|
String libraryVersion = libraryVersionProperties.getVersionString();
|
||||||
|
|
||||||
boolean isOutdated = "snapshot".equals(libraryVersion)
|
String runtimeVersion = KotlinRuntimeLibraryUtil.bundledRuntimeVersion();
|
||||||
|| libraryVersion == null
|
|
||||||
|| libraryVersion.startsWith("internal-") != pluginVersion.startsWith("internal-")
|
boolean isOutdated = libraryVersion == null
|
||||||
|| VersionComparatorUtil.compare(pluginVersion, libraryVersion) > 0;
|
|| 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));
|
||||||
@@ -257,7 +258,6 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
|||||||
return outdatedLibraries;
|
return outdatedLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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() {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea
|
||||||
|
|
||||||
|
import junit.framework.TestCase
|
||||||
|
import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtil
|
||||||
|
import org.jetbrains.kotlin.idea.versions.OutdatedKotlinRuntimeNotification
|
||||||
|
import org.junit.Assert
|
||||||
|
|
||||||
|
|
||||||
|
public class KotlinRuntimeLibraryUtilTest : TestCase() {
|
||||||
|
public fun testKotlinLibraryRelevantVersion() {
|
||||||
|
test("0.10.2013", "0.10.2013")
|
||||||
|
test("0.10.M.2013", "0.10")
|
||||||
|
test("0.10.2.Idea140.2013", "0.10.2")
|
||||||
|
test("0.11.1995.1.M.Idea140.2013", "0.11.1995.1")
|
||||||
|
test("Some.0.10.2", "Some.0.10.2")
|
||||||
|
test("@snapshot@", "@snapshot@")
|
||||||
|
test("snapshot", "snapshot")
|
||||||
|
test("internal-0.1.2", "internal-0.1.2")
|
||||||
|
test(".0.1.2", ".0.1.2")
|
||||||
|
test("0.1.2.", "0.1.2.")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun test(version: String, expected: String) {
|
||||||
|
Assert.assertEquals(expected, KotlinRuntimeLibraryUtil.bundledRuntimeVersion(version))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user