Skip to content

[CQ] remove pre-2024 reflective support for myDisplayName #8354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions src/io/flutter/run/LaunchState.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,34 +168,20 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
// The descriptor shows the run configuration name (e.g., `main.dart`) by default;
// adding the device name will help users identify the instance when trying to operate a specific one.
final String nameWithDeviceName = descriptor.getDisplayName() + " (" + device.deviceName() + ")";
boolean displayNameUpdated = false;

try {
// Find "myDisplayNameView" for 2024+ builds.
// https://github.com/JetBrains/intellij-community/blob/idea/241.14494.240/platform/execution/src/com/intellij/execution/ui/RunContentDescriptor.java#L33
// There is no public way to set display name so we resort to reflection.
final Field f = descriptor.getClass().getDeclaredField("myDisplayNameView");
f.setAccessible(true);
Object viewInstance = f.get(descriptor);
if (viewInstance != null) {
final Method setValueMethod = viewInstance.getClass().getMethod("setValue", Object.class);
setValueMethod.invoke(viewInstance, nameWithDeviceName);
displayNameUpdated = true;
}
}
catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) {
LOG.info(e);
}
if (!displayNameUpdated) {
try {
// Find "myDisplayName" for 2023 builds.
// https://github.com/JetBrains/intellij-community/blob/idea/231.8109.175/platform/execution/src/com/intellij/execution/ui/RunContentDescriptor.java#L30
final Field f = descriptor.getClass().getDeclaredField("myDisplayName");
f.setAccessible(true);
f.set(descriptor, nameWithDeviceName);
}
catch (IllegalAccessException | NoSuchFieldException e) {
LOG.info(e);
}
}

return descriptor;
}
Expand Down