@@ -79,18 +79,12 @@ enum Trigger {
79
79
extensionPanel,
80
80
extensionIcon;
81
81
82
- String get clientName {
83
- switch (this ) {
84
- case Trigger .angularDartDevTools:
85
- return 'acx-devtools' ;
86
- case Trigger .cider:
87
- return 'cider' ;
88
- case Trigger .extensionPanel:
89
- return 'embedded-devtools' ;
90
- case Trigger .extensionIcon:
91
- return 'devtools' ;
92
- }
93
- }
82
+ String get clientName => switch (this ) {
83
+ Trigger .angularDartDevTools => 'acx-devtools' ,
84
+ Trigger .cider => 'cider' ,
85
+ Trigger .extensionPanel => 'embedded-devtools' ,
86
+ Trigger .extensionIcon => 'devtools'
87
+ };
94
88
}
95
89
96
90
enum DebuggerLocation {
@@ -99,18 +93,12 @@ enum DebuggerLocation {
99
93
dartDevTools,
100
94
ide;
101
95
102
- String get displayName {
103
- switch (this ) {
104
- case DebuggerLocation .angularDartDevTools:
105
- return 'AngularDart DevTools' ;
106
- case DebuggerLocation .chromeDevTools:
107
- return 'Chrome DevTools' ;
108
- case DebuggerLocation .dartDevTools:
109
- return 'a Dart DevTools tab' ;
110
- case DebuggerLocation .ide:
111
- return 'an IDE' ;
112
- }
113
- }
96
+ String get displayName => switch (this ) {
97
+ DebuggerLocation .angularDartDevTools => 'AngularDart DevTools' ,
98
+ DebuggerLocation .chromeDevTools => 'Chrome DevTools' ,
99
+ DebuggerLocation .dartDevTools => 'a Dart DevTools tab' ,
100
+ DebuggerLocation .ide => 'an IDE'
101
+ };
114
102
}
115
103
116
104
bool get existsActiveDebugSession => _debugSessions.isNotEmpty;
@@ -331,8 +319,9 @@ Future<bool> _isDartFrame({required int tabId, required int contextId}) {
331
319
Debuggee (tabId: tabId),
332
320
'Runtime.evaluate' ,
333
321
_InjectedParams (
334
- expression:
335
- '[window.\$ dartAppId, window.\$ dartAppInstanceId, window.\$ dwdsVersion]' ,
322
+ expression: '[window.\$ dartAppId, '
323
+ 'window.\$ dartAppInstanceId, '
324
+ 'window.\$ dwdsVersion]' ,
336
325
returnByValue: true ,
337
326
contextId: contextId,
338
327
),
@@ -497,7 +486,8 @@ void _forwardDwdsEventToChromeDebugger(
497
486
);
498
487
} catch (error) {
499
488
debugError (
500
- 'Error forwarding ${message .command } with ${message .commandParams } to chrome.debugger: $error ' ,
489
+ 'Error forwarding ${message .command } with ${message .commandParams } to '
490
+ 'chrome.debugger: $error ' ,
501
491
);
502
492
}
503
493
}
@@ -660,16 +650,13 @@ Future<bool> _sendStopDebuggingMessage(
660
650
);
661
651
}
662
652
663
- _DebugSession ? _debugSessionForTab (tabId, {required TabType type}) {
664
- switch (type) {
665
- case TabType .dartApp:
666
- return _debugSessions
667
- .firstWhereOrNull ((session) => session.appTabId == tabId);
668
- case TabType .devTools:
669
- return _debugSessions
670
- .firstWhereOrNull ((session) => session.devToolsTabId == tabId);
671
- }
672
- }
653
+ _DebugSession ? _debugSessionForTab (int tabId, {required TabType type}) =>
654
+ switch (type) {
655
+ TabType .dartApp =>
656
+ _debugSessions.firstWhereOrNull ((session) => session.appTabId == tabId),
657
+ TabType .devTools => _debugSessions
658
+ .firstWhereOrNull ((session) => session.devToolsTabId == tabId)
659
+ };
673
660
674
661
Future <bool > _authenticateUser (int tabId) async {
675
662
final isAlreadyAuthenticated = await _fetchIsAuthenticated (tabId);
@@ -746,20 +733,14 @@ DebuggerLocation? _debuggerLocation(int dartAppTabId) {
746
733
final trigger = _tabIdToTrigger[dartAppTabId];
747
734
if (debugSession == null || trigger == null ) return null ;
748
735
749
- switch (trigger) {
750
- case Trigger .extensionIcon:
751
- if (debugSession.devToolsTabId != null ) {
752
- return DebuggerLocation .dartDevTools;
753
- } else {
754
- return DebuggerLocation .ide;
755
- }
756
- case Trigger .angularDartDevTools:
757
- return DebuggerLocation .angularDartDevTools;
758
- case Trigger .extensionPanel:
759
- return DebuggerLocation .chromeDevTools;
760
- case Trigger .cider:
761
- return DebuggerLocation .ide;
762
- }
736
+ return switch (trigger) {
737
+ Trigger .angularDartDevTools => DebuggerLocation .angularDartDevTools,
738
+ Trigger .cider => DebuggerLocation .ide,
739
+ Trigger .extensionPanel => DebuggerLocation .chromeDevTools,
740
+ Trigger .extensionIcon => debugSession.devToolsTabId != null
741
+ ? DebuggerLocation .dartDevTools
742
+ : DebuggerLocation .ide,
743
+ };
763
744
}
764
745
765
746
/// Construct an [ExtensionEvent] from [method] and [params] .
@@ -804,7 +785,7 @@ class _DebugSession {
804
785
late final StreamSubscription <List <ExtensionEvent >> _batchSubscription;
805
786
806
787
_DebugSession ({
807
- required client,
788
+ required SocketClient client,
808
789
required this .appTabId,
809
790
required this .trigger,
810
791
required void Function (String data) onIncoming,
@@ -888,14 +869,11 @@ class _DebugSession {
888
869
String ? _authUrl (String ? extensionUrl) {
889
870
if (extensionUrl == null ) return null ;
890
871
final authUrl = Uri .parse (extensionUrl).replace (path: authenticationPath);
891
- switch (authUrl.scheme) {
892
- case 'ws' :
893
- return authUrl.replace (scheme: 'http' ).toString ();
894
- case 'wss' :
895
- return authUrl.replace (scheme: 'https' ).toString ();
896
- default :
897
- return authUrl.toString ();
898
- }
872
+ return switch (authUrl.scheme) {
873
+ 'ws' => authUrl.replace (scheme: 'http' ).toString (),
874
+ 'wss' => authUrl.replace (scheme: 'https' ).toString (),
875
+ _ => authUrl.toString ()
876
+ };
899
877
}
900
878
901
879
@JS ()
0 commit comments