Files
sdk/pkg/scrape/example/generic_classes.dart
T
Robert Nystrom 86ccb1fb6e Migrate pkg/scrape to null safety.
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>
2021-07-07 22:08:53 +00:00

31 lines
908 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('Classes', order: SortOrder.numeric)
..addVisitor(() => GenericClassVisitor())
..runCommandLine(arguments);
}
class GenericClassVisitor extends ScrapeVisitor {
@override
void visitCompilationUnit(CompilationUnit node) {
super.visitCompilationUnit(node);
}
@override
void visitClassDeclaration(ClassDeclaration node) {
if (node.typeParameters == null) {
record('Classes', 0);
} else {
record('Classes', node.typeParameters!.typeParameters.length);
}
super.visitClassDeclaration(node);
}
}