Register KOTLIN_BUNDLED via application component in 193
#KTI-299 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
345528d8f5
commit
5951e7500a
@@ -66,6 +66,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
</component>
|
</component>
|
||||||
</project-components>
|
</project-components>
|
||||||
|
|
||||||
|
<application-components>
|
||||||
|
<component>
|
||||||
|
<implementation-class>org.jetbrains.kotlin.idea.PluginStartupComponent</implementation-class>
|
||||||
|
</component>
|
||||||
|
</application-components>
|
||||||
|
|
||||||
<extensionPoints>
|
<extensionPoints>
|
||||||
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
||||||
|
|
||||||
@@ -80,7 +86,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<applicationInitializedListener implementation="org.jetbrains.kotlin.idea.PluginStartupListener" />
|
|
||||||
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
|
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
|
||||||
|
|
||||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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 com.intellij.openapi.application.PathMacros;
|
||||||
|
import com.intellij.openapi.components.BaseComponent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.utils.PathUtil;
|
||||||
|
|
||||||
|
public class PluginStartupComponent implements BaseComponent {
|
||||||
|
|
||||||
|
private static final String KOTLIN_BUNDLED = "KOTLIN_BUNDLED";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public String getComponentName() {
|
||||||
|
return PluginStartupComponent.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initComponent() {
|
||||||
|
registerPathVariable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerPathVariable() {
|
||||||
|
PathMacros macros = PathMacros.getInstance();
|
||||||
|
macros.setMacro(KOTLIN_BUNDLED, PathUtil.getKotlinPathsForIdeaPlugin().getHomePath().getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disposeComponent() {}
|
||||||
|
}
|
||||||
@@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user