in src/main/kotlin/org/jetbrains/tinygoplugin/services/TinyGoInfoExtractor.kt [135:191]
suspend fun extractTinyGoInfo(
settings: TinyGoConfiguration,
failureListener: TinyGoExtractionFailureListener? = null,
onFinish: (GoExecutor.ExecutionResult?, String) -> Unit,
) {
val currentGoSdk = project.service<GoSdkService>().getSdk(null)
if (currentGoSdk == GoSdk.NULL) {
notifyTinyGoNotConfigured(
project,
TinyGoBundle.message(GO_NOT_CONFIGURED_MESSAGE)
)
logger.debug(GO_NOT_CONFIGURED_MESSAGE)
return
}
if (settings.targetPlatform.isEmpty()) {
notifyTinyGoNotConfigured(
project,
TinyGoBundle.message(TINYGO_TARGET_PLATFORM_NOT_SET)
)
logger.debug(TINYGO_TARGET_PLATFORM_NOT_SET)
return
}
logger.debug("Waiting for TinyGo parameters extraction task")
withBackgroundProgress(project, TinyGoBundle.message(DETECTION_TITLE), cancellable = true) {
reportRawProgress { reporter ->
if (currentGoSdk is GoDownloadingSdk) {
logger.debug("Waiting until Go SDK will be downloaded")
reporter.text(TinyGoBundle.message(WAIT_GO_TITLE))
while (project.service<GoSdkService>().getSdk(null) is GoDownloadingSdk) {
delay(1.seconds.inWholeMilliseconds)
}
}
logger.debug("Go SDK present")
var reloadNeeded = false
if (settings.sdk is TinyGoDownloadingSdk) {
logger.debug("Waiting until TinyGo SDK will be downloaded. Explicit library reload needed")
reporter.text(TinyGoBundle.message(WAIT_TINYGO_TITLE))
while (settings.sdk is TinyGoDownloadingSdk) {
delay(1.seconds.inWholeMilliseconds)
}
reloadNeeded = true
}
logger.debug("TinyGo SDK present")
executor.execute(
settings.sdk.sdkRoot,
tinyGoExtractionArguments(settings),
failureListener,
onFinish
)
if (reloadNeeded) {
logger.debug("Explicit library reload needed. Sending reload signal")
sendReloadLibrariesSignal(project)
}
}
}
logger.debug("TinyGo parameters extraction task finished")
}