Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Unified Diff: lib/src/ascii_tree.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « .analysis_options ('k') | lib/src/asset/dart/serialize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/ascii_tree.dart
diff --git a/lib/src/ascii_tree.dart b/lib/src/ascii_tree.dart
index 8a7734e5083a9ed8c7fadcb81a09abb0b487b503..ec70f7fddb29b89243a392bc15b16e984745c7dd 100644
--- a/lib/src/ascii_tree.dart
+++ b/lib/src/ascii_tree.dart
@@ -60,12 +60,13 @@ import 'utils.dart';
/// will have their contents truncated. Defaults to `false`.
String fromFiles(List<String> files, {String baseDir, bool showAllChildren}) {
// Parse out the files into a tree of nested maps.
- var root = {};
+ var root = <String, Map>{};
for (var file in files) {
if (baseDir != null) file = path.relative(file, from: baseDir);
var directory = root;
for (var part in path.split(file)) {
- directory = directory.putIfAbsent(part, () => {});
+ directory = directory.putIfAbsent(part, () => <String, Map>{})
+ as Map<String, Map>;
}
}
@@ -97,7 +98,7 @@ String fromFiles(List<String> files, {String baseDir, bool showAllChildren}) {
///
/// If [showAllChildren] is `false`, then directories with more than ten items
/// will have their contents truncated. Defaults to `false`.
-String fromMap(Map map, {bool showAllChildren}) {
+String fromMap(Map<String, Map> map, {bool showAllChildren}) {
var buffer = new StringBuffer();
_draw(buffer, "", null, map, showAllChildren: showAllChildren);
return buffer.toString();
@@ -125,8 +126,9 @@ String _getPrefix(bool isRoot, bool isLast) {
return log.gray("| ");
}
-void _draw(StringBuffer buffer, String prefix, String name, Map children,
- {bool showAllChildren, bool isLast: false}) {
+void _draw(
+ StringBuffer buffer, String prefix, String name, Map<String, Map> children,
+ {bool showAllChildren, bool isLast: false}) {
if (showAllChildren == null) showAllChildren = false;
// Don't draw a line for the root node.
@@ -137,8 +139,13 @@ void _draw(StringBuffer buffer, String prefix, String name, Map children,
drawChild(bool isLastChild, String child) {
var childPrefix = _getPrefix(name == null, isLast);
- _draw(buffer, '$prefix$childPrefix', child, children[child],
- showAllChildren: showAllChildren, isLast: isLastChild);
+ _draw(
+ buffer,
+ '$prefix$childPrefix',
+ child,
+ children[child] as Map<String, Map>,
+ showAllChildren: showAllChildren,
+ isLast: isLastChild);
}
if (name == null || showAllChildren || childNames.length <= 10) {
« no previous file with comments | « .analysis_options ('k') | lib/src/asset/dart/serialize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698