Refactoring: extract function for getting project
This commit is contained in:
+10
-10
@@ -19,22 +19,22 @@ package org.jetbrains.kotlin.idea.configuration
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent
|
||||
|
||||
class KotlinExternalSystemSyncListener : ExternalSystemTaskNotificationListenerAdapter() {
|
||||
override fun onStart(id: ExternalSystemTaskId, workingDir: String) {
|
||||
if (id.type == ExternalSystemTaskType.RESOLVE_PROJECT) {
|
||||
id.findProject()?.let { project ->
|
||||
KotlinConfigurationCheckerComponent.getInstance(project).syncStarted()
|
||||
}
|
||||
}
|
||||
val project = id.findResolvedProject() ?: return
|
||||
KotlinConfigurationCheckerComponent.getInstance(project).syncStarted()
|
||||
}
|
||||
|
||||
override fun onEnd(id: ExternalSystemTaskId) {
|
||||
if (id.type == ExternalSystemTaskType.RESOLVE_PROJECT) {
|
||||
id.findProject()?.let { project ->
|
||||
KotlinConfigurationCheckerComponent.getInstance(project).syncDone()
|
||||
}
|
||||
}
|
||||
val project = id.findResolvedProject() ?: return
|
||||
KotlinConfigurationCheckerComponent.getInstance(project).syncDone()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ExternalSystemTaskId.findResolvedProject(): Project? {
|
||||
if (type != ExternalSystemTaskType.RESOLVE_PROJECT) return null
|
||||
return findProject()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user