From 345528d8f5da99b0b374a285c4551d4c2bd12e99 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Mon, 6 Jul 2020 14:42:20 +0200 Subject: [PATCH] Use public api to register KOTLIN_BUNDLED macros Relates to #KT-39968 --- .../resources-descriptors/META-INF/plugin.xml | 2 +- .../META-INF/plugin.xml.202 | 2 +- .../META-INF/plugin.xml.as41 | 2 +- .../kotlin/idea/KotlinPluginMacros.kt | 25 +++++++++++++++ .../kotlin/idea/KotlinPluginMacros.kt.193 | 0 .../kotlin/idea/PluginStartupListener.kt | 31 ------------------- .../kotlin/idea/PluginStartupListener.kt.193 | 31 +++++++++++++++++++ 7 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt create mode 100644 idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt.193 create mode 100644 idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt.193 diff --git a/idea/resources-descriptors/META-INF/plugin.xml b/idea/resources-descriptors/META-INF/plugin.xml index 53260618036..c8a467ee3bd 100644 --- a/idea/resources-descriptors/META-INF/plugin.xml +++ b/idea/resources-descriptors/META-INF/plugin.xml @@ -74,7 +74,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. - + diff --git a/idea/resources-descriptors/META-INF/plugin.xml.202 b/idea/resources-descriptors/META-INF/plugin.xml.202 index ed37fb35054..5a2c095fc92 100644 --- a/idea/resources-descriptors/META-INF/plugin.xml.202 +++ b/idea/resources-descriptors/META-INF/plugin.xml.202 @@ -74,7 +74,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. - + diff --git a/idea/resources-descriptors/META-INF/plugin.xml.as41 b/idea/resources-descriptors/META-INF/plugin.xml.as41 index 536375fddef..3e48ad7f706 100644 --- a/idea/resources-descriptors/META-INF/plugin.xml.as41 +++ b/idea/resources-descriptors/META-INF/plugin.xml.as41 @@ -73,7 +73,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. - + diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt new file mode 100644 index 00000000000..189bbfc873e --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea + +import com.intellij.openapi.application.PathMacroContributor +import org.jetbrains.kotlin.utils.PathUtil + +/** + * Some actions have to be performed before loading and opening any project. + * + * E.g. path variables have to be registered in advance as modules could rely on some path variables. + */ +class KotlinPluginMacros : PathMacroContributor { + override fun registerPathMacros(macros: MutableMap, legacyMacros: MutableMap) { + macros[KOTLIN_BUNDLED_PATH_VARIABLE] = PathUtil.kotlinPathsForIdeaPlugin.homePath.path + } + + companion object { + const val KOTLIN_BUNDLED_PATH_VARIABLE = "KOTLIN_BUNDLED" + } + +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt.193 b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginMacros.kt.193 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt b/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt index 908049cbb9c..e69de29bb2d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt +++ b/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.idea - -import com.intellij.ide.ApplicationInitializedListener -import com.intellij.openapi.application.PathMacros -import org.jetbrains.kotlin.utils.PathUtil.kotlinPathsForIdeaPlugin - -/** - * Some actions have to be performed before loading and opening any project. - * - * E.g. path variables have to be registered in advance as modules could rely on some path variables. - */ -class PluginStartupListener : ApplicationInitializedListener { - - override fun componentsInitialized() { - registerPathVariable() - } - - private fun registerPathVariable() { - val macros = PathMacros.getInstance() - macros.setMacro(KOTLIN_BUNDLED_PATH_VARIABLE, kotlinPathsForIdeaPlugin.homePath.path) - } - - companion object { - const val KOTLIN_BUNDLED_PATH_VARIABLE = "KOTLIN_BUNDLED" - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt.193 b/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt.193 new file mode 100644 index 00000000000..908049cbb9c --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/PluginStartupListener.kt.193 @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea + +import com.intellij.ide.ApplicationInitializedListener +import com.intellij.openapi.application.PathMacros +import org.jetbrains.kotlin.utils.PathUtil.kotlinPathsForIdeaPlugin + +/** + * Some actions have to be performed before loading and opening any project. + * + * E.g. path variables have to be registered in advance as modules could rely on some path variables. + */ +class PluginStartupListener : ApplicationInitializedListener { + + override fun componentsInitialized() { + registerPathVariable() + } + + private fun registerPathVariable() { + val macros = PathMacros.getInstance() + macros.setMacro(KOTLIN_BUNDLED_PATH_VARIABLE, kotlinPathsForIdeaPlugin.homePath.path) + } + + companion object { + const val KOTLIN_BUNDLED_PATH_VARIABLE = "KOTLIN_BUNDLED" + } +} \ No newline at end of file