Skip to content

Commit 2bdfdf1

Browse files
authored
Merge branch 'master' into verifier_removeUnneededFreeArgs
2 parents fd8b548 + 1b2fa45 commit 2bdfdf1

File tree

13 files changed

+75
-76
lines changed

13 files changed

+75
-76
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ intellijPlatform {
166166
cliPath = file("./third_party/lib/verifier-cli-1.388-all.jar")
167167
failureLevel = listOf(
168168
// TODO(team) Ideally all of the following FailureLevels should be enabled:
169-
// TODO(team) Create a tracking issue for each of the following validations
170-
// VerifyPluginTask.FailureLevel.COMPATIBILITY_WARNINGS,
169+
// https://github.com/flutter/flutter-intellij/issues/8361
170+
VerifyPluginTask.FailureLevel.COMPATIBILITY_WARNINGS,
171171
VerifyPluginTask.FailureLevel.COMPATIBILITY_PROBLEMS,
172172
// VerifyPluginTask.FailureLevel.DEPRECATED_API_USAGES, // https://github.com/flutter/flutter-intellij/issues/7718
173173
// VerifyPluginTask.FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES,
174-
// VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES,
174+
VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES,
175175
// VerifyPluginTask.FailureLevel.INTERNAL_API_USAGES,
176176
// VerifyPluginTask.FailureLevel.OVERRIDE_ONLY_API_USAGES,
177177
VerifyPluginTask.FailureLevel.NON_EXTENDABLE_API_USAGES,
178178
VerifyPluginTask.FailureLevel.PLUGIN_STRUCTURE_WARNINGS,
179-
// VerifyPluginTask.FailureLevel.MISSING_DEPENDENCIES,
179+
VerifyPluginTask.FailureLevel.MISSING_DEPENDENCIES,
180180
VerifyPluginTask.FailureLevel.INVALID_PLUGIN,
181181
// VerifyPluginTask.FailureLevel.NOT_DYNAMIC,
182182
)

src/io/flutter/actions/DeviceSelectorAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ public class DeviceSelectorAction extends ComboBoxAction implements DumbAware {
4545
return ActionUpdateThread.BGT;
4646
}
4747

48-
@NotNull
4948
@Override
50-
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
49+
protected @NotNull DefaultActionGroup createPopupActionGroup(@NotNull JComponent button, @NotNull DataContext dataContext) {
5150
final DefaultActionGroup group = new DefaultActionGroup();
5251
group.addAll(actions);
5352
return group;

src/io/flutter/actions/OpenAndroidModule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.jetbrains.annotations.Nullable;
2222
import org.jetbrains.plugins.gradle.util.GradleConstants;
2323

24-
import java.awt.event.InputEvent;
24+
import java.awt.event.ActionEvent;
2525
import java.nio.file.Path;
2626

2727
import static com.android.tools.idea.gradle.project.ProjectImportUtil.findGradleTarget;
@@ -42,8 +42,8 @@ public void actionPerformed(@NotNull AnActionEvent e) {
4242
}
4343
final int modifiers = e.getModifiers();
4444
// From ReopenProjectAction.
45-
final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)
46-
|| BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)
45+
final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, ActionEvent.CTRL_MASK)
46+
|| BitUtil.isSet(modifiers, ActionEvent.SHIFT_MASK)
4747
|| e.getPlace() == ActionPlaces.WELCOME_SCREEN;
4848

4949
VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE);

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
}

