Apply formatter
diff --git a/bin/code_deps.dart b/bin/code_deps.dart
index c3cde7a..a8e8902 100644
--- a/bin/code_deps.dart
+++ b/bin/code_deps.dart
@@ -46,7 +46,7 @@
var json;
try {
json = JSON.decode(new File(args[0]).readAsStringSync());
- } catch(e) {
+ } catch (e) {
print('error: could not read ${args[0]}');
exit(1);
}
@@ -59,12 +59,10 @@
print('missing arguments for `some_path`');
exit(1);
}
- var source =
- info.functions.firstWhere(_longNameMatcher(new RegExp(args[2])),
- orElse: () => null);
- var target =
- info.functions.firstWhere(_longNameMatcher(new RegExp(args[3])),
- orElse: () => null);
+ var source = info.functions
+ .firstWhere(_longNameMatcher(new RegExp(args[2])), orElse: () => null);
+ var target = info.functions
+ .firstWhere(_longNameMatcher(new RegExp(args[3])), orElse: () => null);
print('query: some_path');
if (source == null) {
print("source '${args[2]}' not found in '${args[0]}'");
diff --git a/bin/coverage_log_server.dart b/bin/coverage_log_server.dart
index 0d2f057..c19ae7a 100644
--- a/bin/coverage_log_server.dart
+++ b/bin/coverage_log_server.dart
@@ -32,16 +32,17 @@
main(argv) async {
var parser = new ArgParser()
..addOption('port', abbr: 'p', help: 'port number', defaultsTo: "8080")
- ..addOption('host', help: 'host name (use 0.0.0.0 for all interfaces)',
+ ..addOption('host',
+ help: 'host name (use 0.0.0.0 for all interfaces)',
defaultsTo: 'localhost')
- ..addFlag('help', abbr: 'h', help: 'show this help message',
- negatable: false)
+ ..addFlag('help',
+ abbr: 'h', help: 'show this help message', negatable: false)
..addOption('uri-prefix',
help: 'uri path prefix that will hit this server. This will be injected'
- ' into the .js file',
+ ' into the .js file',
defaultsTo: '')
- ..addOption('out', abbr: 'o', help: 'output log file',
- defaultsTo: _DEFAULT_OUT_TEMPLATE);
+ ..addOption('out',
+ abbr: 'o', help: 'output log file', defaultsTo: _DEFAULT_OUT_TEMPLATE);
var args = parser.parse(argv);
if (args['help'] == true || args.rest.isEmpty) {
print('usage: dart coverage_logging.dart [options] '
@@ -95,8 +96,8 @@
String get _serializedData => new JsonEncoder.withIndent(' ').convert(data);
- _Server(this.hostname, this.port, String jsPath, this.htmlPath,
- this.outPath, String prefix)
+ _Server(this.hostname, this.port, String jsPath, this.htmlPath, this.outPath,
+ String prefix)
: jsPath = jsPath,
jsCode = _adjustRequestUrl(new File(jsPath).readAsStringSync(), prefix),
prefix = _normalize(prefix);
@@ -121,8 +122,9 @@
// Serve an HTML file at the default prefix, or a path matching the HTML
// file name
- if (urlPath == prefix || urlPath == '$prefix/'
- || urlPath == _expectedPath(baseHtmlName)) {
+ if (urlPath == prefix ||
+ urlPath == '$prefix/' ||
+ urlPath == _expectedPath(baseHtmlName)) {
var contents = htmlPath == null
? '<html><script src="$baseJsName"></script>'
: await new File(htmlPath).readAsString();
@@ -167,8 +169,8 @@
await new Future.delayed(new Duration(seconds: 3));
await new File(outPath).writeAsString(_serializedData);
var diff = data.length - _total;
- print(diff ? ' - no new element covered'
- : ' - $diff new elements covered');
+ print(
+ diff ? ' - no new element covered' : ' - $diff new elements covered');
_savePending = false;
_total = data.length;
}
@@ -184,8 +186,7 @@
_adjustRequestUrl(String code, String prefix) {
var newUrl = prefix == '' ? 'coverage' : '$prefix/coverage';
- return code.replaceFirst(
- '"/coverage_uri_to_amend_by_server"',
+ return code.replaceFirst('"/coverage_uri_to_amend_by_server"',
'"/$newUrl" /*url-prefix updated!*/');
}
diff --git a/bin/debug_info.dart b/bin/debug_info.dart
index c005073..b616a76 100644
--- a/bin/debug_info.dart
+++ b/bin/debug_info.dart
@@ -57,8 +57,8 @@
int accounted = totalLib + constantsSize;
if (accounted != realTotal) {
- var percent = ((realTotal - accounted) * 100 / realTotal)
- .toStringAsFixed(2);
+ var percent =
+ ((realTotal - accounted) * 100 / realTotal).toStringAsFixed(2);
_fail('$percent% size missing: $accounted (all libs + consts) '
'< $realTotal (total)');
}
diff --git a/bin/function_size_analysis.dart b/bin/function_size_analysis.dart
index 318a444..2a3192c 100644
--- a/bin/function_size_analysis.dart
+++ b/bin/function_size_analysis.dart
@@ -20,8 +20,8 @@
showCodeDistribution(info);
}
-showCodeDistribution(AllInfo info, {bool filter(Info info),
- bool showLibrarySizes: false}) {
+showCodeDistribution(AllInfo info,
+ {bool filter(Info info), bool showLibrarySizes: false}) {
var realTotal = info.program.size;
if (filter == null) filter = (i) => true;
var reported = []
@@ -74,8 +74,8 @@
}
helper(mainMethod);
reported.forEach((n) => dominatedSize.putIfAbsent(n, () => n.size));
- reported.sort((a, b) => (dominatedSize[b] + nodeData[b].maxSize)
- - (dominatedSize[a] + nodeData[a].maxSize));
+ reported.sort((a, b) => (dominatedSize[b] + nodeData[b].maxSize) -
+ (dominatedSize[a] + nodeData[a].maxSize));
if (showLibrarySizes) {
print(' --- Results per library ---');
@@ -97,7 +97,7 @@
var reportedByLibrary = totals.keys.toList();
reportedByLibrary.sort((a, b) => totals[b] - totals[a]);
reportedByLibrary.forEach((name) {
- _showLib(name, totals[name], realTotal, longest + 1);
+ _showLib(name, totals[name], realTotal, longest + 1);
});
}
@@ -118,7 +118,11 @@
_SccData();
int _maxSize;
- int get maxSize { compute(); return _maxSize; }
+ int get maxSize {
+ compute();
+ return _maxSize;
+ }
+
void compute() {
if (_maxSize != null) return;
var max = 0;
diff --git a/bin/library_size_split.dart b/bin/library_size_split.dart
index 9f5292c..360d036 100644
--- a/bin/library_size_split.dart
+++ b/bin/library_size_split.dart
@@ -77,14 +77,13 @@
var json = JSON.decode(new File(filename).readAsStringSync());
var info = AllInfo.parseFromJson(json);
- var groupingText = args.length > 1
- ? new File(args[1]).readAsStringSync() : defaultGrouping;
+ var groupingText =
+ args.length > 1 ? new File(args[1]).readAsStringSync() : defaultGrouping;
var groupingYaml = loadYaml(groupingText);
var groups = [];
for (var group in groupingYaml['groups']) {
- groups.add(new _Group(group['name'],
- new RegExp(group['regexp']),
- group['cluster'] ?? 0));
+ groups.add(new _Group(
+ group['name'], new RegExp(group['regexp']), group['cluster'] ?? 0));
}
var sizes = {};
@@ -124,8 +123,9 @@
return;
}
- var percent = row.value == realTotal ? '100'
- : (row.value * 100 / realTotal).toStringAsFixed(2);
+ var percent = row.value == realTotal
+ ? '100'
+ : (row.value * 100 / realTotal).toStringAsFixed(2);
print(' ${_pad(row.label, longest + 1, right: true)}'
' ${_pad(row.value, 8)} ${_pad(percent, 6)}%');
}
diff --git a/bin/live_code_size_analysis.dart b/bin/live_code_size_analysis.dart
index cd81d99..4bbd983 100644
--- a/bin/live_code_size_analysis.dart
+++ b/bin/live_code_size_analysis.dart
@@ -112,6 +112,7 @@
_showHeader(String msg, String header1, String header2) {
print(' ${pad(msg, 30, right: true)} ${pad(header1, 8)} ${pad(header2, 6)}');
}
+
_show(String msg, int size, int total) {
var percent = (size * 100 / total).toStringAsFixed(2);
print(' ${pad(msg, 30, right: true)} ${pad(size, 8)} ${pad(percent, 6)}%');
diff --git a/lib/info.dart b/lib/info.dart
index 812bd46..e821249 100644
--- a/lib/info.dart
+++ b/lib/info.dart
@@ -61,8 +61,8 @@
this.coverageId);
BasicInfo._fromId(String serializedId)
- : kind = _kindFromSerializedId(serializedId),
- id = _idFromSerializedId(serializedId);
+ : kind = _kindFromSerializedId(serializedId),
+ id = _idFromSerializedId(serializedId);
Map toJson() {
var res = {
@@ -89,7 +89,6 @@
final List<DependencyInfo> uses = <DependencyInfo>[];
}
-
/// The entire information produced while compiling a program.
class AllInfo {
/// Summary information about the program.
@@ -262,10 +261,10 @@
json['holding'].forEach((k, deps) {
var src = idMap[k];
- assert (src != null);
+ assert(src != null);
for (var dep in deps) {
var target = idMap[dep['id']];
- assert (target != null);
+ assert(target != null);
src.uses.add(new DependencyInfo(target, dep['mask']));
}
});
@@ -281,10 +280,11 @@
LibraryInfo parseLibrary(Map json) {
LibraryInfo result = parseId(json['id']);
- result..name = json['name']
- ..uri = Uri.parse(json['canonicalUri'])
- ..outputUnit = parseId(json['outputUnit'])
- ..size = json['size'];
+ result
+ ..name = json['name']
+ ..uri = Uri.parse(json['canonicalUri'])
+ ..outputUnit = parseId(json['outputUnit'])
+ ..size = json['size'];
for (var child in json['children'].map(parseId)) {
if (child is FunctionInfo) {
result.topLevelFunctions.add(child);
@@ -302,11 +302,12 @@
ClassInfo parseClass(Map json) {
ClassInfo result = parseId(json['id']);
- result..name = json['name']
- ..parent = parseId(json['parent'])
- ..outputUnit = parseId(json['outputUnit'])
- ..size = json['size']
- ..isAbstract = json['modifiers']['abstract'] == true;
+ result
+ ..name = json['name']
+ ..parent = parseId(json['parent'])
+ ..outputUnit = parseId(json['outputUnit'])
+ ..size = json['size']
+ ..isAbstract = json['modifiers']['abstract'] == true;
assert(result is ClassInfo);
for (var child in json['children'].map(parseId)) {
if (child is FunctionInfo) {
@@ -321,7 +322,8 @@
FieldInfo parseField(Map json) {
FieldInfo result = parseId(json['id']);
- return result..name = json['name']
+ return result
+ ..name = json['name']
..parent = parseId(json['parent'])
..coverageId = json['coverageId']
..outputUnit = parseId(json['outputUnit'])
@@ -343,18 +345,19 @@
TypedefInfo parseTypedef(Map json) {
TypedefInfo result = parseId(json['id']);
- return result..name = json['name']
+ return result
+ ..name = json['name']
..parent = parseId(json['parent'])
..type = json['type']
..size = 0;
}
- ProgramInfo parseProgram(Map json) =>
- new ProgramInfo()..size = json['size'];
+ ProgramInfo parseProgram(Map json) => new ProgramInfo()..size = json['size'];
FunctionInfo parseFunction(Map json) {
FunctionInfo result = parseId(json['id']);
- return result..name = json['name']
+ return result
+ ..name = json['name']
..parent = parseId(json['parent'])
..coverageId = json['coverageId']
..outputUnit = parseId(json['outputUnit'])
@@ -381,25 +384,25 @@
}
Info parseId(String serializedId) => registry.putIfAbsent(serializedId, () {
- if (serializedId == null) {
- return null;
- } else if (serializedId.startsWith('function/')) {
- return new FunctionInfo._(serializedId);
- } else if (serializedId.startsWith('library/')) {
- return new LibraryInfo._(serializedId);
- } else if (serializedId.startsWith('class/')) {
- return new ClassInfo._(serializedId);
- } else if (serializedId.startsWith('field/')) {
- return new FieldInfo._(serializedId);
- } else if (serializedId.startsWith('constant/')) {
- return new ConstantInfo._(serializedId);
- } else if (serializedId.startsWith('typedef/')) {
- return new TypedefInfo._(serializedId);
- } else if (serializedId.startsWith('outputUnit/')) {
- return new OutputUnitInfo._(serializedId);
- }
- assert(false);
- });
+ if (serializedId == null) {
+ return null;
+ } else if (serializedId.startsWith('function/')) {
+ return new FunctionInfo._(serializedId);
+ } else if (serializedId.startsWith('library/')) {
+ return new LibraryInfo._(serializedId);
+ } else if (serializedId.startsWith('class/')) {
+ return new ClassInfo._(serializedId);
+ } else if (serializedId.startsWith('field/')) {
+ return new FieldInfo._(serializedId);
+ } else if (serializedId.startsWith('constant/')) {
+ return new ConstantInfo._(serializedId);
+ } else if (serializedId.startsWith('typedef/')) {
+ return new TypedefInfo._(serializedId);
+ } else if (serializedId.startsWith('outputUnit/')) {
+ return new OutputUnitInfo._(serializedId);
+ }
+ assert(false);
+ });
}
/// Info associated with a library element.
@@ -497,16 +500,12 @@
static int _ids = 0;
// TODO(sigmund): Add coverage support to constants?
- ConstantInfo(
- {int size: 0,
- this.code,
- OutputUnitInfo outputUnit})
+ ConstantInfo({int size: 0, this.code, OutputUnitInfo outputUnit})
: super(InfoKind.constant, _ids++, null, outputUnit, size, null);
ConstantInfo._(String serializedId) : super._fromId(serializedId);
- Map toJson() => super.toJson()
- ..addAll({'code': code});
+ Map toJson() => super.toJson()..addAll({'code': code});
void accept(InfoVisitor visitor) => visitor.visitConstant(this);
}
@@ -547,12 +546,13 @@
FieldInfo._(String serializedId) : super._fromId(serializedId);
Map toJson() {
- var result = super.toJson()..addAll({
- 'children': closures.map((i) => i.serializedId).toList(),
- 'inferredType': inferredType,
- 'code': code,
- 'type': type,
- });
+ var result = super.toJson()
+ ..addAll({
+ 'children': closures.map((i) => i.serializedId).toList(),
+ 'inferredType': inferredType,
+ 'code': code,
+ 'type': type,
+ });
if (isConst) {
result['const'] = true;
if (initializer != null) result['initializer'] = initializer.serializedId;
@@ -723,15 +723,23 @@
}
String _kindToString(InfoKind kind) {
- switch(kind) {
- case InfoKind.library: return 'library';
- case InfoKind.clazz: return 'class';
- case InfoKind.function: return 'function';
- case InfoKind.field: return 'field';
- case InfoKind.constant: return 'constant';
- case InfoKind.outputUnit: return 'outputUnit';
- case InfoKind.typedef: return 'typedef';
- default: return null;
+ switch (kind) {
+ case InfoKind.library:
+ return 'library';
+ case InfoKind.clazz:
+ return 'class';
+ case InfoKind.function:
+ return 'function';
+ case InfoKind.field:
+ return 'field';
+ case InfoKind.constant:
+ return 'constant';
+ case InfoKind.outputUnit:
+ return 'outputUnit';
+ case InfoKind.typedef:
+ return 'typedef';
+ default:
+ return null;
}
}
@@ -742,15 +750,23 @@
_kindFromString(serializedId.substring(0, serializedId.indexOf('/')));
InfoKind _kindFromString(String kind) {
- switch(kind) {
- case 'library': return InfoKind.library;
- case 'class': return InfoKind.clazz;
- case 'function': return InfoKind.function;
- case 'field': return InfoKind.field;
- case 'constant': return InfoKind.constant;
- case 'outputUnit': return InfoKind.outputUnit;
- case 'typedef': return InfoKind.typedef;
- default: return null;
+ switch (kind) {
+ case 'library':
+ return InfoKind.library;
+ case 'class':
+ return InfoKind.clazz;
+ case 'function':
+ return InfoKind.function;
+ case 'field':
+ return InfoKind.field;
+ case 'constant':
+ return InfoKind.constant;
+ case 'outputUnit':
+ return InfoKind.outputUnit;
+ case 'typedef':
+ return InfoKind.typedef;
+ default:
+ return null;
}
}
diff --git a/lib/src/graph.dart b/lib/src/graph.dart
index 2e33f4e..4bb7f4b 100644
--- a/lib/src/graph.dart
+++ b/lib/src/graph.dart
@@ -169,7 +169,9 @@
List<N> component;
_NodeInfo(int depth)
- : index = depth, lowlink = depth, onStack = false;
+ : index = depth,
+ lowlink = depth,
+ onStack = false;
}
/// Implements Tarjan's Algorithm for finding the strongly connected components
diff --git a/lib/src/util.dart b/lib/src/util.dart
index 914cbde..e30ba17 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -5,7 +5,8 @@
/// Computes a graph of dependencies from [info].
Graph<Info> graphFromInfo(AllInfo info) {
- print(' info: dependency graph information is work in progress and might be incomplete');
+ print(' info: dependency graph information is work in progress and'
+ ' might be incomplete');
// Note: we are combining dependency information that is computed in two ways
// (functionInfo.uses vs allInfo.dependencies).
// TODO(sigmund): fix inconsistencies between these two ways, stick with one