Use public api to register KOTLIN_BUNDLED macros

Relates to #KT-39968
This commit is contained in:
Vladimir Dolzhenko
2020-07-06 14:42:20 +02:00
committed by Vladimir Dolzhenko
parent ab2128f55d
commit 345528d8f5
7 changed files with 59 additions and 34 deletions
@@ -74,7 +74,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
</extensions>
<extensions defaultExtensionNs="com.intellij">
<applicationInitializedListener implementation="org.jetbrains.kotlin.idea.PluginStartupListener" />
<pathMacroContributor implementation="org.jetbrains.kotlin.idea.KotlinPluginMacros"/>
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
@@ -74,7 +74,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
</extensions>
<extensions defaultExtensionNs="com.intellij">
<applicationInitializedListener implementation="org.jetbrains.kotlin.idea.PluginStartupListener" />
<pathMacroContributor implementation="org.jetbrains.kotlin.idea.KotlinPluginMacros"/>
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
@@ -73,7 +73,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
</extensions>
<extensions defaultExtensionNs="com.intellij">
<applicationInitializedListener implementation="org.jetbrains.kotlin.idea.PluginStartupListener" />
<pathMacroContributor implementation="org.jetbrains.kotlin.idea.KotlinPluginMacros"/>
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
@@ -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<String, String>, legacyMacros: MutableMap<String, String>) {
macros[KOTLIN_BUNDLED_PATH_VARIABLE] = PathUtil.kotlinPathsForIdeaPlugin.homePath.path
}
companion object {
const val KOTLIN_BUNDLED_PATH_VARIABLE = "KOTLIN_BUNDLED"
}
}
@@ -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"
}
}
@@ -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"
}
}