override fun extensionCreated()

in rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/GodotRunConfigurationGenerator.kt [54:117]


        override fun extensionCreated(lifetime: Lifetime, session: ClientProjectSession, model: GodotFrontendBackendModel) {
            val project = session.project
            project.solution.isLoaded.whenTrue(lifetime){
                val godotDiscoverer = GodotProjectDiscoverer.getInstance(project)
                godotDiscoverer.godotDescriptor.viewNotNull(lifetime) { lt, descriptor ->
                    logger.info("descriptor = $descriptor")
                    val tempRelPath = Paths.get(descriptor.mainProjectBasePath).relativeToOrSelf(project.solutionDirectory.toPath())
                    val relPath = if (tempRelPath.pathString.isEmpty()) "./" else tempRelPath
                    val runManager = RunManager.getInstance(project)

                    // todo: remove in 261
                    run {
                        val toRemove = runManager.allSettings.filter {
                            it.type is GdScriptConfigurationType && it.name == PLAYER_GDSCRIPT_ATTACH_CONFIGURATION_NAME_OLD
                        }
                        for (value in toRemove) {
                            runManager.removeConfiguration(value)
                        }
                    }

                    GodotProjectDiscoverer.getInstance(project).godot4Path.advise(lt) { corePath->
                        if (corePath != null) {
                            val toRemove = runManager.allSettings.filter {
                                it.type is MonoRemoteConfigType && it.name == ATTACH_CONFIGURATION_NAME
                            }
                            for (value in toRemove) {
                                runManager.removeConfiguration(value)
                            }
                        }
                        else if (!descriptor.isPureGdScriptProject){
                            if (!runManager.allSettings.any { it.type is MonoRemoteConfigType && it.name == ATTACH_CONFIGURATION_NAME }) {
                                val configurationType = ConfigurationTypeUtil.findConfigurationType(MonoRemoteConfigType::class.java)
                                val runConfiguration = runManager.createConfiguration(ATTACH_CONFIGURATION_NAME, configurationType.factory)
                                val remoteConfig = runConfiguration.configuration as DotNetRemoteConfiguration
                                remoteConfig.port = godotDiscoverer.port
                                runConfiguration.storeInLocalWorkspace()
                                runManager.addConfiguration(runConfiguration)
                            }
                        }
                    }

                    GodotProjectDiscoverer.getInstance(project).godot3Path.adviseNotNull(lt) { path ->
                        createOrUpdateRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${relPath}\"", runManager, path, project)
                        createOrUpdateRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${relPath}\" --editor", runManager, path, project)
                        selectConfigurationIfNeeded(runManager)
                    }
                    GodotProjectDiscoverer.getInstance(project).godot4Path.adviseNotNull(lt) { path ->
                        createOrUpdateCoreRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${relPath}\"", runManager, path, project)
                        createOrUpdateCoreRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${relPath}\" --editor", runManager, path, project)
                        selectConfigurationIfNeeded(runManager)
                    }

                    GodotProjectDiscoverer.getInstance(project).godotPath.adviseNotNull(lt) { path ->
                        createOrUpdateGdScriptRunConfiguration(PLAYER_GDSCRIPT_CONFIGURATION_NAME, runManager)
                        createOrUpdateGdScriptRunConfiguration(PLAYER_GDSCRIPT_ATTACH_CONFIGURATION_NAME, runManager, true)
                        if (descriptor.isPureGdScriptProject){
                            createOrUpdateNativeExecutableRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${relPath}\" --editor", runManager, path, project)
                            selectConfigurationIfNeeded(runManager)
                        }
                        selectConfigurationIfNeeded(runManager)
                    }
                }
            }
        }