cleanup — get extensions as list

This commit is contained in:
Vladimir Krivosheev
2018-08-03 22:16:29 +02:00
parent 6050d5d693
commit 06a5bccc02
2 changed files with 9 additions and 9 deletions
@@ -42,7 +42,7 @@ class RunConfigurableTest {
private fun createRunManager(element: Element): RunManagerImpl {
val runManager = RunManagerImpl(projectRule.project)
runManager.initializeConfigurationTypes(arrayOf(ApplicationConfigurationType.getInstance(), JUnitConfigurationType.getInstance()))
runManager.initializeConfigurationTypes(listOf(ApplicationConfigurationType.getInstance(), JUnitConfigurationType.getInstance()))
runManager.loadState(element)
return runManager
}
@@ -148,7 +148,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
get() = project.messageBus.syncPublisher(RunManagerListener.TOPIC)
init {
initializeConfigurationTypes(ConfigurationType.CONFIGURATION_TYPE_EP.extensions)
initializeConfigurationTypes(ConfigurationType.CONFIGURATION_TYPE_EP.extensionList)
project.messageBus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
override fun rootsChanged(event: ModuleRootEvent) {
selectedConfiguration?.let {
@@ -159,7 +159,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
}
// separate method needed for tests
fun initializeConfigurationTypes(factories: Array<ConfigurationType>) {
fun initializeConfigurationTypes(factories: List<ConfigurationType>) {
val types = factories.toMutableList()
types.sortBy { it.displayName }
types.add(UnknownConfigurationType.INSTANCE)
@@ -531,11 +531,11 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
}
val nameGenerator = UniqueNameGenerator()
workspaceSchemeManagerProvider.load(parentNode) {
var schemeKey: String? = it.getAttributeValue("name")
workspaceSchemeManagerProvider.load(parentNode) { element ->
var schemeKey: String? = element.getAttributeValue("name")
if (schemeKey == "<template>" || schemeKey == null) {
// scheme name must be unique
it.getAttributeValue("type")?.let {
element.getAttributeValue("type")?.let {
if (schemeKey == null) {
schemeKey = "<template>"
}
@@ -543,7 +543,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
}
}
else if (schemeKey != null) {
val typeId = it.getAttributeValue("type")
val typeId = element.getAttributeValue("type")
if (typeId == null) {
LOG.warn("typeId is null for '${schemeKey}'")
}
@@ -555,7 +555,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
schemeKey = nameGenerator.generateUniqueName("Unnamed")
}
else {
schemeKey = "${schemeKey!!}, factoryName: ${it.getAttributeValue("factoryName", "")}"
schemeKey = "${schemeKey!!}, factoryName: ${element.getAttributeValue("factoryName", "")}"
nameGenerator.addExistingName(schemeKey!!)
}
schemeKey!!
@@ -649,7 +649,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
fun clearAll() {
clear(true)
idToType.clear()
initializeConfigurationTypes(emptyArray())
initializeConfigurationTypes(emptyList())
}
private fun clear(allConfigurations: Boolean) {