diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index edca335fe9a..2f25b58a4ee 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -1,9 +1,4 @@ - - - org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent - - diff --git a/idea/resources/META-INF/plugin.xml b/idea/resources/META-INF/plugin.xml index e2e2615c292..5c94778c189 100644 --- a/idea/resources/META-INF/plugin.xml +++ b/idea/resources/META-INF/plugin.xml @@ -78,41 +78,44 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. - - - - - - + + - - + + - - - - + + + - - - - - - - - - - - - - - - - + + - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/idea/resources/META-INF/plugin.xml.191 b/idea/resources/META-INF/plugin.xml.191 index 271f1801886..92e379de4b6 100644 --- a/idea/resources/META-INF/plugin.xml.191 +++ b/idea/resources/META-INF/plugin.xml.191 @@ -58,6 +58,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent + + + org.jetbrains.kotlin.idea.completion.LookupCancelWatcher diff --git a/idea/resources/META-INF/plugin.xml.192 b/idea/resources/META-INF/plugin.xml.192 index 26ac2ebd8ae..de2e8900d08 100644 --- a/idea/resources/META-INF/plugin.xml.192 +++ b/idea/resources/META-INF/plugin.xml.192 @@ -58,6 +58,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent + + + org.jetbrains.kotlin.idea.completion.LookupCancelWatcher diff --git a/idea/resources/META-INF/plugin.xml.201 b/idea/resources/META-INF/plugin.xml.201 index a6f8fdb02df..1b8cd15a31b 100644 --- a/idea/resources/META-INF/plugin.xml.201 +++ b/idea/resources/META-INF/plugin.xml.201 @@ -74,7 +74,10 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + diff --git a/idea/resources/META-INF/plugin.xml.as35 b/idea/resources/META-INF/plugin.xml.as35 index e0cf902c639..f7b4b27084b 100644 --- a/idea/resources/META-INF/plugin.xml.as35 +++ b/idea/resources/META-INF/plugin.xml.as35 @@ -59,6 +59,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent + + + org.jetbrains.kotlin.idea.completion.LookupCancelWatcher diff --git a/idea/resources/META-INF/plugin.xml.as36 b/idea/resources/META-INF/plugin.xml.as36 index 8002dae9d90..a0ffea07287 100644 --- a/idea/resources/META-INF/plugin.xml.as36 +++ b/idea/resources/META-INF/plugin.xml.as36 @@ -59,6 +59,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent + + + org.jetbrains.kotlin.idea.completion.LookupCancelWatcher diff --git a/idea/resources/META-INF/plugin.xml.as40 b/idea/resources/META-INF/plugin.xml.as40 index a046fbfd3e6..c4efd9c233d 100644 --- a/idea/resources/META-INF/plugin.xml.as40 +++ b/idea/resources/META-INF/plugin.xml.as40 @@ -79,7 +79,10 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. + + + diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt index 66a5f1c702b..70a94e9f2ca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt @@ -17,47 +17,41 @@ package org.jetbrains.kotlin.idea.versions import com.intellij.ide.util.PropertiesComponent -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.BaseComponent +import com.intellij.openapi.project.Project +import com.intellij.openapi.startup.StartupActivity import com.intellij.openapi.vfs.JarFileSystem import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFileVisitor import com.intellij.openapi.vfs.newvfs.NewVirtualFile import org.jetbrains.kotlin.idea.KotlinPluginUtil +import org.jetbrains.kotlin.idea.util.application.isUnitTestMode import java.io.File -private val INSTALLED_KOTLIN_VERSION = "installed.kotlin.plugin.version" - /** * Component forces update for built-in libraries in plugin directory. They are ignored because of * com.intellij.util.indexing.FileBasedIndex.isUnderConfigOrSystem() */ -class KotlinUpdatePluginComponent : BaseComponent { - override fun initComponent() { - if (ApplicationManager.getApplication()?.isUnitTestMode == true) { - return - } +// BUNCH: 192 +class KotlinUpdatePluginStartupActivity : StartupActivity { - val installedKotlinVersion = PropertiesComponent.getInstance()?.getValue(INSTALLED_KOTLIN_VERSION) + override fun runActivity(project: Project) { + if (isUnitTestMode()) return - if (installedKotlinVersion == null || KotlinPluginUtil.getPluginVersion() != installedKotlinVersion) { + val propertiesComponent = PropertiesComponent.getInstance() ?: return + + val installedKotlinVersion = propertiesComponent.getValue(INSTALLED_KOTLIN_VERSION) + + if (KotlinPluginUtil.getPluginVersion() != installedKotlinVersion) { // Force refresh jar handlers for (libraryJarDescriptor in LibraryJarDescriptor.values()) { requestFullJarUpdate(libraryJarDescriptor.getPathInPlugin()) } - PropertiesComponent.getInstance()?.setValue(INSTALLED_KOTLIN_VERSION, KotlinPluginUtil.getPluginVersion()) + propertiesComponent.setValue(INSTALLED_KOTLIN_VERSION, KotlinPluginUtil.getPluginVersion()) } } - override fun getComponentName(): String { - return "ReindexBundledRuntimeComponent" - } - - override fun disposeComponent() { - } - private fun requestFullJarUpdate(jarFilePath: File) { val localVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jarFilePath) ?: return @@ -66,4 +60,8 @@ class KotlinUpdatePluginComponent : BaseComponent { VfsUtilCore.visitChildrenRecursively(jarFile, object : VirtualFileVisitor() {}) ((jarFile as NewVirtualFile)).markDirtyRecursively() } + + companion object { + private const val INSTALLED_KOTLIN_VERSION = "installed.kotlin.plugin.version" + } } diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 new file mode 100644 index 00000000000..92308d328e6 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 @@ -0,0 +1,70 @@ +/* + * 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.versions + +import com.intellij.ide.util.PropertiesComponent +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.components.BaseComponent +import com.intellij.openapi.vfs.JarFileSystem +import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.openapi.vfs.VfsUtilCore +import com.intellij.openapi.vfs.VirtualFileVisitor +import com.intellij.openapi.vfs.newvfs.NewVirtualFile +import org.jetbrains.kotlin.idea.KotlinPluginUtil +import java.io.File + +private val INSTALLED_KOTLIN_VERSION = "installed.kotlin.plugin.version" + +/** + * Component forces update for built-in libraries in plugin directory. They are ignored because of + * com.intellij.util.indexing.FileBasedIndex.isUnderConfigOrSystem() + */ +// BUNCH: 192 +class KotlinUpdatePluginComponent : BaseComponent { + override fun initComponent() { + if (ApplicationManager.getApplication()?.isUnitTestMode == true) { + return + } + + val installedKotlinVersion = PropertiesComponent.getInstance()?.getValue(INSTALLED_KOTLIN_VERSION) + + if (installedKotlinVersion == null || KotlinPluginUtil.getPluginVersion() != installedKotlinVersion) { + // Force refresh jar handlers + for (libraryJarDescriptor in LibraryJarDescriptor.values()) { + requestFullJarUpdate(libraryJarDescriptor.getPathInPlugin()) + } + + PropertiesComponent.getInstance()?.setValue(INSTALLED_KOTLIN_VERSION, KotlinPluginUtil.getPluginVersion()) + } + } + + override fun getComponentName(): String { + return "ReindexBundledRuntimeComponent" + } + + override fun disposeComponent() { + } + + private fun requestFullJarUpdate(jarFilePath: File) { + val localVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jarFilePath) ?: return + + // Build and update JarHandler + val jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(localVirtualFile) ?: return + VfsUtilCore.visitChildrenRecursively(jarFile, object : VirtualFileVisitor() {}) + ((jarFile as NewVirtualFile)).markDirtyRecursively() + } +}