Skip to content

Commit b8310be

Browse files
authored
Rider plugin 223 (#2064)
* [utbot-rider] 1. Removed unnecessary SolutionComponents 2. ProjectPublisher now cancels correctly 3. ProjectPublisher correctly spawn publishing process 4. VSharp type loading fixes, this allows generating tests for Rider SDK classes 5. Assemblies now resolve from Rider-provided set of assemblies 6. Removed VSharp log directories after test generation 7. Correctly checks for overloads in method 8. Bumped minimum compatible version to .NET 7 * [utbot-rider] 1. Bumped rd version to 2022.3.3 2. Rider plugin now shows consoles for publish and vsharp processes 3. Rider version is targeting 223 4. Introduced UtBotRiderModel, which available when includeRiderInBuild=true. It copies rider-model.jar to generate necessary files * [utbot-rider] Changes.xml * [utbot-rider] review fixes * [utbot-rider] Review fix
1 parent d6a1e30 commit b8310be

File tree

25 files changed

+956
-152
lines changed

25 files changed

+956
-152
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ intellijPluginVersion=1.13.1
4141
# every time you bump rd version:
4242
# 1. regenerate all models
4343
# 2. check if rider plugin works
44-
rdVersion=2022.2.1
44+
rdVersion=2022.3.3
4545
# to enable - add -PincludeRiderInBuild=true in build CLI
4646
includeRiderInBuild=false
4747
jacocoVersion=0.8.8

utbot-framework/src/main/kotlin/org/utbot/framework/process/generated/EngineProcessModel.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ class EngineProcessModel private constructor(
6565
fun create(lifetime: Lifetime, protocol: IProtocol): EngineProcessModel {
6666
EngineProcessRoot.register(protocol.serializers)
6767

68-
return EngineProcessModel().apply {
69-
identify(protocol.identity, RdId.Null.mix("EngineProcessModel"))
70-
bind(lifetime, protocol, "EngineProcessModel")
71-
}
68+
return EngineProcessModel()
7269
}
7370

7471

utbot-framework/src/main/kotlin/org/utbot/framework/process/generated/RdInstrumenterAdapter.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ class RdInstrumenterAdapter private constructor(
4242
fun create(lifetime: Lifetime, protocol: IProtocol): RdInstrumenterAdapter {
4343
EngineProcessRoot.register(protocol.serializers)
4444

45-
return RdInstrumenterAdapter().apply {
46-
identify(protocol.identity, RdId.Null.mix("RdInstrumenterAdapter"))
47-
bind(lifetime, protocol, "RdInstrumenterAdapter")
48-
}
45+
return RdInstrumenterAdapter()
4946
}
5047

5148
private val __StringNullableSerializer = FrameworkMarshallers.String.nullable()

utbot-framework/src/main/kotlin/org/utbot/framework/process/generated/RdSourceFindingStrategy.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ class RdSourceFindingStrategy private constructor(
4444
fun create(lifetime: Lifetime, protocol: IProtocol): RdSourceFindingStrategy {
4545
EngineProcessRoot.register(protocol.serializers)
4646

47-
return RdSourceFindingStrategy().apply {
48-
identify(protocol.identity, RdId.Null.mix("RdSourceFindingStrategy"))
49-
bind(lifetime, protocol, "RdSourceFindingStrategy")
50-
}
47+
return RdSourceFindingStrategy()
5148
}
5249

5350
private val __StringNullableSerializer = FrameworkMarshallers.String.nullable()

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/rd/generated/InstrumentedProcessModel.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ class InstrumentedProcessModel private constructor(
5454
fun create(lifetime: Lifetime, protocol: IProtocol): InstrumentedProcessModel {
5555
InstrumentedProcessRoot.register(protocol.serializers)
5656

57-
return InstrumentedProcessModel().apply {
58-
identify(protocol.identity, RdId.Null.mix("InstrumentedProcessModel"))
59-
bind(lifetime, protocol, "InstrumentedProcessModel")
60-
}
57+
return InstrumentedProcessModel()
6158
}
6259

6360

utbot-rd/build.gradle

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
plugins {
2-
id 'com.jetbrains.rdgen' version "2022.2.1"
2+
id 'com.jetbrains.rdgen' version "2022.3.3"
33
}
44

55
import com.jetbrains.rd.generator.gradle.RdGenExtension
66
import com.jetbrains.rd.generator.gradle.RdGenTask
77

8+
if (includeRiderInBuild.toBoolean()) {
9+
def utbotRider = project.rootProject.childProjects["utbot-rider"]
10+
evaluationDependsOn(utbotRider.path)
11+
tasks.getByName("classes").dependsOn(utbotRider.tasks.getByName("addRiderModelsToUtbotModels"))
12+
}
13+
814
compileKotlin {
915
kotlinOptions {
1016
jvmTarget = JavaVersion.VERSION_1_8
@@ -26,6 +32,8 @@ configurations {
2632
lifetimedProcessMockCompileClasspath.extendsFrom configurations.compileClasspath
2733
processWithRdServerMockCompileClasspath.extendsFrom configurations.compileClasspath
2834
rdgenModelsCompileClasspath.extendsFrom configurations.compileClasspath
35+
if (includeRiderInBuild.toBoolean())
36+
riderRdgenModelsCompileClasspath.extendsFrom configurations.rdgenModelsCompileClasspath
2937
}
3038

3139
sourceSets {
@@ -44,8 +52,17 @@ sourceSets {
4452
srcDirs = ["src/main/rdgen"]
4553
}
4654
}
55+
if (includeRiderInBuild.toBoolean()) {
56+
riderRdgenModels {
57+
kotlin {
58+
srcDirs = ["src/main/riderRdgenModels"]
59+
}
60+
}
61+
}
4762
}
4863

64+
def riderModelJar = new File(project.buildDir, "libs/rider-model.jar")
65+
4966
dependencies {
5067
implementation project(':utbot-core')
5168
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
@@ -56,6 +73,10 @@ dependencies {
5673
processWithRdServerMockImplementation project(':utbot-rd')
5774

5875
rdgenModelsCompileClasspath group: 'com.jetbrains.rd', name: 'rd-gen', version: rdVersion
76+
77+
if (includeRiderInBuild.toBoolean()) {
78+
riderRdgenModelsCompileClasspath files(riderModelJar)
79+
}
5980
}
6081

6182
task lifetimedProcessMockJar(type: Jar) {
@@ -99,6 +120,50 @@ test {
99120
systemProperty("PROCESS_WITH_RD_SERVER_MOCK", processWithRdServerMockJar.archiveFile.get().getAsFile().canonicalPath)
100121
}
101122

123+
if (includeRiderInBuild.toBoolean()) {
124+
def currentProjectDir = project.projectDir
125+
def riderProject = project.rootProject.childProjects["utbot-rider"]
126+
def riderTask = riderProject.tasks.getByName("addRiderModelsToUtbotModels")
127+
// !!!! IMPORTANT !!!!
128+
// after generation you should MANUALLY correct kotlin generated code as it is incorrectly references some rider model
129+
// mandatory steps:
130+
// 1. In UtBotRiderModel.Generated.kt change package to `package org.utbot.rider.generated`
131+
// 2. then import all unreferenced classes
132+
// otherwise you will have broken plugin initialization and ClassNotFoundException
133+
task generateRiderModels(type: RdGenTask) {
134+
dependsOn(riderTask)
135+
136+
def riderProjectDir = riderProject.projectDir
137+
def generatedOutputDir = new File(riderProjectDir, "src/main/kotlin/org/utbot/rider/generated")
138+
def hashDir = generatedOutputDir
139+
def sourcesDir = new File(currentProjectDir, "src/main/riderRdgenModels/org/utbot/rider/rd/models")
140+
def rdParams = extensions.getByName("params") as RdGenExtension
141+
142+
group = "rdgen"
143+
rdParams.verbose = true
144+
rdParams.sources(sourcesDir)
145+
rdParams.hashFolder = hashDir.canonicalPath
146+
rdParams.packages = "org.utbot.rider.rd.models"
147+
rdParams.classpath(riderModelJar)
148+
149+
rdParams.generator {
150+
language = "kotlin"
151+
transform = "symmetric"
152+
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
153+
directory = generatedOutputDir.canonicalPath
154+
namespace = "org.utbot.rider.generated"
155+
}
156+
157+
rdParams.generator {
158+
language = "csharp"
159+
transform = "symmetric"
160+
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
161+
namespace = "UtBot"
162+
directory = new File(riderProjectDir, "src/dotnet/UtBot/UtBot/Generated")
163+
}
164+
}
165+
}
166+
102167
task generateInstrumentedProcessModels(type: RdGenTask) {
103168
def currentProjectDir = project.projectDir
104169
def instrumentationProjectDir = project.rootProject.childProjects["utbot-instrumentation"].projectDir

utbot-rd/src/main/kotlin/org/utbot/rd/generated/LoggerModel.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class LoggerModel private constructor(
4343
fun create(lifetime: Lifetime, protocol: IProtocol): LoggerModel {
4444
LoggerRoot.register(protocol.serializers)
4545

46-
return LoggerModel().apply {
47-
identify(protocol.identity, RdId.Null.mix("LoggerModel"))
48-
bind(lifetime, protocol, "LoggerModel")
49-
}
46+
return LoggerModel()
5047
}
5148

5249

utbot-rd/src/main/kotlin/org/utbot/rd/generated/SettingsModel.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class SettingsModel private constructor(
4343
fun create(lifetime: Lifetime, protocol: IProtocol): SettingsModel {
4444
SettingsRoot.register(protocol.serializers)
4545

46-
return SettingsModel().apply {
47-
identify(protocol.identity, RdId.Null.mix("SettingsModel"))
48-
bind(lifetime, protocol, "SettingsModel")
49-
}
46+
return SettingsModel()
5047
}
5148

5249

utbot-rd/src/main/kotlin/org/utbot/rd/generated/SynchronizationModel.Generated.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ class SynchronizationModel private constructor(
4444
fun create(lifetime: Lifetime, protocol: IProtocol): SynchronizationModel {
4545
SynchronizationRoot.register(protocol.serializers)
4646

47-
return SynchronizationModel().apply {
48-
identify(protocol.identity, RdId.Null.mix("SynchronizationModel"))
49-
bind(lifetime, protocol, "SynchronizationModel")
50-
}
47+
return SynchronizationModel()
5148
}
5249

5350

utbot-rd/src/main/rdgen/org/utbot/rd/models/CSharpModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ object VSharpModel: Ext(CSharpRoot) {
1313
field("parameters", immutableList(PredefinedType.string))
1414
}
1515

16+
val mapEntry = structdef {
17+
field("key", PredefinedType.string)
18+
field("value", PredefinedType.string)
19+
}
20+
1621
val generateArguments = structdef {
1722
field("assemblyPath", PredefinedType.string)
1823
field("projectCsprojPath", PredefinedType.string)
1924
field("solutionFilePath", PredefinedType.string)
2025
field("methods", immutableList(methodDescriptor))
2126
field("generationTimeoutInSeconds", PredefinedType.int)
2227
field("targetFramework", PredefinedType.string.nullable)
28+
field("assembliesFullNameToTheirPath", immutableList(mapEntry))
2329
}
2430

2531
val generateResults = structdef {

0 commit comments

Comments
 (0)