Skip to content

[CQ] rename Flutter -> InspectorView #8169

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
May 8, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions flutter-idea/src/io/flutter/FlutterInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import io.flutter.survey.FlutterSurveyNotifications;
import io.flutter.utils.FlutterModuleUtils;
import io.flutter.utils.OpenApiUtils;
import io.flutter.view.FlutterViewFactory;
import io.flutter.view.InspectorViewFactory;
import org.jetbrains.annotations.NotNull;

import java.time.LocalDate;
Expand Down Expand Up @@ -366,7 +366,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {

private void initializeToolWindows(@NotNull final Project project) {
// Start watching for Flutter debug active events.
FlutterViewFactory.init(project);
InspectorViewFactory.init(project);
RemainingDevToolsViewFactory.init(project);
DevToolsExtensionsViewFactory.init(project);
toolWindowsInitialized = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.flutter.settings.FlutterSettings;
import io.flutter.utils.JsonUtils;
import io.flutter.view.EmbeddedBrowser;
import io.flutter.view.FlutterView;
import io.flutter.view.InspectorView;
import io.flutter.vmService.VmServiceConsumers;
import org.dartlang.vm.service.VmService;
import org.dartlang.vm.service.consumer.GetObjectConsumer;
Expand Down Expand Up @@ -372,7 +372,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
return;
}

final ToolWindow toolWindow = toolWindowManager.getToolWindow(FlutterView.TOOL_WINDOW_ID);
final ToolWindow toolWindow = toolWindowManager.getToolWindow(InspectorView.TOOL_WINDOW_ID);
if (toolWindow != null && !toolWindow.isVisible()) {
toolWindow.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ex.ToolWindowManagerListener;
import io.flutter.view.FlutterView;
import io.flutter.view.InspectorView;
import org.jetbrains.annotations.NotNull;

public class FlutterViewToolWindowManagerListener implements ToolWindowManagerListener {
public class InspectorViewToolWindowManagerListener implements ToolWindowManagerListener {
private boolean inspectorIsOpen;
private Runnable onWindowOpen;
private Runnable onWindowFirstVisible;

public FlutterViewToolWindowManagerListener(Project project, ToolWindow toolWindow) {
public InspectorViewToolWindowManagerListener(Project project, ToolWindow toolWindow) {
project.getMessageBus().connect().subscribe(ToolWindowManagerListener.TOPIC, this);

inspectorIsOpen = toolWindow.isShowStripeButton();
Expand All @@ -33,7 +33,7 @@ public void updateOnWindowFirstVisible(Runnable onWindowFirstVisible) {

@Override
public void stateChanged(@NotNull ToolWindowManager toolWindowManager) {
final ToolWindow inspectorWindow = toolWindowManager.getToolWindow(FlutterView.TOOL_WINDOW_ID);
final ToolWindow inspectorWindow = toolWindowManager.getToolWindow(InspectorView.TOOL_WINDOW_ID);
if (inspectorWindow == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
import io.flutter.sdk.FlutterSdk;
import io.flutter.sdk.FlutterSdkVersion;
import io.flutter.settings.FlutterSettings;
import io.flutter.toolwindow.FlutterViewToolWindowManagerListener;
import io.flutter.toolwindow.InspectorViewToolWindowManagerListener;
import io.flutter.utils.*;
import org.dartlang.vm.service.VmService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand All @@ -55,30 +56,27 @@
import java.util.concurrent.atomic.AtomicReference;

@com.intellij.openapi.components.State(
name = "FlutterView",
name = "InspectorView",
storages = {@Storage("$WORKSPACE_FILE$")}
)
public class FlutterView implements PersistentStateComponent<FlutterViewState>, Disposable {
private static final Logger LOG = Logger.getInstance(FlutterView.class);
public class InspectorView implements PersistentStateComponent<InspectorViewState>, Disposable {
private static final Logger LOG = Logger.getInstance(InspectorView.class);

public static final String TOOL_WINDOW_ID = "Flutter Inspector";
public static final @NotNull String TOOL_WINDOW_ID = "Flutter Inspector";

public static final String WIDGET_TAB_LABEL = "Widgets";
public static final String RENDER_TAB_LABEL = "Render Tree";
public static final String PERFORMANCE_TAB_LABEL = "Performance";
protected static final String INSTALLATION_IN_PROGRESS_LABEL = "Installing JxBrowser and DevTools...";
protected static final String INSTALLATION_TIMED_OUT_LABEL =
"Waiting for JxBrowser installation timed out. Restart your IDE to try again.";
protected static final String INSTALLATION_WAIT_FAILED = "The JxBrowser installation failed unexpectedly. Restart your IDE to try again.";
protected static final String DEVTOOLS_FAILED_LABEL = "Setting up DevTools failed.";
protected static final int INSTALLATION_WAIT_LIMIT_SECONDS = 2000;

protected final EventStream<Boolean> shouldAutoHorizontalScroll = new EventStream<>(FlutterViewState.AUTO_SCROLL_DEFAULT);
protected final EventStream<Boolean> highlightNodesShownInBothTrees =
new EventStream<>(FlutterViewState.HIGHLIGHT_NODES_SHOWN_IN_BOTH_TREES_DEFAULT);
protected final @NotNull EventStream<Boolean> shouldAutoHorizontalScroll = new EventStream<>(InspectorViewState.AUTO_SCROLL_DEFAULT);
protected final @NotNull EventStream<Boolean> highlightNodesShownInBothTrees =
new EventStream<>(InspectorViewState.HIGHLIGHT_NODES_SHOWN_IN_BOTH_TREES_DEFAULT);

@NotNull
private final FlutterViewState state = new FlutterViewState();
private final InspectorViewState state = new InspectorViewState();

@VisibleForTesting
@NotNull
Expand All @@ -87,23 +85,23 @@ public class FlutterView implements PersistentStateComponent<FlutterViewState>,
@NotNull
private final Project myProject;

private Content emptyContent;
private @Nullable Content emptyContent;

private FlutterViewToolWindowManagerListener toolWindowListener;
private InspectorViewToolWindowManagerListener toolWindowListener;
private int devToolsInstallCount = 0;
private final JxBrowserUtils jxBrowserUtils;
private final JxBrowserManager jxBrowserManager;

public FlutterView(@NotNull Project project) {
public InspectorView(@NotNull Project project) {
this(project, JxBrowserManager.getInstance(), new JxBrowserUtils(), new ViewUtils());
}

@VisibleForTesting
@NonInjectable
protected FlutterView(@NotNull Project project,
@NotNull JxBrowserManager jxBrowserManager,
JxBrowserUtils jxBrowserUtils,
ViewUtils viewUtils) {
protected InspectorView(@NotNull Project project,
@NotNull JxBrowserManager jxBrowserManager,
JxBrowserUtils jxBrowserUtils,
ViewUtils viewUtils) {
myProject = project;
this.jxBrowserUtils = jxBrowserUtils;
this.jxBrowserManager = jxBrowserManager;
Expand All @@ -120,7 +118,7 @@ public void dispose() {

@NotNull
@Override
public FlutterViewState getState() {
public InspectorViewState getState() {
return state;
}

Expand All @@ -130,14 +128,14 @@ public Project getProject() {
}

@Override
public void loadState(@NotNull FlutterViewState state) {
public void loadState(@NotNull InspectorViewState state) {
this.state.copyFrom(state);

shouldAutoHorizontalScroll.setValue(this.state.getShouldAutoScroll());
highlightNodesShownInBothTrees.setValue(this.state.getHighlightNodesShownInBothTrees());
}

void initToolWindow(ToolWindow window) {
void initToolWindow(@NotNull ToolWindow window) {
if (window.isDisposed()) return;

updateForEmptyContent(window);
Expand Down Expand Up @@ -264,7 +262,7 @@ protected void verifyEventDispatchThread() {
@VisibleForTesting
protected void setUpToolWindowListener(FlutterApp app, ToolWindow toolWindow, boolean isEmbedded, DevToolsIdeFeature ideFeature) {
if (this.toolWindowListener == null) {
this.toolWindowListener = new FlutterViewToolWindowManagerListener(myProject, toolWindow);
this.toolWindowListener = new InspectorViewToolWindowManagerListener(myProject, toolWindow);
}
this.toolWindowListener.updateOnWindowOpen(() -> {
devToolsInstallCount += 1;
Expand Down Expand Up @@ -432,13 +430,13 @@ private void replacePanelLabel(ToolWindow toolWindow, JComponent label) {
});
}

private void debugActiveHelper(FlutterApp app) {
private void debugActiveHelper(@NotNull FlutterApp app) {
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
if (!(toolWindowManager instanceof ToolWindowManagerEx)) {
return;
}

final ToolWindow toolWindow = toolWindowManager.getToolWindow(FlutterView.TOOL_WINDOW_ID);
final ToolWindow toolWindow = toolWindowManager.getToolWindow(InspectorView.TOOL_WINDOW_ID);
if (toolWindow == null) {
return;
}
Expand All @@ -464,7 +462,7 @@ private void debugActiveHelper(FlutterApp app) {
}
else {
if (toolWindowListener == null) {
toolWindowListener = new FlutterViewToolWindowManagerListener(myProject, toolWindow);
toolWindowListener = new InspectorViewToolWindowManagerListener(myProject, toolWindow);
}
// If the window isn't visible yet, only executed embedded browser steps when it becomes visible.
toolWindowListener.updateOnWindowFirstVisible(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindowManager;
import io.flutter.utils.OpenApiUtils;
import io.flutter.utils.ViewListener;
import org.jetbrains.annotations.NotNull;

public class FlutterViewFactory implements ToolWindowFactory, DumbAware {
public class InspectorViewFactory implements ToolWindowFactory, DumbAware {
private static final String TOOL_WINDOW_VISIBLE_PROPERTY = "flutter.view.tool.window.visible";

public static void init(@NotNull Project project) {
project.getMessageBus().connect().subscribe(
FlutterViewMessages.FLUTTER_DEBUG_TOPIC, (FlutterViewMessages.FlutterDebugNotifier)(event) -> initFlutterView(project, event)
FlutterViewMessages.FLUTTER_DEBUG_TOPIC, (FlutterViewMessages.FlutterDebugNotifier)(event) -> initInspectorView(project, event)
);

final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(FlutterView.TOOL_WINDOW_ID);
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(InspectorView.TOOL_WINDOW_ID);
if (window != null) {
window.setAvailable(true);

Expand All @@ -39,24 +38,18 @@ public boolean shouldBeAvailable(@NotNull Project project) {
return false;
}

private static void initFlutterView(@NotNull Project project, FlutterViewMessages.FlutterDebugEvent event) {
private static void initInspectorView(@NotNull Project project, FlutterViewMessages.FlutterDebugEvent event) {
OpenApiUtils.safeInvokeLater(() -> {
final FlutterView flutterView = project.getService(FlutterView.class);
flutterView.debugActive(event);
final InspectorView inspectorView = project.getService(InspectorView.class);
inspectorView.debugActive(event);
});
}

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
//noinspection CodeBlock2Expr
DumbService.getInstance(project).runWhenSmart(() -> {
project.getService(FlutterView.class).initToolWindow(toolWindow);
project.getService(InspectorView.class).initToolWindow(toolWindow);
});
}

public static class FlutterViewListener extends ViewListener {
public FlutterViewListener(@NotNull Project project) {
super(project, FlutterView.TOOL_WINDOW_ID, TOOL_WINDOW_VISIBLE_PROPERTY);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

import com.intellij.util.EventDispatcher;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.NotNull;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
* State for the Flutter view.
* State for the Inspector view.
*/
public class FlutterViewState {
public class InspectorViewState {
public static final boolean AUTO_SCROLL_DEFAULT = false;
public static final boolean HIGHLIGHT_NODES_SHOWN_IN_BOTH_TREES_DEFAULT = false;

private final EventDispatcher<ChangeListener> dispatcher = EventDispatcher.create(ChangeListener.class);
private final @NotNull EventDispatcher<ChangeListener> dispatcher = EventDispatcher.create(ChangeListener.class);

@Attribute(value = "splitter-proportion")
public float splitterProportion;
Expand All @@ -29,7 +30,7 @@ public class FlutterViewState {
@Attribute(value = "highlight-nodes-shown-in-both-trees")
public boolean highlightNodesShownInBothTrees = HIGHLIGHT_NODES_SHOWN_IN_BOTH_TREES_DEFAULT;

public FlutterViewState() {
public InspectorViewState() {
}

public float getSplitterProportion() {
Expand Down Expand Up @@ -58,7 +59,7 @@ public void removeListener(ChangeListener listener) {
dispatcher.removeListener(listener);
}

void copyFrom(FlutterViewState other) {
void copyFrom(InspectorViewState other) {
splitterProportion = other.splitterProportion;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Double getCurrentDisplayRefreshRateRaw() {

private CompletableFuture<Double> getDisplayRefreshRate() {
final CompletableFuture<Double> displayRefreshRate = new CompletableFuture<>();
vmServiceManager.getFlutterViewId().whenComplete((String id, Throwable throwable) -> {
vmServiceManager.getInspectorViewId().whenComplete((String id, Throwable throwable) -> {
if (throwable != null) {
// We often see "java.lang.RuntimeException: Method not found" from here; perhaps a race condition?
LOG.warn(throwable.getMessage());
Expand All @@ -102,11 +102,11 @@ private CompletableFuture<Double> getDisplayRefreshRate() {
return displayRefreshRate;
}

private CompletableFuture<Double> invokeGetDisplayRefreshRate(String flutterViewId) {
private CompletableFuture<Double> invokeGetDisplayRefreshRate(String inspectorViewId) {
final CompletableFuture<Double> ret = new CompletableFuture<>();

final JsonObject params = new JsonObject();
params.addProperty("viewId", flutterViewId);
params.addProperty("viewId", inspectorViewId);

vmService.callServiceExtension(
vmServiceManager.getCurrentFlutterIsolateRaw().getId(), ServiceExtensions.displayRefreshRate, params,
Expand Down
4 changes: 2 additions & 2 deletions flutter-idea/src/io/flutter/vmService/VMServiceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,14 @@ private void unregisterService(String serviceName) {
}
}

public CompletableFuture<String> getFlutterViewId() {
public CompletableFuture<String> getInspectorViewId() {
return getFlutterViewsList().exceptionally(exception -> {
throw new RuntimeException(exception.getMessage());
}).thenApplyAsync((JsonElement element) -> {
final JsonArray viewsList = element.getAsJsonObject().get("views").getAsJsonArray();
for (JsonElement jsonElement : viewsList) {
final JsonObject view = jsonElement.getAsJsonObject();
if (Objects.equals(view.get("type").getAsString(), "FlutterView")) {
if (Objects.equals(view.get("type").getAsString(), "InspectorView")) {
return view.get("id").getAsString();
}
}
Expand Down
Loading