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

Side by Side Diff: pkg/analyzer/tool/summary/stats.dart

Issue 1691043002: In summary/stats.dart, don't count enums with index == 0. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This file contains code for collecting statistics about the use of fields in 6 * This file contains code for collecting statistics about the use of fields in
7 * a summary file. 7 * a summary file.
8 */ 8 */
9 library analyzer.tool.summary.stats; 9 library analyzer.tool.summary.stats;
10 10
11 import 'dart:io'; 11 import 'dart:io';
12 import 'dart:mirrors';
12 13
13 import 'package:analyzer/src/summary/base.dart'; 14 import 'package:analyzer/src/summary/base.dart';
14 import 'package:analyzer/src/summary/idl.dart'; 15 import 'package:analyzer/src/summary/idl.dart';
15 16
16 main(List<String> args) { 17 main(List<String> args) {
17 if (args.length != 1) { 18 if (args.length != 1) {
18 _printUsage(); 19 _printUsage();
19 exitCode = 1; 20 exitCode = 1;
20 return; 21 return;
21 } 22 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 * Record statistics for [obj] and all objects it refers to. 74 * Record statistics for [obj] and all objects it refers to.
74 */ 75 */
75 void record(SummaryClass obj) { 76 void record(SummaryClass obj) {
76 Map<String, int> typeCounts = 77 Map<String, int> typeCounts =
77 counts.putIfAbsent(obj.runtimeType, () => <String, int>{}); 78 counts.putIfAbsent(obj.runtimeType, () => <String, int>{});
78 obj.toMap().forEach((String key, Object value) { 79 obj.toMap().forEach((String key, Object value) {
79 if (value == null || 80 if (value == null ||
80 value == 0 || 81 value == 0 ||
81 value == false || 82 value == false ||
82 value == '' || 83 value == '' ||
83 value is List && value.isEmpty) { 84 value is List && value.isEmpty ||
85 reflect(value).type.isEnum && (value as dynamic).index == 0) {
84 return; 86 return;
85 } 87 }
86 if (!typeCounts.containsKey(key)) { 88 if (!typeCounts.containsKey(key)) {
87 typeCounts[key] = 0; 89 typeCounts[key] = 0;
88 } 90 }
89 typeCounts[key]++; 91 typeCounts[key]++;
90 if (value is SummaryClass) { 92 if (value is SummaryClass) {
91 record(value); 93 record(value);
92 } else if (value is List) { 94 } else if (value is List) {
93 value.forEach((Object element) { 95 value.forEach((Object element) {
94 if (element is SummaryClass) { 96 if (element is SummaryClass) {
95 record(element); 97 record(element);
96 } 98 }
97 }); 99 });
98 } 100 }
99 }); 101 });
100 } 102 }
101 } 103 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698