Skip to content

Commit

Permalink
simplify the debugger's libraries view (#2386)
Browse files Browse the repository at this point in the history
simplify the debugger's libraries view
  • Loading branch information
devoncarew committed Sep 29, 2020
1 parent 6dce387 commit f38f4ac
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
25 changes: 24 additions & 1 deletion packages/devtools_app/lib/src/debugger/debugger_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class FileNode extends TreeNode<FileNode> {
for (var name in directoryParts) {
node = node._getCreateChild(name);
}

node.scriptRef = script;
}

Expand All @@ -311,6 +312,21 @@ class FileNode extends TreeNode<FileNode> {
child._trimChildrenAsMapEntries();
}
}

@override
int get hashCode => scriptRef?.hashCode ?? name.hashCode;

@override
bool operator ==(Object other) {
if (other is! FileNode) return false;
final FileNode node = other;

if (scriptRef == null) {
return node.scriptRef != null ? false : name == node.name;
} else {
return node.scriptRef == null ? false : scriptRef == node.scriptRef;
}
}
}

class ScriptRefUtils {
Expand Down Expand Up @@ -347,6 +363,13 @@ class ScriptRefUtils {
];
}

return parts;
if (parts.length > 1) {
return [
parts.first,
parts.sublist(1).join('/'),
];
} else {
return parts;
}
}
}
1 change: 0 additions & 1 deletion packages/devtools_app/lib/src/debugger/scripts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class ScriptPickerState extends State<ScriptPicker> {
waitDuration: tooltipWait,
preferBelow: false,
message: node.name,
key: ValueKey(node.name),
child: Material(
child: InkWell(
onTap: () {
Expand Down
20 changes: 4 additions & 16 deletions packages/devtools_app/test/debugger_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ void main() {
expect(child.scriptRef, isNull);

child = child.children[0];
expect(child.name, 'bar');
expect(child.scriptRef, isNull);

child = child.children[0];
expect(child.name, 'baz');
expect(child.scriptRef, isNull);

child = child.children[0];
expect(child.name, 'qux.dart');
expect(child.name, 'bar/baz/qux.dart');
expect(child.scriptRef, isNotNull);
});

Expand All @@ -89,11 +81,7 @@ void main() {
expect(child.scriptRef, isNull);

child = child.children[0];
expect(child.name, 'bar');
expect(child.scriptRef, isNull);

child = child.children[0];
expect(child.name, 'baz.dart');
expect(child.name, 'bar/baz.dart');
expect(child.scriptRef, isNotNull);
});
});
Expand All @@ -111,12 +99,12 @@ void main() {
expect(
ScriptRefUtils.splitDirectoryParts(
ScriptRef(uri: 'package:foo.bar.baz/qux.dart', id: 'id-5')),
orderedEquals(['package:foo', 'bar', 'baz', 'qux.dart']),
orderedEquals(['package:foo', 'bar/baz/qux.dart']),
);
expect(
ScriptRefUtils.splitDirectoryParts(
ScriptRef(uri: 'google3:///foo/bar/baz.dart', id: 'id-6')),
orderedEquals(['google3:foo', 'bar', 'baz.dart']),
orderedEquals(['google3:foo', 'bar/baz.dart']),
);
});
});
Expand Down

0 comments on commit f38f4ac

Please sign in to comment.