Closed DanTup closed 3 months ago
@kenzieschmoll @CoderDake I have a mostly-working sidebar over DTD (in the mock editor... haven't done any real Dart-Code side yet) in https://github.com/flutter/devtools/pull/7919 though it still needs some tweaks.
Since the change is quite large, I'm trying to split it up. This one adds the new DTD API interface, but doesn't use DTD yet. It just wraps the old postMessage
API to behave like the new DTD one, allowing the sidebar code itself to be updated for the new API but still work with the existing postMessage
API from VS Code. This is essentially a no-op refactor, but it means implementing the DTD part will not involve changes to some of these tests and the sidebar UI code.
I'm working on supporting the Sidebar over DTD. The full in-progress change is at https://github.com/flutter/devtools/pull/7919 but it's getting quite large since the DTD API is slightly different (better) than the
postMessage
one and we should support both for some transition period (to handle old editor plugin versions). The plan is to build the new DTD APIs and then just provide wrappers around thepostMessage
API to make it the same (so the sidebar code can just work against one interface).This PR takes all the non-DTD implementation from that PR which is basically a refactor of the
postMessage
classes, the sidebar (to use the new DTD-like APIs) and tests (again, to use the new DTD-like APIs). This will make the next PRs smaller because they're just adding the DTD implementation without changing the sidebar implementation, tests etc.There are some differences in how the APIs work.. the new API will get
getDevices()
and thendeviceAdded
events, whereas thepostMessage
API just sends adevicesUpdated
event with the full set of devices on every change (and always sends an initial set as part of initialization). The wrapper (PostMessageEditorClient
) handles these differences.A summary of the changes:
devtools_app/lib/src/editor/
contains the new API classes and interfaces for a client and server of the editor functionalityPostMessageEditorClient
class is a wrapper over the postMessage API (DartToolingApiImpl
, nowPostMessageToolApiImpl
) that implements the new DTD interface (including handling differences between how the events work, such as having no getDevices() and getting a full set of devices in each device event)EditorClient
(which currently is always the wrapper over postMessage, but can be a DTD implementation), and the Sidebar ("FlutterPanel") widget is updated to handle the new eventsEditorClient
in place of the old postMessage APIFakeDartToolingApi
) was replaced with aFakeEditor
mixin that is agnostic to postMessage/DTD and provides the mock editor functionality for the mock editor stager app (and maybe can be used in more tests)