@@ -168,34 +168,20 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
168
168
// The descriptor shows the run configuration name (e.g., `main.dart`) by default;
169
169
// adding the device name will help users identify the instance when trying to operate a specific one.
170
170
final String nameWithDeviceName = descriptor .getDisplayName () + " (" + device .deviceName () + ")" ;
171
- boolean displayNameUpdated = false ;
171
+
172
172
try {
173
- // Find "myDisplayNameView" for 2024+ builds.
174
- // https://github.com/JetBrains/intellij-community/blob/idea/241.14494.240/platform/execution/src/com/intellij/execution/ui/RunContentDescriptor.java#L33
173
+ // There is no public way to set display name so we resort to reflection.
175
174
final Field f = descriptor .getClass ().getDeclaredField ("myDisplayNameView" );
176
175
f .setAccessible (true );
177
176
Object viewInstance = f .get (descriptor );
178
177
if (viewInstance != null ) {
179
178
final Method setValueMethod = viewInstance .getClass ().getMethod ("setValue" , Object .class );
180
179
setValueMethod .invoke (viewInstance , nameWithDeviceName );
181
- displayNameUpdated = true ;
182
180
}
183
181
}
184
182
catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e ) {
185
183
LOG .info (e );
186
184
}
187
- if (!displayNameUpdated ) {
188
- try {
189
- // Find "myDisplayName" for 2023 builds.
190
- // https://github.com/JetBrains/intellij-community/blob/idea/231.8109.175/platform/execution/src/com/intellij/execution/ui/RunContentDescriptor.java#L30
191
- final Field f = descriptor .getClass ().getDeclaredField ("myDisplayName" );
192
- f .setAccessible (true );
193
- f .set (descriptor , nameWithDeviceName );
194
- }
195
- catch (IllegalAccessException | NoSuchFieldException e ) {
196
- LOG .info (e );
197
- }
198
- }
199
185
200
186
return descriptor ;
201
187
}
0 commit comments