Skip to content

Commit 049a8b8

Browse files
authored
Fix DDC compilation error for the Dart Debug Extension (#1594)
1 parent a0b9bae commit 049a8b8

File tree

4 files changed

+1375
-1376
lines changed

4 files changed

+1375
-1376
lines changed

dwds/debug_extension/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Notify the debugger and inspector panels when the debug session is disconnected.
44
- Provide a detailed error message when the debugger fails to connect.
55
- Send an event to the server when the debugger is detached.
6+
- Fix compilation errors when the extension is built with DDC.
67

78
## 1.28
89

dwds/debug_extension/CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ pub run build_runner build web -o build -r
88

99
This will build to the `/web` directory.
1010

11-
TODO(elliette): Building with DDC no longer works, figure out why.
12-
See https://github.com/dart-lang/webdev/issues/1506
1311
- With DDC:
1412

1513
```

dwds/debug_extension/web/background.dart

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ final _tabsToAttach = <Tab>{};
4848

4949
final _debugSessions = <DebugSession>[];
5050

51-
final _devToolsPanelsNotifier = Notifier(<DevToolsPanel>[]);
51+
final _devToolsPanelsNotifier =
52+
Notifier<List<DevToolsPanel>>(<DevToolsPanel>[]);
5253

5354
// Keeps track of the most recent Dart tab that was opened. This is a heuristic
5455
// to let us guess which tab the user is trying to debug if they start debugging
@@ -178,9 +179,9 @@ void _startDebugging(DebuggerTrigger debuggerTrigger) {
178179
// Extracts the extension backend port from the injected JS.
179180
var attachDebuggerToTab = allowInterop(_attachDebuggerToTab);
180181

181-
queryTabs(getCurrentTabQuery, allowInterop((List<Tab> tabs) {
182-
if (tabs != null && tabs.isNotEmpty) {
183-
attachDebuggerToTab(tabs[0]);
182+
queryTabs(getCurrentTabQuery, allowInterop((List tabs) {
183+
if (tabs.isNotEmpty) {
184+
attachDebuggerToTab(tabs.first as Tab);
184185
} else if (_mostRecentDartTab != null) {
185186
attachDebuggerToTab(_mostRecentDartTab);
186187
} else {
@@ -371,8 +372,9 @@ void _forwardMessageToExternalExtensions(
371372
}
372373
}
373374

374-
void _notifyPanelScriptOfChanges(List<DevToolsPanel> panels) {
375-
for (final panel in panels) {
375+
void _notifyPanelScriptOfChanges(List panels) {
376+
final panelsList = List<DevToolsPanel>.from(panels);
377+
for (final panel in panelsList) {
376378
sendSimpleMessage(panel.panelId,
377379
SimpleMessage(recipient: 'panel-script', body: panel.devToolsUri));
378380
}
@@ -532,7 +534,8 @@ Future<void> _startSseClient(
532534

533535
void _updateOrCreateDevToolsPanel(
534536
String appId, void Function(DevToolsPanel panel) update) {
535-
final devToolsPanels = _devToolsPanelsNotifier.value;
537+
final devToolsPanels =
538+
List<DevToolsPanel>.from(_devToolsPanelsNotifier.value);
536539
var panelAlreadyExists = false;
537540
for (final panel in devToolsPanels) {
538541
if (panel.appId == appId) {
@@ -551,19 +554,18 @@ void _updateOrCreateDevToolsPanel(
551554
void _updateIcon() {
552555
var query = QueryInfo(active: true, currentWindow: true);
553556
queryTabs(query, allowInterop((List tabs) {
554-
var tabList = List<Tab>.from(tabs);
555557
// If tabList is empty, the user has likely navigated to a different window.
556558
// Therefore, do not update the icon:
557-
if (tabList.isEmpty || tabList.first == null || tabList.first.id == null) {
558-
return;
559-
}
559+
if (tabs.isEmpty) return;
560+
final tab = tabs.first as Tab;
561+
if (tab.id == null) return;
560562

561-
if (_tabIdToWarning.containsKey(tabList.first.id)) {
563+
if (_tabIdToWarning.containsKey(tab.id)) {
562564
// Set the warning icon (red):
563565
setIcon(IconInfo(path: 'dart_warning.png'));
564-
} else if (_debuggableTabs.contains(tabList.first.id)) {
566+
} else if (_debuggableTabs.contains(tab.id)) {
565567
// Set the debuggable icon (blue):
566-
_mostRecentDartTab = tabList.first;
568+
_mostRecentDartTab = tab;
567569
setIcon(IconInfo(path: 'dart.png'));
568570
} else {
569571
// Set the default icon (grey):
@@ -595,7 +597,7 @@ class Notifier<T> {
595597
Notifier(T value) : _value = value;
596598

597599
T _value;
598-
final List<Listener> _listeners = <Listener>[];
600+
final List<Listener<T>> _listeners = <Listener<T>>[];
599601

600602
T get value => _value;
601603

@@ -604,7 +606,7 @@ class Notifier<T> {
604606
notifyListeners();
605607
}
606608

607-
void addListener(Listener listener) {
609+
void addListener(Listener<T> listener) {
608610
_listeners.add(listener);
609611
}
610612

0 commit comments

Comments
 (0)