Use ServiceLoader instead of IntelliJ extensions for ScriptHelper
This commit is contained in:
+1
@@ -0,0 +1 @@
|
|||||||
|
org.jetbrains.kotlin.script.ScriptHelperImpl
|
||||||
+1
-1
@@ -49,7 +49,7 @@ class LazyScriptClassMemberScope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createScriptParameters(constructor: ClassConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
private fun createScriptParameters(constructor: ClassConstructorDescriptorImpl): List<ValueParameterDescriptor> {
|
||||||
return ScriptHelper.getInstance()!!.getScriptParameters(scriptDescriptor.scriptDefinition, scriptDescriptor).mapIndexed { index, (name, type) ->
|
return ScriptHelper.getInstance().getScriptParameters(scriptDescriptor.scriptDefinition, scriptDescriptor).mapIndexed { index, (name, type) ->
|
||||||
ValueParameterDescriptorImpl(
|
ValueParameterDescriptorImpl(
|
||||||
constructor, null, index, Annotations.EMPTY, name, type,
|
constructor, null, index, Annotations.EMPTY, name, type,
|
||||||
/* declaresDefaultValue = */ false,
|
/* declaresDefaultValue = */ false,
|
||||||
|
|||||||
+1
-1
@@ -80,5 +80,5 @@ class LazyScriptDescriptor(
|
|||||||
|
|
||||||
override fun getUnsubstitutedPrimaryConstructor() = super.getUnsubstitutedPrimaryConstructor()!!
|
override fun getUnsubstitutedPrimaryConstructor() = super.getUnsubstitutedPrimaryConstructor()!!
|
||||||
|
|
||||||
override fun computeSupertypes() = listOf(ScriptHelper.getInstance()!!.getKotlinType(this, scriptDefinition.template)).ifEmpty { listOf(builtIns.anyType) }
|
override fun computeSupertypes() = listOf(ScriptHelper.getInstance().getKotlinType(this, scriptDefinition.template)).ifEmpty { listOf(builtIns.anyType) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.script
|
package org.jetbrains.kotlin.script
|
||||||
|
|
||||||
import com.intellij.openapi.extensions.ExtensionPointName
|
|
||||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import java.util.*
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
data class ScriptParameter(val name: Name, val type: KotlinType)
|
data class ScriptParameter(val name: Name, val type: KotlinType)
|
||||||
@@ -29,8 +29,10 @@ interface ScriptHelper {
|
|||||||
fun getKotlinType(scriptDescriptor: ScriptDescriptor, kClass: KClass<out Any>): KotlinType
|
fun getKotlinType(scriptDescriptor: ScriptDescriptor, kClass: KClass<out Any>): KotlinType
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val EP_NAME = ExtensionPointName.create<ScriptHelper>("org.jetbrains.kotlin.scriptHelper")
|
private val scriptHelperInstance: ScriptHelper =
|
||||||
|
ServiceLoader.load(ScriptHelper::class.java, ScriptHelper::class.java.classLoader).firstOrNull()
|
||||||
|
?: error("ScriptHelper implementation is not found")
|
||||||
|
|
||||||
fun getInstance(): ScriptHelper? = EP_NAME.extensions.firstOrNull()
|
fun getInstance(): ScriptHelper = scriptHelperInstance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
interface="org.jetbrains.kotlin.idea.facet.KotlinVersionInfoProvider"/>
|
interface="org.jetbrains.kotlin.idea.facet.KotlinVersionInfoProvider"/>
|
||||||
<extensionPoint name="gradleModelFacade"
|
<extensionPoint name="gradleModelFacade"
|
||||||
interface="org.jetbrains.kotlin.idea.inspections.gradle.KotlinGradleModelFacade"/>
|
interface="org.jetbrains.kotlin.idea.inspections.gradle.KotlinGradleModelFacade"/>
|
||||||
<extensionPoint name="scriptHelper"
|
|
||||||
interface="org.jetbrains.kotlin.script.ScriptHelper"/>
|
|
||||||
<extensionPoint name="completionInformationProvider"
|
<extensionPoint name="completionInformationProvider"
|
||||||
interface="org.jetbrains.kotlin.idea.completion.CompletionInformationProvider" />
|
interface="org.jetbrains.kotlin.idea.completion.CompletionInformationProvider" />
|
||||||
<extensionPoint name="moduleBuilder"
|
<extensionPoint name="moduleBuilder"
|
||||||
|
|||||||
@@ -2,6 +2,5 @@
|
|||||||
<id>org.jetbrains.kotlin</id>
|
<id>org.jetbrains.kotlin</id>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
<scriptHelper implementation="org.jetbrains.kotlin.script.ScriptHelperImpl"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
Reference in New Issue
Block a user