86ccb1fb6e
Change-Id: I5c9857090eed7bf521ba581d0c9051606ed45304 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205940 Auto-Submit: Bob Nystrom <rnystrom@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com>
50 lines
1.5 KiB
Dart
50 lines
1.5 KiB
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('Declarations')
|
|
..addHistogram('Uses')
|
|
..addHistogram('Superclass names')
|
|
..addHistogram('Superinterface names')
|
|
..addHistogram('Mixin names')
|
|
..addVisitor(() => ClassReuseVisitor())
|
|
..runCommandLine(arguments);
|
|
}
|
|
|
|
class ClassReuseVisitor extends ScrapeVisitor {
|
|
@override
|
|
void visitClassDeclaration(ClassDeclaration node) {
|
|
if (node.isAbstract) {
|
|
record('Declarations', 'abstract class');
|
|
} else {
|
|
record('Declarations', 'class');
|
|
}
|
|
|
|
var extendsClause = node.extendsClause;
|
|
if (extendsClause != null) {
|
|
record('Uses', 'extend');
|
|
record('Superclass names', extendsClause.superclass.toString());
|
|
}
|
|
|
|
var withClause = node.withClause;
|
|
if (withClause != null) {
|
|
for (var mixin in withClause.mixinTypes) {
|
|
record('Uses', 'mixin');
|
|
record('Mixin names', mixin.toString());
|
|
}
|
|
}
|
|
|
|
var implementsClause = node.implementsClause;
|
|
if (implementsClause != null) {
|
|
for (var type in implementsClause.interfaces) {
|
|
record('Uses', 'implement');
|
|
record('Superinterface names', type.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|