Skip to content

Commit 1fd1674

Browse files
authored
[CQ] remove pre-2024 reflective support for myDisplayName (#8354)
Ideally there'd be no reflection here but at least this gets rid of the conditional support for 2023. See: #8352 --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent 2455dd0 commit 1fd1674

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/io/flutter/run/LaunchState.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,20 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
168168
// The descriptor shows the run configuration name (e.g., `main.dart`) by default;
169169
// adding the device name will help users identify the instance when trying to operate a specific one.
170170
final String nameWithDeviceName = descriptor.getDisplayName() + " (" + device.deviceName() + ")";
171-
boolean displayNameUpdated = false;
171+
172172
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.
175174
final Field f = descriptor.getClass().getDeclaredField("myDisplayNameView");
176175
f.setAccessible(true);
177176
Object viewInstance = f.get(descriptor);
178177
if (viewInstance != null) {
179178
final Method setValueMethod = viewInstance.getClass().getMethod("setValue", Object.class);
180179
setValueMethod.invoke(viewInstance, nameWithDeviceName);
181-
displayNameUpdated = true;
182180
}
183181
}
184182
catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) {
185183
LOG.info(e);
186184
}
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-
}
199185

200186
return descriptor;
201187
}

0 commit comments

Comments
 (0)