Skip to content

Commit 3dbdb6f

Browse files
Refactor InspectorServiceBase and ObjectGroupBase out of InspectorService and ObjectGroup (flutter#3465)
1 parent 513884f commit 3dbdb6f

8 files changed

Lines changed: 717 additions & 644 deletions

File tree

packages/devtools_app/lib/src/console_service.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ConsoleService extends Disposer {
9494
final _stdio = ListValueNotifier<ConsoleLine>([]);
9595
bool _stdioTrailingNewline = false;
9696

97-
ObjectGroup get objectGroup {
97+
ObjectGroupBase get objectGroup {
9898
final inspectorService = serviceManager.inspectorService;
9999
if (_objectGroup?.inspectorService == inspectorService) {
100100
return _objectGroup;
@@ -104,7 +104,7 @@ class ConsoleService extends Disposer {
104104
return _objectGroup;
105105
}
106106

107-
ObjectGroup _objectGroup;
107+
ObjectGroupBase _objectGroup;
108108

109109
/// Clears the contents of stdio.
110110
void clearStdio() {

packages/devtools_app/lib/src/debugger/debugger_model.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ Future<void> buildVariablesTree(
406406
}
407407
if (diagnostic != null && includeDiagnosticChildren) {
408408
// Always add children last after properties to avoid confusion.
409-
final ObjectGroup service = diagnostic.inspectorService;
409+
final ObjectGroupBase service = diagnostic.inspectorService;
410410
final diagnosticChildren = await diagnostic.children;
411411
if (diagnosticChildren?.isNotEmpty ?? false) {
412412
final childrenNode = Variable.text(
@@ -428,7 +428,7 @@ Future<void> buildVariablesTree(
428428
final inspectorService = serviceManager.inspectorService;
429429
if (inspectorService != null) {
430430
final tasks = <Future>[];
431-
ObjectGroup group;
431+
ObjectGroupBase group;
432432
Future<void> _maybeUpdateRef(Variable child) async {
433433
if (child.ref == null) return;
434434
if (child.ref.diagnostic == null) {
@@ -477,7 +477,7 @@ Future<void> buildVariablesTree(
477477

478478
Future<Variable> _buildVariable(
479479
RemoteDiagnosticsNode diagnostic,
480-
ObjectGroup inspectorService,
480+
ObjectGroupBase inspectorService,
481481
IsolateRef isolateRef,
482482
) async {
483483
final instanceRef =
@@ -491,7 +491,7 @@ Future<Variable> _buildVariable(
491491
}
492492

493493
Future<List<Variable>> _createVariablesForDiagnostics(
494-
ObjectGroup inspectorService,
494+
ObjectGroupBase inspectorService,
495495
List<RemoteDiagnosticsNode> diagnostics,
496496
IsolateRef isolateRef,
497497
) async {
@@ -798,16 +798,18 @@ class Variable extends TreeNode<Variable> {
798798
}
799799
// Group name doesn't matter in this case.
800800
final group = inspectorService.createObjectGroup('inspect-variables');
801-
802-
try {
803-
return await group.setSelection(ref);
804-
} catch (e) {
805-
// This is somewhat unexpected. The inspectorRef must have been disposed.
806-
return false;
807-
} finally {
808-
// Not really needed as we shouldn't actually be allocating anything.
809-
unawaited(group.dispose());
801+
if (group is ObjectGroup) {
802+
try {
803+
return await group.setSelection(ref);
804+
} catch (e) {
805+
// This is somewhat unexpected. The inspectorRef must have been disposed.
806+
return false;
807+
} finally {
808+
// Not really needed as we shouldn't actually be allocating anything.
809+
unawaited(group.dispose());
810+
}
810811
}
812+
return false;
811813
}
812814

813815
Future<bool> get isInspectable async {

packages/devtools_app/lib/src/inspector/diagnostics_node.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
9292

9393
/// Service used to retrieve more detailed information about the value of
9494
/// the property and its children and properties.
95-
final ObjectGroup inspectorService;
95+
final ObjectGroupBase inspectorService;
9696

9797
/// JSON describing the diagnostic node.
9898
final Map<String, Object> json;
@@ -138,7 +138,7 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
138138

139139
bool get isLocalClass {
140140
final objectGroup = inspectorService;
141-
if (objectGroup is ObjectGroup) {
141+
if (objectGroup is ObjectGroupBase) {
142142
return _isLocalClass ??= objectGroup.inspectorService.isLocalClass(this);
143143
} else {
144144
// TODO(jacobr): if objectGroup is a Future<ObjectGroup> we cannot compute
@@ -608,7 +608,7 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
608608
}
609609

610610
Future<List<RemoteDiagnosticsNode>> getProperties(
611-
ObjectGroup objectGroup) async {
611+
ObjectGroupBase objectGroup) async {
612612
return await objectGroup.getProperties(dartDiagnosticRef);
613613
}
614614

@@ -679,7 +679,10 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
679679
}
680680

681681
Future<void> setSelectionInspector(bool uiAlreadyUpdated) async {
682-
await inspectorService?.setSelectionInspector(valueRef, uiAlreadyUpdated);
682+
final objectGroup = inspectorService;
683+
if (objectGroup is ObjectGroup) {
684+
await objectGroup.setSelectionInspector(valueRef, uiAlreadyUpdated);
685+
}
683686
}
684687
}
685688

0 commit comments

Comments
 (0)