/
RsDebugProcessConfigurator.kt
32 lines (29 loc) · 1.33 KB
/
RsDebugProcessConfigurator.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package org.rust.debugger.runconfig
import com.jetbrains.cidr.execution.debugger.CidrDebugProcess
import com.jetbrains.cidr.execution.debugger.CidrDebugProcessConfigurator
import org.rust.cargo.project.model.cargoProjects
class RsDebugProcessConfigurator : CidrDebugProcessConfigurator {
override fun configure(process: CidrDebugProcess) {
val cargoProject = when {
process is RsLocalDebugProcess -> {
// In case of Rust project, select the corresponding Cargo project
process.runParameters.cargoProject
}
process.project.cargoProjects.hasAtLeastOneValidProject -> {
// In case of cross-language project (e.g. C project with some Rust code inside),
// we actually don't know which Cargo project will be used during execution.
// So any of the available Rust projects can be selected
process.project.cargoProjects.allProjects.firstOrNull()
}
else -> {
// Otherwise, don't configure the debug process for Rust
return
}
}
RsDebugProcessConfigurationHelper(process, cargoProject, isCrossLanguage = true).configure()
}
}