src/io/flutter/run/bazelTest/FlutterBazelTestConfigurationEditorForm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
1313
import com.intellij.openapi.util.io.FileUtil;
1414
import com.intellij.openapi.util.text.StringUtil;
15-
import com.intellij.ui.ListCellRendererWrapper;
15+
import com.intellij.ui.SimpleListCellRenderer;
1616
import com.jetbrains.lang.dart.ide.runner.server.ui.DartCommandLineConfigurationEditorForm;
1717
import io.flutter.run.bazelTest.BazelTestFields.Scope;
1818
import io.flutter.settings.FlutterSettings;
@@ -62,7 +62,7 @@ public FlutterBazelTestConfigurationEditorForm(final Project project) {
6262
updateFields(next);
6363
render(next);
6464
});
65-
scope.setRenderer(new ListCellRendererWrapper<>() {
65+
scope.setRenderer(new SimpleListCellRenderer<>() {
6666
@Override
6767
public void customize(final JList list,
6868
final Scope value,

src/io/flutter/run/test/TestForm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.intellij.openapi.options.SettingsEditor;
1010
import com.intellij.openapi.project.Project;
1111
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
12-
import com.intellij.ui.ListCellRendererWrapper;
12+
import com.intellij.ui.SimpleListCellRenderer;
1313
import io.flutter.run.test.TestFields.Scope;
1414
import org.jetbrains.annotations.NotNull;
1515

@@ -51,7 +51,7 @@ public class TestForm extends SettingsEditor<TestConfig> {
5151
updateFields(next);
5252
render(next);
5353
});
54-
scope.setRenderer(new ListCellRendererWrapper<>() {
54+
scope.setRenderer(new SimpleListCellRenderer<>() {
5555
@Override
5656
public void customize(final JList list,
5757
final Scope value,

src/io/flutter/sdk/FlutterSdkUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ private static void updateKnownPaths(@SuppressWarnings("SameParameterValue") @No
7878
final PropertiesComponent props = PropertiesComponent.getInstance();
7979

8080
// Add the existing known paths.
81-
final String[] oldPaths = props.getValues(propertyKey);
81+
final List<String> oldPaths = props.getList(propertyKey);
8282
if (oldPaths != null) {
83-
allPaths.addAll(Arrays.asList(oldPaths));
83+
allPaths.addAll(oldPaths);
8484
}
8585

8686
// Store the values back.
@@ -131,9 +131,9 @@ public static String[] getKnownFlutterSdkPaths() {
131131
}
132132

133133
// use the list of paths they've entered in the past
134-
final String[] knownPaths = PropertiesComponent.getInstance().getValues(FLUTTER_SDK_KNOWN_PATHS);
134+
final List<String> knownPaths = PropertiesComponent.getInstance().getList(FLUTTER_SDK_KNOWN_PATHS);
135135
if (knownPaths != null) {
136-
paths.addAll(Arrays.asList(knownPaths));
136+
paths.addAll(knownPaths);
137137
}
138138

139139
// search the user's path

src/io/flutter/toolwindow/ToolWindowBadgeUpdater.java

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,81 @@
1010
import com.intellij.openapi.wm.ToolWindow;
1111
import com.intellij.openapi.wm.ToolWindowId;
1212
import com.intellij.openapi.wm.ToolWindowManager;
13-
import com.intellij.ui.BadgeIcon;
1413
import io.flutter.run.common.RunMode;
1514
import io.flutter.run.daemon.FlutterApp;
1615

17-
import java.awt.Color;
18-
import java.awt.Paint;
16+
import javax.swing.*;
17+
import java.awt.*;
1918
import java.util.Objects;
20-
import javax.swing.Icon;
2119

2220
public class ToolWindowBadgeUpdater {
23-
public static final Paint BADGE_PAINT = Color.decode("#5ca963");
21+
public static final Color BADGE_PAINT = Color.decode("#5ca963");
2422

2523
/**
2624
* Updates the tool window icons for RUN or DEBUG mode with a green badge.
2725
*
28-
* @param app The FlutterApp instance running in a given mode.
26+
* @param app The FlutterApp instance running in a given mode.
2927
* @param project The current IntelliJ project context.
3028
*/
3129
public static void updateBadgedIcon(FlutterApp app, Project project) {
3230
final ToolWindowManager manager = ToolWindowManager.getInstance(Objects.requireNonNull(project));
3331
final ToolWindow runToolWindow = manager.getToolWindow(ToolWindowId.RUN);
3432
final ToolWindow debugToolWindow = manager.getToolWindow(ToolWindowId.DEBUG);
3533

36-
if(Objects.requireNonNull(app).getMode() == RunMode.RUN) {
34+
if (Objects.requireNonNull(app).getMode() == RunMode.RUN) {
3735
if (runToolWindow != null) {
3836
manager.invokeLater(() -> {
3937
Icon baseIcon = AllIcons.Toolwindows.ToolWindowRun;
4038
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);
41-
4239
runToolWindow.setIcon(iconWithBadge);
4340
});
4441
}
4542
}
46-
else if(app.getMode() == RunMode.DEBUG) {
43+
else if (app.getMode() == RunMode.DEBUG) {
4744
manager.invokeLater(() -> {
4845
Icon baseIcon = AllIcons.Toolwindows.ToolWindowDebugger;
4946
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);
50-
5147
Objects.requireNonNull(debugToolWindow).setIcon(iconWithBadge);
5248
});
5349
}
50+
}
51+
52+
private static class BadgeIcon implements Icon {
53+
private final Icon baseIcon;
54+
private final Color overlayColor;
55+
private static final float alpha = 1.0F;
56+
57+
public BadgeIcon(Icon baseIcon, Color overlayColor) {
58+
this.baseIcon = baseIcon;
59+
this.overlayColor = overlayColor;
60+
}
61+
62+
@Override
63+
public void paintIcon(Component c, Graphics g, int x, int y) {
64+
baseIcon.paintIcon(c, g, x, y);
65+
66+
Graphics2D g2d = (Graphics2D)g.create();
67+
try {
68+
g2d.translate(x, y);
69+
70+
g2d.setComposite(AlphaComposite.SrcOver.derive(alpha));
71+
72+
g2d.setColor(overlayColor);
73+
g2d.fillRect(0, 0, getIconWidth(), getIconHeight());
74+
}
75+
finally {
76+
g2d.dispose();
77+
}
78+
}
79+
80+
@Override
81+
public int getIconWidth() {
82+
return baseIcon.getIconWidth();
83+
}
5484

85+
@Override
86+
public int getIconHeight() {
87+
return baseIcon.getIconHeight();
88+
}
5589
}
5690
}

src/io/flutter/utils/GradleUtils.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -213,29 +213,7 @@ private static GradleSettingsFile parseSettings(Project project) {
213213

214214
@SuppressWarnings("rawtypes")
215215
private static BuildModelContext makeBuildModelContext(Project project) {
216-
// return BuildModelContext.create(project);
217-
Method method = ReflectionUtil.getDeclaredMethod(BuildModelContext.class, "create", Project.class);
218-
if (method != null) {
219-
try {
220-
return (BuildModelContext)method.invoke(null, project);
221-
}
222-
catch (IllegalAccessException | InvocationTargetException e) {
223-
throw new RuntimeException(e);
224-
}
225-
}
226-
// If we get here we're using the 4.1 API.
227-
// return BuildModelContext.create(project, new AndroidLocationProvider());
228-
Class locationProviderClass = AndroidLocationProvider.class.getInterfaces()[0];
229-
// Class.forName("com.android.tools.idea.gradle.dsl.model.BuildModelContext.ResolvedConfigurationFileLocationProvider");
230-
// does not work in the debugger. That's why we get it from the interfaces of AndroidLocationProvider.
231-
method = ReflectionUtil.getDeclaredMethod(BuildModelContext.class, "create", Project.class, locationProviderClass);
232-
assert method != null;
233-
try {
234-
return (BuildModelContext)method.invoke(null, project, new AndroidLocationProvider());
235-
}
236-
catch (IllegalAccessException | InvocationTargetException e) {
237-
throw new RuntimeException(e);
238-
}
216+
return BuildModelContext.create(project, new AndroidLocationProvider());
239217
}
240218

241219
// The project is an Android project that contains a Flutter module.

src/io/flutter/vmService/VmServiceWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ private void checkDone() {
600600

601601
@Override
602602
public void onError(RPCError error) {
603-
LOG.error(error);
603+
LOG.error(error.toString());
604604
LOG.error(error.getMessage());
605605
LOG.error(error.getRequest());
606606
LOG.error(error.getDetails());

0 commit comments

Comments
 (0)