Add languageSetting provider
Access to facets could be heavy #KTIJ-23501
This commit is contained in:
committed by
teamcity
parent
d7a58a7c6c
commit
2ec07b861b
@@ -34,8 +34,9 @@ import org.jetbrains.kotlin.types.Variance
|
|||||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||||
|
|
||||||
class MainFunctionDetector {
|
class MainFunctionDetector {
|
||||||
|
private val languageVersionSettings: LanguageVersionSettings by lazy { getLanguageVersionSettings() }
|
||||||
private val getFunctionDescriptor: (KtNamedFunction) -> FunctionDescriptor?
|
private val getFunctionDescriptor: (KtNamedFunction) -> FunctionDescriptor?
|
||||||
private val languageVersionSettings: LanguageVersionSettings
|
private val getLanguageVersionSettings: () -> LanguageVersionSettings
|
||||||
|
|
||||||
/** Assumes that the function declaration is already resolved and the descriptor can be found in the `bindingContext`. */
|
/** Assumes that the function declaration is already resolved and the descriptor can be found in the `bindingContext`. */
|
||||||
constructor(bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings) {
|
constructor(bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings) {
|
||||||
@@ -44,14 +45,22 @@ class MainFunctionDetector {
|
|||||||
?: throw throw KotlinExceptionWithAttachments("No descriptor resolved for $function")
|
?: throw throw KotlinExceptionWithAttachments("No descriptor resolved for $function")
|
||||||
.withPsiAttachment("function.text", function)
|
.withPsiAttachment("function.text", function)
|
||||||
}
|
}
|
||||||
this.languageVersionSettings = languageVersionSettings
|
this.getLanguageVersionSettings = { languageVersionSettings }
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(languageVersionSettings: LanguageVersionSettings, functionResolver: (KtNamedFunction) -> FunctionDescriptor?) {
|
constructor(
|
||||||
|
languageVersionSettingsProvider: () -> LanguageVersionSettings,
|
||||||
|
functionResolver: (KtNamedFunction) -> FunctionDescriptor?
|
||||||
|
) {
|
||||||
|
this.getLanguageVersionSettings = languageVersionSettingsProvider
|
||||||
this.getFunctionDescriptor = functionResolver
|
this.getFunctionDescriptor = functionResolver
|
||||||
this.languageVersionSettings = languageVersionSettings
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
languageVersionSettings: LanguageVersionSettings,
|
||||||
|
functionResolver: (KtNamedFunction) -> FunctionDescriptor?
|
||||||
|
) : this({ languageVersionSettings }, functionResolver)
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun isMain(
|
fun isMain(
|
||||||
function: KtNamedFunction,
|
function: KtNamedFunction,
|
||||||
|
|||||||
Reference in New Issue
Block a user