diff --git a/resharper/src/ProjectModel/GodotMessagingClient.cs b/resharper/src/ProjectModel/GodotMessagingClient.cs index aad52b29..cdee4cca 100644 --- a/resharper/src/ProjectModel/GodotMessagingClient.cs +++ b/resharper/src/ProjectModel/GodotMessagingClient.cs @@ -3,14 +3,12 @@ using GodotTools.IdeMessaging; using GodotTools.IdeMessaging.Requests; using JetBrains.Application.Threading; -using JetBrains.Application.Threading.Tasks; using JetBrains.Collections.Viewable; using JetBrains.Lifetimes; using JetBrains.ProjectModel; using JetBrains.Rd.Base; using JetBrains.ReSharper.Feature.Services.Protocol; using JetBrains.Rider.Model.Godot.FrontendBackend; -using JetBrains.Threading; using JetBrains.Util; using ILogger = JetBrains.Util.ILogger; @@ -30,9 +28,11 @@ public GodotMessagingClient(ISolution solution, ILogger logger, Lifetime lifetim myLogger = logger; var model = solution.GetProtocolSolution().GetGodotFrontendBackendModel(); - model.MainProjectBasePath.AdviseOnce(lifetime, baseDir => + model.GodotDescriptor.AdviseOnce(lifetime, descriptor => { - myClient = new Client(Identity, baseDir, this, this); + if (descriptor.IsPureGdScriptProject) return; + + myClient = new Client(Identity, descriptor.MainProjectBasePath, this, this); SubscribeConnected(logger, threading, model); SubscribeDisconnected(logger, threading, model); myClient.Start(); @@ -42,7 +42,7 @@ public GodotMessagingClient(ISolution solution, ILogger logger, Lifetime lifetim private void SubscribeDisconnected(ILogger logger, IThreading threading, GodotFrontendBackendModel model) { // it looks like it subscribes to be called just once - myClient.AwaitDisconnected().ContinueWith(task => + myClient.AwaitDisconnected().ContinueWith(_ => { logger.Info("Godot Editor disconnected..."); model.EditorState.SetValue(GodotEditorState.Disconnected); @@ -52,7 +52,7 @@ private void SubscribeDisconnected(ILogger logger, IThreading threading, GodotFr private void SubscribeConnected(ILogger logger, IThreading threading, GodotFrontendBackendModel model) { - myClient.AwaitConnected().ContinueWith(task => + myClient.AwaitConnected().ContinueWith(_ => { logger.Info("Godot Editor connected..."); model.EditorState.SetValue(GodotEditorState.Connected); diff --git a/resharper/src/ProjectModel/GodotTracker.cs b/resharper/src/ProjectModel/GodotTracker.cs index 88fbfaa1..12febbd1 100644 --- a/resharper/src/ProjectModel/GodotTracker.cs +++ b/resharper/src/ProjectModel/GodotTracker.cs @@ -15,6 +15,11 @@ public class GodotTracker public GodotTracker(ISolution solution, ILogger logger, ISolutionLoadTasksScheduler tasksScheduler) { var model = solution.GetProtocolSolution().GetGodotFrontendBackendModel(); + if (solution.SolutionFile == null && solution.SolutionDirectory.Combine("project.godot").ExistsFile) + { + model.GodotDescriptor.SetValue(new GodotDescriptor(true, solution.SolutionDirectory.FullPath)); + } + tasksScheduler.EnqueueTask(new SolutionLoadTask(GetType(), SolutionLoadTaskKinds.Done, () => @@ -25,7 +30,7 @@ public GodotTracker(ISolution solution, ILogger logger, ISolutionLoadTasksSchedu if (!file.ExistsFile) continue; MainProjectBasePath = file.Directory; logger.Verbose($"Godot MainProjectBasePath: {file.Directory}"); - model.MainProjectBasePath.SetValue(file.Directory.FullPath); + model.GodotDescriptor.SetValue(new GodotDescriptor(false, file.Directory.FullPath)); break; } })); diff --git a/rider/protocol/src/kotlin/model/frontendBackend/GodotFrontendBackendModel.kt b/rider/protocol/src/kotlin/model/frontendBackend/GodotFrontendBackendModel.kt index 24ee2ef0..6da25f42 100644 --- a/rider/protocol/src/kotlin/model/frontendBackend/GodotFrontendBackendModel.kt +++ b/rider/protocol/src/kotlin/model/frontendBackend/GodotFrontendBackendModel.kt @@ -23,6 +23,11 @@ object GodotFrontendBackendModel : Ext(SolutionModel.Solution) { +"Connected" } + val GodotDescriptor = structdef("GodotDescriptor"){ + field("isPureGdScriptProject", bool).documentation = "True for pure GdScript project" + field("mainProjectBasePath", string).documentation = "Path to the folder with the project.godot" + } + init { setting(Kotlin11Generator.Namespace, "com.jetbrains.rider.model.godot.frontendBackend") setting(CSharp50Generator.Namespace, "JetBrains.Rider.Model.Godot.FrontendBackend") @@ -34,13 +39,14 @@ object GodotFrontendBackendModel : Ext(SolutionModel.Solution) { // Misc backend/fronted context property("godotPath", string).documentation = "Path to GodotEditor" - property("mainProjectBasePath", string).documentation = "Path to the folder with the project.godot" // Settings stored in the backend field("backendSettings", aggregatedef("GodotBackendSettings") { property("enableDebuggerExtensions", bool) }) + property("godotDescriptor", GodotDescriptor) + property("editorState", GodotEditorState) } } diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/FrontendBackendHost.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/FrontendBackendHost.kt index f1e362fb..690356a8 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/FrontendBackendHost.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/FrontendBackendHost.kt @@ -95,11 +95,11 @@ class FrontendBackendHost(project: Project) : LifetimedService() { task } - GodotProjectDiscoverer.getInstance(project).godotMonoPath.adviseNotNull(lifetime){ + GodotProjectDiscoverer.getInstance(project).godot3Path.adviseNotNull(lifetime){ model.godotPath.set(it) } - GodotProjectDiscoverer.getInstance(project).godotCorePath.adviseNotNull(lifetime){ s -> + GodotProjectDiscoverer.getInstance(project).godot4Path.adviseNotNull(lifetime){ s -> RiderDebuggerWorkerModelManager.getModels().adviseNotNull(lifetime){ model.backendSettings.enableDebuggerExtensions.flowInto(lifetime, diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/GodotProjectDiscoverer.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/GodotProjectDiscoverer.kt index 83c38ebd..7fbc4cf0 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/GodotProjectDiscoverer.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/GodotProjectDiscoverer.kt @@ -12,6 +12,7 @@ import com.jetbrains.rd.util.lifetime.Lifetime import com.jetbrains.rd.util.reactive.IProperty import com.jetbrains.rd.util.reactive.Property import com.jetbrains.rd.util.reactive.adviseNotNull +import com.jetbrains.rider.model.godot.frontendBackend.GodotDescriptor import com.jetbrains.rider.model.godot.frontendBackend.GodotFrontendBackendModel import com.jetbrains.rider.plugins.godot.run.GodotRunConfigurationGenerator import com.jetbrains.rider.plugins.godot.run.configurations.GodotDebugRunConfiguration @@ -24,18 +25,19 @@ import java.io.File @Service(Service.Level.PROJECT) class GodotProjectDiscoverer(project: Project) : LifetimedService() { - val mainProjectBasePath : IProperty = Property(null) + val godotDescriptor : IProperty = Property(null) private val logger = Logger.getInstance(GodotProjectDiscoverer::class.java) - val godotMonoPath : IProperty = Property(null) - val godotCorePath : IProperty = Property(null) + val godot3Path : IProperty = Property(null) + val godot4Path : IProperty = Property(null) init { - mainProjectBasePath.adviseNotNull(project.lifetime){ - logger.info("Godot mainProjectBasePath: $it") - godotMonoPath.set( - MetadataMonoFileWatcher.Util.getFromMonoMetadataPath(it) - ?: MetadataMonoFileWatcher.Util.getGodotPath(it) ?: getGodotPathFromPlayerRunConfiguration(project)) - godotCorePath.set(MetadataCoreFileWatcher.Util.getGodotPath(it) ?: getGodotPathFromCorePlayerRunConfiguration(project)) + godotDescriptor.adviseNotNull(project.lifetime){ + logger.info("Godot godotDescriptor: $it") + val basePath = File(it.mainProjectBasePath) + godot3Path.set( + MetadataMonoFileWatcher.Util.getFromMonoMetadataPath(basePath) + ?: MetadataMonoFileWatcher.Util.getGodotPath(basePath) ?: getGodotPathFromPlayerRunConfiguration(project)) + godot4Path.set(MetadataCoreFileWatcher.Util.getGodotPath(basePath) ?: getGodotPathFromCorePlayerRunConfiguration(project)) } } @@ -78,8 +80,8 @@ class GodotProjectDiscoverer(project: Project) : LifetimedService() { session: ClientProjectSession, model: GodotFrontendBackendModel ) { - model.mainProjectBasePath.adviseNotNull(lifetime) { - getInstance(session.project).mainProjectBasePath.set(it) + model.godotDescriptor.adviseNotNull(lifetime){ + getInstance(session.project).godotDescriptor.set(it) } } } diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataCoreFileWatcher.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataCoreFileWatcher.kt index 78668a57..427ad2b0 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataCoreFileWatcher.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataCoreFileWatcher.kt @@ -26,8 +26,7 @@ import kotlin.io.path.isDirectory class MetadataCoreFileWatcher : ProjectActivity { object Util { - fun getGodotPath(mainProjectBasePath: String): String? { - val projectPath = File(mainProjectBasePath) + fun getGodotPath(projectPath: File): String? { val projectMetadataCfg = projectPath.resolve(cfgDir).resolve(cfgFileName) if (projectMetadataCfg.exists()) { @@ -53,10 +52,11 @@ class MetadataCoreFileWatcher : ProjectActivity { withContext(Dispatchers.EDT) { project.solution.isLoaded.whenTrue(project.lifetime) {l-> val godotDiscoverer = GodotProjectDiscoverer.getInstance(project) - godotDiscoverer.mainProjectBasePath.viewNotNull(l) { lt, mainProjectBasePath -> + godotDiscoverer.godotDescriptor.viewNotNull(l) { lt, descriptor -> + val mainProjectBaseFile = File(descriptor.mainProjectBasePath) lt.launchBackground { val watchService: WatchService = FileSystems.getDefault().newWatchService() - val metaFileDir = File(mainProjectBasePath).resolve(cfgDir).toPath() + val metaFileDir = mainProjectBaseFile.resolve(cfgDir).toPath() withTimeout(Duration.ofMinutes(5)) { while (!(metaFileDir.isDirectory())) { @@ -81,11 +81,11 @@ class MetadataCoreFileWatcher : ProjectActivity { val context = event.context() ?: continue if (context.toString() == cfgFileName) { logger.info("GodotCoreProjectDiscoverer.getInstance(project).godotPath.set()") - val newPath = Util.getGodotPath(mainProjectBasePath) ?: continue + val newPath = Util.getGodotPath(mainProjectBaseFile) ?: continue logger.info("GodotCoreProjectDiscoverer.getInstance(project).godotPath.set($newPath)") application.invokeLater { logger.info("application.invokeLater GodotProjectDiscoverer.getInstance(project).godotPath.set($newPath)") - GodotProjectDiscoverer.getInstance(project).godotCorePath.set(newPath) + GodotProjectDiscoverer.getInstance(project).godot4Path.set(newPath) } } } diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataMonoFileWatcher.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataMonoFileWatcher.kt index feb876c7..c607a87b 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataMonoFileWatcher.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/MetadataMonoFileWatcher.kt @@ -30,7 +30,7 @@ class MetadataMonoFileWatcher : ProjectActivity { //Windows: %APPDATA%\Godot\projects\{PROJECT_NAME}_{MD5_OF_PROJECT_PATH}\ //macOS: $XDG_DATA_HOME/Godot/projects/{PROJECT_NAME}_{MD5_OF_PROJECT_PATH}/ or $HOME/Library/Application Support/Godot/projects/{PROJECT_NAME}_{MD5_OF_PROJECT_PATH}/ //Linux: $XDG_DATA_HOME/godot/projects/{PROJECT_NAME}_{MD5_OF_PROJECT_PATH}/ or $HOME/.local/share/godot/projects/{PROJECT_NAME}_{MD5_OF_PROJECT_PATH}/ - fun getGodotPath(projectPath: String): String? { + fun getGodotPath(projectPath: File): String? { val projectsSettingsPath = if (SystemInfo.isMac) { val home = Paths.get(System.getenv("HOME")) home.resolve("Library/Application Support/Godot/projects") @@ -43,8 +43,8 @@ class MetadataMonoFileWatcher : ProjectActivity { } else throw Exception("Unexpected OS.") - val md5 = projectPath.md5() - val projectSettingsPath = projectsSettingsPath.resolve("${Paths.get(projectPath).fileName}-$md5") + val md5 = projectPath.path.md5() + val projectSettingsPath = projectsSettingsPath.resolve("${projectPath.toPath().fileName}-$md5") val projectMetadataCfg = projectSettingsPath.resolve("project_metadata.cfg").toFile() if (projectMetadataCfg.exists()) { @@ -63,8 +63,7 @@ class MetadataMonoFileWatcher : ProjectActivity { return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0') } - fun getFromMonoMetadataPath(mainProjectBasePath: String): String? { - val basePath = File(mainProjectBasePath) + fun getFromMonoMetadataPath(basePath: File): String? { var metaFile = basePath.resolve(metaFileDir).resolve(metaFileName) if (!metaFile.exists()) metaFile = basePath.resolve(metaFileDir).resolve(oldMetaFileName) @@ -92,10 +91,12 @@ class MetadataMonoFileWatcher : ProjectActivity { withContext(Dispatchers.EDT) { project.solution.isLoaded.whenTrue(project.lifetime) { l -> val godotDiscoverer = GodotProjectDiscoverer.getInstance(project) - godotDiscoverer.mainProjectBasePath.viewNotNull(l) { lt, mainProjectBasePath -> + godotDiscoverer.godotDescriptor.viewNotNull(l) { lt, descriptor -> + if (descriptor.isPureGdScriptProject) return@viewNotNull + val mainProjectBasePath = File(descriptor.mainProjectBasePath) thread(name = "MetadataFileWatcher") { val watchService: WatchService = FileSystems.getDefault().newWatchService() - val metaFileDir = File(mainProjectBasePath).resolve(metaFileDir).toPath() + val metaFileDir = mainProjectBasePath.resolve(metaFileDir).toPath() if (!(metaFileDir.isDirectory())) return@thread @@ -117,7 +118,7 @@ class MetadataMonoFileWatcher : ProjectActivity { logger.info("GodotProjectDiscoverer.getInstance(project).godotPath.set($newPath)") application.invokeLater { logger.info("application.invokeLater GodotProjectDiscoverer.getInstance(project).godotPath.set($newPath)") - GodotProjectDiscoverer.getInstance(project).godotMonoPath.set(newPath) + GodotProjectDiscoverer.getInstance(project).godot3Path.set(newPath) } } } diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/GodotRunConfigurationGenerator.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/GodotRunConfigurationGenerator.kt index 4b07653b..839f25ae 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/GodotRunConfigurationGenerator.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/GodotRunConfigurationGenerator.kt @@ -3,6 +3,7 @@ package com.jetbrains.rider.plugins.godot.run import com.intellij.execution.RunManager import com.intellij.execution.configurations.ConfigurationTypeUtil import com.intellij.openapi.client.ClientProjectSession +import com.intellij.openapi.components.Service import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.jetbrains.rd.platform.util.idea.LifetimedService @@ -18,10 +19,13 @@ import com.jetbrains.rider.plugins.godot.run.configurations.GodotDebugRunConfigu import com.jetbrains.rider.projectView.solution import com.jetbrains.rider.run.configurations.dotNetExe.DotNetExeConfiguration import com.jetbrains.rider.run.configurations.dotNetExe.DotNetExeConfigurationType +import com.jetbrains.rider.run.configurations.exe.ExeConfiguration +import com.jetbrains.rider.run.configurations.exe.ExeConfigurationType import com.jetbrains.rider.run.configurations.remote.DotNetRemoteConfiguration import com.jetbrains.rider.run.configurations.remote.MonoRemoteConfigType import com.jetbrains.rider.runtime.dotNetCore.DotNetCoreRuntimeType +@Service class GodotRunConfigurationGenerator : LifetimedService() { companion object { @@ -38,11 +42,12 @@ class GodotRunConfigurationGenerator : LifetimedService() { val project = session.project project.solution.isLoaded.whenTrue(lifetime){ val godotDiscoverer = GodotProjectDiscoverer.getInstance(project) - godotDiscoverer.mainProjectBasePath.viewNotNull(lifetime) { lt, mainProjectBasePath -> - logger.info("isGodotProject = true") + godotDiscoverer.godotDescriptor.viewNotNull(lifetime) { lt, descriptor -> + logger.info("descriptor = $descriptor") + val basePath = descriptor.mainProjectBasePath val runManager = RunManager.getInstance(project) - GodotProjectDiscoverer.getInstance(project).godotCorePath.advise(lt) { corePath-> + GodotProjectDiscoverer.getInstance(project).godot4Path.advise(lt) { corePath-> if (corePath != null) { val toRemove = runManager.allSettings.filter { it.type is MonoRemoteConfigType && it.name == ATTACH_CONFIGURATION_NAME @@ -63,14 +68,23 @@ class GodotRunConfigurationGenerator : LifetimedService() { } } - GodotProjectDiscoverer.getInstance(project).godotMonoPath.adviseNotNull(lt){ path -> - createOrUpdateRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${mainProjectBasePath}\"", runManager, path, project) - createOrUpdateRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${mainProjectBasePath}\" --editor", runManager, path, project) + GodotProjectDiscoverer.getInstance(project).godot3Path.adviseNotNull(lt) { path -> + if (descriptor.isPureGdScriptProject){ + createOrUpdateGdScriptRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${basePath}\"", runManager, path, project) + createOrUpdateGdScriptRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${basePath}\" --editor", runManager, path, project) + return@adviseNotNull + } + createOrUpdateRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${basePath}\"", runManager, path, project) + createOrUpdateRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${basePath}\" --editor", runManager, path, project) } - - GodotProjectDiscoverer.getInstance(project).godotCorePath.adviseNotNull(lt){ path -> - createOrUpdateCoreRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${mainProjectBasePath}\"", runManager, path, project) - createOrUpdateCoreRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${mainProjectBasePath}\" --editor", runManager, path, project) + GodotProjectDiscoverer.getInstance(project).godot4Path.adviseNotNull(lt) { path -> + if (descriptor.isPureGdScriptProject){ + createOrUpdateGdScriptRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${basePath}\"", runManager, path, project) + createOrUpdateGdScriptRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${basePath}\" --editor", runManager, path, project) + return@adviseNotNull + } + createOrUpdateCoreRunConfiguration(PLAYER_CONFIGURATION_NAME, "--path \"${basePath}\"", runManager, path, project) + createOrUpdateCoreRunConfiguration(EDITOR_CONFIGURATION_NAME, "--path \"${basePath}\" --editor", runManager, path, project) } // make configuration selected if nothing is selected @@ -132,5 +146,30 @@ class GodotRunConfigurationGenerator : LifetimedService() { runManager.addConfiguration(runConfiguration) } } + + private fun createOrUpdateGdScriptRunConfiguration( + configurationName: String, + programParameters:String, + runManager: RunManager, + godotPath: String, + project: Project + ) { + val configs = runManager.allSettings.filter { it.type is ExeConfigurationType && it.name == configurationName } + if (configs.any()) { + configs.forEach{ + (it.configuration as ExeConfiguration).parameters.exePath = godotPath + } + } else { + val configurationType = ConfigurationTypeUtil.findConfigurationType(ExeConfigurationType::class.java) + val runConfiguration = runManager.createConfiguration(configurationName, configurationType.factory) + val config = runConfiguration.configuration as ExeConfiguration + config.parameters.exePath = godotPath + config.parameters.programParameters = programParameters + config.parameters.workingDirectory = "${project.basePath}" + config.beforeRunTasks.removeIf { true } + runConfiguration.storeInLocalWorkspace() + runManager.addConfiguration(runConfiguration) + } + } } } \ No newline at end of file diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducer.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducer.kt index c4df776d..5d6cc98c 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducer.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducer.kt @@ -12,9 +12,9 @@ import java.io.File class DebugSceneRunConfigurationProducer : LazyRunConfigurationProducer() { companion object{ - internal fun extractResPath(basePath:String, context: ConfigurationContext): String? { + internal fun extractResPath(basePath:File, context: ConfigurationContext): String? { val file = getContainingFile(context) ?: return null - val relPath = file.virtualFile.toIOFile().relativeTo(File(basePath)) + val relPath = file.virtualFile.toIOFile().relativeTo(basePath) return "res://$relPath" } @@ -28,10 +28,10 @@ class DebugSceneRunConfigurationProducer : LazyRunConfigurationProducer().factory override fun isConfigurationFromContext(configuration: GodotDebugRunConfiguration, context: ConfigurationContext): Boolean { - if (GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value == null) return false - if (GodotProjectDiscoverer.getInstance(context.project).godotMonoPath.value == null) return false + val basePath = GodotProjectDiscoverer.getInstance(context.project).godotDescriptor.value?.mainProjectBasePath ?: return false + if (GodotProjectDiscoverer.getInstance(context.project).godot3Path.value == null) return false - val resPath = extractResPath(GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value!!, context) ?: return false + val resPath = extractResPath(File(basePath), context) ?: return false return configuration.parameters.programParameters.contains(resPath) } @@ -39,15 +39,16 @@ class DebugSceneRunConfigurationProducer : LazyRunConfigurationProducer): Boolean { val file = getContainingFile(context) ?: return false - val resPath = extractResPath(GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value!!, context) ?: return false + val basePath = GodotProjectDiscoverer.getInstance(context.project).godotDescriptor.value?.mainProjectBasePath ?: return false + val resPath = extractResPath(File(basePath), context) ?: return false - val path = GodotProjectDiscoverer.getInstance(context.project).godotMonoPath.value + val path = GodotProjectDiscoverer.getInstance(context.project).godot3Path.value if (path == null || !File(path).exists()) { return false } configuration.parameters.exePath = path - configuration.parameters.programParameters = "--path \"${GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value}\" \"$resPath\"" + configuration.parameters.programParameters = "--path \"${basePath}\" \"$resPath\"" configuration.parameters.workingDirectory = "${context.project.basePath}" configuration.name = file.name diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducerCor.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducerCor.kt index cbba183a..31f4b013 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducerCor.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/run/configurations/DebugSceneRunConfigurationProducerCor.kt @@ -15,24 +15,25 @@ class DebugSceneRunConfigurationProducerCor : LazyRunConfigurationProducer().factory override fun isConfigurationFromContext(configuration: DotNetExeConfiguration, context: ConfigurationContext): Boolean { - if (GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value == null) return false - if (GodotProjectDiscoverer.getInstance(context.project).godotCorePath.value == null) return false + val basePath = GodotProjectDiscoverer.getInstance(context.project).godotDescriptor.value?.mainProjectBasePath ?: return false + if (GodotProjectDiscoverer.getInstance(context.project).godot4Path.value == null) return false - val resPath = DebugSceneRunConfigurationProducer.extractResPath(GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value!!, context) ?: return false + val resPath = DebugSceneRunConfigurationProducer.extractResPath(File(basePath), context) ?: return false return configuration.parameters.programParameters.contains(resPath) } override fun setupConfigurationFromContext(configuration: DotNetExeConfiguration, context: ConfigurationContext, sourceElement: Ref): Boolean { val file = DebugSceneRunConfigurationProducer.getContainingFile(context) ?: return false - val resPath = DebugSceneRunConfigurationProducer.extractResPath(GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value!!, context) ?: return false + val basePath = GodotProjectDiscoverer.getInstance(context.project).godotDescriptor.value?.mainProjectBasePath ?: return false + val resPath = DebugSceneRunConfigurationProducer.extractResPath(File(basePath), context) ?: return false - val path = GodotProjectDiscoverer.getInstance(context.project).godotCorePath.value + val path = GodotProjectDiscoverer.getInstance(context.project).godot4Path.value if (path == null || !File(path).exists()) { return false } configuration.parameters.exePath = path - configuration.parameters.programParameters = "--path \"${GodotProjectDiscoverer.getInstance(context.project).mainProjectBasePath.value}\" \"$resPath\"" + configuration.parameters.programParameters = "--path \"${File(basePath)}\" \"$resPath\"" configuration.parameters.workingDirectory = "${context.project.basePath}" configuration.parameters.runtimeType = DotNetCoreRuntimeType diff --git a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/ui/ToolbarActionsGroup.kt b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/ui/ToolbarActionsGroup.kt index 4524904e..216149dc 100644 --- a/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/ui/ToolbarActionsGroup.kt +++ b/rider/src/main/kotlin/com/jetbrains/rider/plugins/godot/ui/ToolbarActionsGroup.kt @@ -18,7 +18,8 @@ class ToolbarActionsGroup : DefaultActionGroup(), DumbAware, TooltipDescriptionP return } - e.presentation.isVisible = GodotProjectDiscoverer.getInstance(project).mainProjectBasePath.value != null + val descriptor = GodotProjectDiscoverer.getInstance(project).godotDescriptor.value + e.presentation.isVisible = descriptor != null && !descriptor.isPureGdScriptProject if (e.presentation.isVisible) { e.presentation.isEnabled = true diff --git a/rider/src/main/resources/META-INF/plugin.xml b/rider/src/main/resources/META-INF/plugin.xml index d189e2e5..5b30a6ee 100644 --- a/rider/src/main/resources/META-INF/plugin.xml +++ b/rider/src/main/resources/META-INF/plugin.xml @@ -28,7 +28,6 @@ -