891a8a1aa3
The README explains, it but, in short, this is a little library I harvested from the scripts I wrote during ui-as-code. It makes it easier to write scripts to gather bits of statistical data from Dart syntax. Change-Id: Ia33797f582c4d4f9f966b7f6dc7b58ca2414601e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166788 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
25 lines
695 B
Dart
25 lines
695 B
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
import 'package:analyzer/dart/ast/ast.dart';
|
|
import 'package:scrape/scrape.dart';
|
|
|
|
void main(List<String> arguments) {
|
|
Scrape()
|
|
..addHistogram('If')
|
|
..addVisitor(() => IfVisitor())
|
|
..runCommandLine(arguments);
|
|
}
|
|
|
|
class IfVisitor extends ScrapeVisitor {
|
|
@override
|
|
void visitIfStatement(IfStatement node) {
|
|
if (node.elseStatement != null) {
|
|
record('If', 'else');
|
|
} else {
|
|
record('If', 'no else');
|
|
}
|
|
super.visitIfStatement(node);
|
|
}
|
|
}
|