mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
dart2js_info: Enable and fix some lints
always_declare_return_types unawaited_futures Enabled, fixed then disabled directives_ordering due to code generation Change-Id: Icaf7358222b1c9a939a4764be091e1956d449386 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253365 Commit-Queue: Mark Zhou <markzipan@google.com> Auto-Submit: Kevin Moore <kevmoo@google.com> Commit-Queue: Kevin Moore <kevmoo@google.com> Reviewed-by: Mark Zhou <markzipan@google.com>
This commit is contained in:
parent
4e616b6b0d
commit
d50903739c
|
@ -1,4 +0,0 @@
|
|||
# Copyright (c) 2015, 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.
|
||||
|
|
@ -4,3 +4,10 @@ analyzer:
|
|||
errors:
|
||||
# Until the protobuf package generates the right code - or the right ignores
|
||||
constant_identifier_names: ignore
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- always_declare_return_types
|
||||
# Enable once we update protobuf generation
|
||||
#- directives_ordering
|
||||
- unawaited_futures
|
||||
|
|
|
@ -29,7 +29,6 @@ import 'dart:collection';
|
|||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/graph.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
|
@ -92,7 +91,7 @@ class _SomePathQuery extends Command<void> with PrintUsageException {
|
|||
|
||||
/// A query supported by this tool.
|
||||
abstract class Query {
|
||||
run(Graph<Info> graph);
|
||||
void run(Graph<Info> graph);
|
||||
}
|
||||
|
||||
/// Query that searches for a single path between two elements.
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'to_json.dart' show ToJsonCommand;
|
||||
import 'to_binary.dart' show ToBinaryCommand;
|
||||
import 'to_json.dart' show ToJsonCommand;
|
||||
import 'to_proto.dart' show ToProtoCommand;
|
||||
import 'usage_exception.dart';
|
||||
|
||||
|
@ -22,7 +22,7 @@ class ConvertCommand extends Command<void> with PrintUsageException {
|
|||
_addSubcommand(ToProtoCommand());
|
||||
}
|
||||
|
||||
_addSubcommand(Command<void> command) {
|
||||
void _addSubcommand(Command<void> command) {
|
||||
addSubcommand(command);
|
||||
command.argParser
|
||||
..addOption('out',
|
||||
|
|
|
@ -111,7 +111,7 @@ class _Server {
|
|||
: jsCode = _adjustRequestUrl(File(jsPath).readAsStringSync(), prefix),
|
||||
prefix = _normalize(prefix);
|
||||
|
||||
run() async {
|
||||
Future<void> run() async {
|
||||
await shelf.serve(_handler, hostname, port);
|
||||
var urlBase = "http://$hostname:$port${prefix == '' ? '/' : '/$prefix/'}";
|
||||
var htmlFilename = htmlPath == null ? '' : path.basename(htmlPath!);
|
||||
|
@ -121,7 +121,7 @@ class _Server {
|
|||
" - coverage reporting: ${urlBase}coverage\n");
|
||||
}
|
||||
|
||||
_expectedPath(String tail) => prefix == '' ? tail : '$prefix/$tail';
|
||||
String _expectedPath(String tail) => prefix == '' ? tail : '$prefix/$tail';
|
||||
|
||||
FutureOr<shelf.Response> _handler(shelf.Request request) async {
|
||||
var urlPath = request.url.path;
|
||||
|
@ -161,7 +161,7 @@ class _Server {
|
|||
return shelf.Response.notFound('Not found: "$urlPath"');
|
||||
}
|
||||
|
||||
_record(List entries) {
|
||||
void _record(List entries) {
|
||||
for (var entry in entries) {
|
||||
var id = entry[0];
|
||||
data.putIfAbsent('$id', () => {'name': entry[1], 'count': 0});
|
||||
|
@ -172,7 +172,7 @@ class _Server {
|
|||
|
||||
bool _savePending = false;
|
||||
int _total = 0;
|
||||
_enqueueSave() async {
|
||||
Future<void> _enqueueSave() async {
|
||||
if (!_savePending) {
|
||||
_savePending = true;
|
||||
await Future.delayed(Duration(seconds: 3));
|
||||
|
@ -188,13 +188,13 @@ class _Server {
|
|||
}
|
||||
|
||||
/// Removes leading and trailing slashes of [uriPath].
|
||||
_normalize(String uriPath) {
|
||||
String _normalize(String uriPath) {
|
||||
if (uriPath.startsWith('/')) uriPath = uriPath.substring(1);
|
||||
if (uriPath.endsWith('/')) uriPath = uriPath.substring(0, uriPath.length - 1);
|
||||
return uriPath;
|
||||
}
|
||||
|
||||
_adjustRequestUrl(String code, String prefix) {
|
||||
String _adjustRequestUrl(String code, String prefix) {
|
||||
var url = prefix == '' ? 'coverage' : '$prefix/coverage';
|
||||
var hook = '''
|
||||
self.dartCallInstrumentation = function(id, name) {
|
||||
|
|
|
@ -44,7 +44,7 @@ class DebugCommand extends Command<void> with PrintUsageException {
|
|||
}
|
||||
|
||||
/// Validates that codesize of elements adds up to total codesize.
|
||||
validateSize(AllInfo info, String debugLibName) {
|
||||
void validateSize(AllInfo info, String debugLibName) {
|
||||
// Gather data from visiting all info elements.
|
||||
final tracker = _SizeTracker(debugLibName);
|
||||
info.accept(tracker);
|
||||
|
@ -87,10 +87,10 @@ validateSize(AllInfo info, String debugLibName) {
|
|||
}
|
||||
|
||||
/// Validates that every element in the model has a parent (except libraries).
|
||||
validateParents(AllInfo info) {
|
||||
void validateParents(AllInfo info) {
|
||||
final parentlessInfos = <Info>{};
|
||||
|
||||
failIfNoParents(List<Info> infos) {
|
||||
void failIfNoParents(List<Info> infos) {
|
||||
for (var info in infos) {
|
||||
if (info.parent == null) {
|
||||
parentlessInfos.add(info);
|
||||
|
@ -160,7 +160,7 @@ class _SizeTracker extends RecursiveInfoVisitor {
|
|||
|
||||
bool _debug = false;
|
||||
@override
|
||||
visitLibrary(LibraryInfo info) {
|
||||
void visitLibrary(LibraryInfo info) {
|
||||
if (_debugLibName != null) _debug = info.name.contains(_debugLibName!);
|
||||
_push();
|
||||
if (_debug) {
|
||||
|
@ -176,7 +176,7 @@ class _SizeTracker extends RecursiveInfoVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
_handleCodeInfo(info) {
|
||||
void _handleCodeInfo(info) {
|
||||
discovered.add(info);
|
||||
var code = info.code;
|
||||
if (_debug && code != null) {
|
||||
|
@ -209,26 +209,26 @@ class _SizeTracker extends RecursiveInfoVisitor {
|
|||
}
|
||||
|
||||
@override
|
||||
visitField(FieldInfo info) {
|
||||
void visitField(FieldInfo info) {
|
||||
_handleCodeInfo(info);
|
||||
super.visitField(info);
|
||||
}
|
||||
|
||||
@override
|
||||
visitFunction(FunctionInfo info) {
|
||||
void visitFunction(FunctionInfo info) {
|
||||
_handleCodeInfo(info);
|
||||
super.visitFunction(info);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedef(TypedefInfo info) {
|
||||
void visitTypedef(TypedefInfo info) {
|
||||
if (_debug) print('$info');
|
||||
stack.last._totalSize += info.size;
|
||||
super.visitTypedef(info);
|
||||
}
|
||||
|
||||
@override
|
||||
visitClass(ClassInfo info) {
|
||||
void visitClass(ClassInfo info) {
|
||||
if (_debug) {
|
||||
print('$info');
|
||||
_debugCode.write(' ' * _indent);
|
||||
|
@ -246,7 +246,7 @@ class _SizeTracker extends RecursiveInfoVisitor {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClassType(ClassTypeInfo info) {
|
||||
void visitClassType(ClassTypeInfo info) {
|
||||
if (_debug) {
|
||||
print('$info');
|
||||
_debugCode.write(' ' * _indent);
|
||||
|
@ -304,7 +304,7 @@ void compareGraphs(AllInfo info) {
|
|||
// differently than 'deps' links
|
||||
int inUsesNotInDependencies = 0;
|
||||
int inDependenciesNotInUses = 0;
|
||||
sameEdges(f) {
|
||||
void sameEdges(f) {
|
||||
var targets1 = g1.targetsOf(f).toSet();
|
||||
var targets2 = g2.targetsOf(f).toSet();
|
||||
inUsesNotInDependencies += targets1.difference(targets2).length;
|
||||
|
@ -324,7 +324,7 @@ void compareGraphs(AllInfo info) {
|
|||
|
||||
// Validates that all elements are reachable from `main` in the dependency
|
||||
// graph.
|
||||
verifyDeps(AllInfo info) {
|
||||
void verifyDeps(AllInfo info) {
|
||||
var graph = graphFromInfo(info);
|
||||
var entrypoint = info.program!.entrypoint;
|
||||
var reachables = Set.from(graph.preOrder(entrypoint));
|
||||
|
@ -340,5 +340,5 @@ verifyDeps(AllInfo info) {
|
|||
}
|
||||
}
|
||||
|
||||
_pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg');
|
||||
_fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg');
|
||||
void _pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg');
|
||||
void _fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg');
|
||||
|
|
|
@ -30,7 +30,7 @@ class DeferredLibraryLayout extends Command<void> with PrintUsageException {
|
|||
}
|
||||
}
|
||||
|
||||
_showLayout(String file) async {
|
||||
Future<void> _showLayout(String file) async {
|
||||
AllInfo info = await infoFromFile(file);
|
||||
|
||||
Map<OutputUnitInfo, Map<LibraryInfo, List<BasicInfo>>> hunkMembers = {};
|
||||
|
@ -83,4 +83,4 @@ _showLayout(String file) async {
|
|||
});
|
||||
}
|
||||
|
||||
_libOf(e) => e is LibraryInfo || e == null ? e : _libOf(e.parent);
|
||||
dynamic _libOf(e) => e is LibraryInfo || e == null ? e : _libOf(e.parent);
|
||||
|
|
|
@ -8,7 +8,6 @@ library dart2js_info.bin.deferred_library_size;
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
|
||||
|
@ -56,7 +55,7 @@ void printSizes(Map<String, int> sizeByImport, int programSize) {
|
|||
int longest = importSizes.fold('Percent of code deferred'.length,
|
||||
(longest, importSize) => max(longest, importSize.import.length));
|
||||
|
||||
printRow(label, data, {int width = 15}) {
|
||||
void printRow(label, data, {int width = 15}) {
|
||||
print('${label.toString().padRight(longest + 1)}'
|
||||
'${data.toString().padLeft(width)}');
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class FunctionSizeCommand extends Command<void> with PrintUsageException {
|
|||
}
|
||||
}
|
||||
|
||||
showCodeDistribution(AllInfo info,
|
||||
void showCodeDistribution(AllInfo info,
|
||||
{bool Function(Info info)? filter, bool showLibrarySizes = false}) {
|
||||
var realTotal = info.program!.size;
|
||||
filter ??= (i) => true;
|
||||
|
@ -152,25 +152,26 @@ class _SccData {
|
|||
}
|
||||
}
|
||||
|
||||
_showLibHeader(int namePadding) {
|
||||
void _showLibHeader(int namePadding) {
|
||||
print(' ${pad("Library", namePadding, right: true)}'
|
||||
' ${pad("bytes", 8)} ${pad("%", 6)}');
|
||||
}
|
||||
|
||||
_showLib(String msg, int size, int total, int namePadding) {
|
||||
void _showLib(String msg, int size, int total, int namePadding) {
|
||||
var percent = (size * 100 / total).toStringAsFixed(2);
|
||||
print(' ${pad(msg, namePadding, right: true)}'
|
||||
' ${pad(size, 8)} ${pad(percent, 6)}%');
|
||||
}
|
||||
|
||||
_showElementHeader() {
|
||||
void _showElementHeader() {
|
||||
print('${pad("element size", 16)} '
|
||||
'${pad("dominated size", 18)} '
|
||||
'${pad("reachable size", 18)} '
|
||||
'Element identifier');
|
||||
}
|
||||
|
||||
_showElement(String name, int size, int dominatedSize, int maxSize, int total) {
|
||||
void _showElement(
|
||||
String name, int size, int dominatedSize, int maxSize, int total) {
|
||||
var percent = (size * 100 / total).toStringAsFixed(2);
|
||||
var minPercent = (dominatedSize * 100 / total).toStringAsFixed(2);
|
||||
var maxPercent = (maxSize * 100 / total).toStringAsFixed(2);
|
||||
|
|
|
@ -33,14 +33,15 @@ void injectText(AllInfo info) {
|
|||
|
||||
Map<String, String> _cache = {};
|
||||
|
||||
_getContents(OutputUnitInfo unit) => _cache.putIfAbsent(unit.filename, () {
|
||||
String _getContents(OutputUnitInfo unit) =>
|
||||
_cache.putIfAbsent(unit.filename, () {
|
||||
var uri = Uri.base.resolve(unit.filename);
|
||||
return File.fromUri(uri).readAsStringSync();
|
||||
});
|
||||
|
||||
_fillSpan(CodeSpan span, OutputUnitInfo unit) {
|
||||
void _fillSpan(CodeSpan span, OutputUnitInfo unit) {
|
||||
if (span.text == null && span.start != null && span.end != 0) {
|
||||
var contents = _getContents(unit);
|
||||
span.text = contents.substring(span.start, span.end);
|
||||
span.text = contents.substring(span.start!, span.end);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ import 'dart:io';
|
|||
import 'dart:math' show max;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
@ -129,12 +128,12 @@ class LibrarySizeCommand extends Command<void> with PrintUsageException {
|
|||
final realTotal = info.program!.size;
|
||||
var longest = 0;
|
||||
final rows = <_Row>[];
|
||||
addRow(String label, int value) {
|
||||
void addRow(String label, int value) {
|
||||
rows.add(_Row(label, value));
|
||||
longest = max(longest, label.length);
|
||||
}
|
||||
|
||||
printRow(_Row row) {
|
||||
void printRow(_Row row) {
|
||||
if (row is _Divider) {
|
||||
print(' ${'-' * (longest + 18)}');
|
||||
return;
|
||||
|
@ -205,7 +204,7 @@ class _Divider extends _Row {
|
|||
const _Divider() : super('', 0);
|
||||
}
|
||||
|
||||
_pad(value, n, {bool right = false}) {
|
||||
String _pad(value, n, {bool right = false}) {
|
||||
final s = '$value';
|
||||
if (s.length >= n) return s;
|
||||
var pad = ' ' * (n - s.length);
|
||||
|
|
|
@ -38,7 +38,6 @@ import 'dart:convert';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
import 'package:dart2js_info/src/util.dart';
|
||||
|
@ -69,7 +68,7 @@ class LiveCodeAnalysisCommand extends Command<void> with PrintUsageException {
|
|||
}
|
||||
}
|
||||
|
||||
_liveCodeAnalysis(infoFile, coverageFile, bool verbose) async {
|
||||
Future<void> _liveCodeAnalysis(infoFile, coverageFile, bool verbose) async {
|
||||
var info = await infoFromFile(infoFile);
|
||||
var coverage = jsonDecode(File(coverageFile).readAsStringSync());
|
||||
|
||||
|
@ -132,11 +131,11 @@ _liveCodeAnalysis(infoFile, coverageFile, bool verbose) async {
|
|||
}
|
||||
}
|
||||
|
||||
_showHeader(String msg, String header1, String header2) {
|
||||
void _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) {
|
||||
void _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)}%');
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import 'dart:io';
|
|||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
import 'package:dart2js_info/src/util.dart';
|
||||
|
@ -67,7 +66,7 @@ class RuntimeCoverageAnalysisCommand extends Command<void>
|
|||
if (showPackages) {
|
||||
await _reportWithPackages(args[0], args[1]);
|
||||
} else if (filterFile.isNotEmpty) {
|
||||
_reportWithClassFilter(args[0], args[1], filterFile);
|
||||
await _reportWithClassFilter(args[0], args[1], filterFile);
|
||||
} else {
|
||||
await _report(args[0], args[1]);
|
||||
}
|
||||
|
@ -434,16 +433,16 @@ void _section(String title, {int? size}) {
|
|||
print('=' * 72);
|
||||
}
|
||||
|
||||
_showHeader(String msg, String header1, String header2) {
|
||||
void _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) {
|
||||
void _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)}%');
|
||||
}
|
||||
|
||||
_leftPadded(String msg1, String msg2) {
|
||||
void _leftPadded(String msg1, String msg2) {
|
||||
print(' ${pad(msg1, 50, right: true)} $msg2');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,8 @@ library compiler.tool.show_inferred_types;
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/src/util.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
import 'package:dart2js_info/src/util.dart';
|
||||
|
||||
import 'usage_exception.dart';
|
||||
|
||||
|
@ -33,14 +32,15 @@ class ShowInferredTypesCommand extends Command<void> with PrintUsageException {
|
|||
usageException(
|
||||
'Missing arguments, expected: info.data <function-name-regex>');
|
||||
}
|
||||
_showInferredTypes(args[0], args[1], argRes['long-names']);
|
||||
await _showInferredTypes(args[0], args[1], argRes['long-names']);
|
||||
}
|
||||
}
|
||||
|
||||
_showInferredTypes(String infoFile, String pattern, bool showLongName) async {
|
||||
Future<void> _showInferredTypes(
|
||||
String infoFile, String pattern, bool showLongName) async {
|
||||
var info = await infoFromFile(infoFile);
|
||||
var nameRegExp = RegExp(pattern);
|
||||
matches(e) => nameRegExp.hasMatch(longName(e));
|
||||
bool matches(e) => nameRegExp.hasMatch(longName(e));
|
||||
|
||||
bool noResults = true;
|
||||
void showMethods() {
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/binary_serialization.dart' as binary;
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
|
||||
import 'inject_text.dart';
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'usage_exception.dart';
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
import 'package:vm_snapshot_analysis/treemap.dart';
|
||||
import 'package:dart2js_info/src/util.dart';
|
||||
import 'package:vm_snapshot_analysis/program_info.dart' as vm;
|
||||
import 'package:vm_snapshot_analysis/treemap.dart';
|
||||
|
||||
import 'usage_exception.dart';
|
||||
|
||||
/// Command that converts a `--dump-info` JSON output into a format ingested by Devtools.
|
||||
///
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// 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 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/json_info_codec.dart';
|
||||
import 'package:dart2js_info/src/io.dart';
|
||||
|
|
|
@ -6,13 +6,13 @@ import 'package:args/command_runner.dart';
|
|||
|
||||
import 'src/code_deps.dart';
|
||||
import 'src/common_command.dart';
|
||||
import 'src/convert.dart';
|
||||
import 'src/coverage_log_server.dart';
|
||||
import 'src/debug_info.dart';
|
||||
import 'src/diff.dart';
|
||||
import 'src/deferred_library_check.dart';
|
||||
import 'src/deferred_library_size.dart';
|
||||
import 'src/deferred_library_layout.dart';
|
||||
import 'src/convert.dart';
|
||||
import 'src/deferred_library_size.dart';
|
||||
import 'src/diff.dart';
|
||||
import 'src/function_size_analysis.dart';
|
||||
import 'src/library_size_split.dart';
|
||||
import 'src/live_code_size_analysis.dart';
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'info.dart';
|
||||
import 'src/binary/sink.dart';
|
||||
import 'src/binary/source.dart';
|
||||
import 'info.dart';
|
||||
|
||||
void encode(AllInfo info, Sink<List<int>> sink) {
|
||||
BinaryPrinter(BinarySink(sink)).visitAll(info);
|
||||
|
@ -143,7 +143,7 @@ class BinaryPrinter implements InfoVisitor<void> {
|
|||
});
|
||||
}
|
||||
|
||||
_visitCodeSpan(CodeSpan code) {
|
||||
void _visitCodeSpan(CodeSpan code) {
|
||||
sink.writeIntOrNull(code.start);
|
||||
sink.writeIntOrNull(code.end);
|
||||
sink.writeStringOrNull(code.text);
|
||||
|
@ -376,7 +376,7 @@ class BinaryReader {
|
|||
info.classTypes.addAll(source.readList(readClassType));
|
||||
info.typedefs.addAll(source.readList(readTypedef));
|
||||
|
||||
setParent(BasicInfo child) => child.parent = info;
|
||||
LibraryInfo setParent(BasicInfo child) => child.parent = info;
|
||||
info.topLevelFunctions.forEach(setParent);
|
||||
info.topLevelVariables.forEach(setParent);
|
||||
info.classes.forEach(setParent);
|
||||
|
@ -393,7 +393,7 @@ class BinaryReader {
|
|||
info.functions.addAll(source.readList(readFunction));
|
||||
info.supers.addAll(source.readList(readClass));
|
||||
|
||||
setParent(BasicInfo child) => child.parent = info;
|
||||
ClassInfo setParent(BasicInfo child) => child.parent = info;
|
||||
info.fields.forEach(setParent);
|
||||
info.functions.forEach(setParent);
|
||||
return info;
|
||||
|
|
|
@ -87,7 +87,7 @@ List<ManifestComplianceFailure> checkDeferredLibraryManifest(
|
|||
|
||||
var failures = <ManifestComplianceFailure>[];
|
||||
|
||||
checkInfo(BasicInfo info) {
|
||||
void checkInfo(BasicInfo info) {
|
||||
if (info.size == 0) return;
|
||||
var lib = _getLibraryOf(info);
|
||||
if (lib != null && _isPackageUri(lib.uri)) {
|
||||
|
|
|
@ -632,7 +632,7 @@ abstract class VMProgramInfoVisitor<T> extends InfoVisitor<T> {
|
|||
/// so on.
|
||||
class RecursiveInfoVisitor extends InfoVisitor<void> {
|
||||
@override
|
||||
visitAll(AllInfo info) {
|
||||
void visitAll(AllInfo info) {
|
||||
// Note: we don't visit functions, fields, classes, and typedefs because
|
||||
// they are reachable from the library info.
|
||||
info.libraries.forEach(visitLibrary);
|
||||
|
@ -640,10 +640,10 @@ class RecursiveInfoVisitor extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitProgram(ProgramInfo info) {}
|
||||
void visitProgram(ProgramInfo info) {}
|
||||
|
||||
@override
|
||||
visitLibrary(LibraryInfo info) {
|
||||
void visitLibrary(LibraryInfo info) {
|
||||
info.topLevelFunctions.forEach(visitFunction);
|
||||
info.topLevelVariables.forEach(visitField);
|
||||
info.classes.forEach(visitClass);
|
||||
|
@ -652,33 +652,33 @@ class RecursiveInfoVisitor extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClass(ClassInfo info) {
|
||||
void visitClass(ClassInfo info) {
|
||||
info.functions.forEach(visitFunction);
|
||||
info.fields.forEach(visitField);
|
||||
}
|
||||
|
||||
@override
|
||||
visitClassType(ClassTypeInfo info) {}
|
||||
void visitClassType(ClassTypeInfo info) {}
|
||||
|
||||
@override
|
||||
visitField(FieldInfo info) {
|
||||
void visitField(FieldInfo info) {
|
||||
info.closures.forEach(visitClosure);
|
||||
}
|
||||
|
||||
@override
|
||||
visitConstant(ConstantInfo info) {}
|
||||
void visitConstant(ConstantInfo info) {}
|
||||
|
||||
@override
|
||||
visitFunction(FunctionInfo info) {
|
||||
void visitFunction(FunctionInfo info) {
|
||||
info.closures.forEach(visitClosure);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedef(TypedefInfo info) {}
|
||||
void visitTypedef(TypedefInfo info) {}
|
||||
@override
|
||||
visitOutput(OutputUnitInfo info) {}
|
||||
void visitOutput(OutputUnitInfo info) {}
|
||||
@override
|
||||
visitClosure(ClosureInfo info) {
|
||||
void visitClosure(ClosureInfo info) {
|
||||
visitFunction(info.function);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,10 +591,11 @@ class AllInfoToJsonConverter extends Converter<AllInfo, Map>
|
|||
}
|
||||
|
||||
@override
|
||||
visitTypedef(TypedefInfo info) => _visitBasicInfo(info)..['type'] = info.type;
|
||||
Map visitTypedef(TypedefInfo info) =>
|
||||
_visitBasicInfo(info)..['type'] = info.type;
|
||||
|
||||
@override
|
||||
visitOutput(OutputUnitInfo info) => _visitBasicInfo(info)
|
||||
Map visitOutput(OutputUnitInfo info) => _visitBasicInfo(info)
|
||||
..['filename'] = info.filename
|
||||
..['imports'] = info.imports;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class CommonElement {
|
|||
|
||||
CommonElement(this.oldInfo, this.newInfo);
|
||||
|
||||
get name => longName(oldInfo, useLibraryUri: true);
|
||||
String get name => longName(oldInfo, useLibraryUri: true);
|
||||
}
|
||||
|
||||
List<CommonElement> findCommonalities(AllInfo oldInfo, AllInfo newInfo) {
|
||||
|
@ -31,27 +31,27 @@ class _InfoCommonElementFinder extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitAll(AllInfo info) {
|
||||
void visitAll(AllInfo info) {
|
||||
throw StateError('should not run common on AllInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitProgram(ProgramInfo info) {
|
||||
void visitProgram(ProgramInfo info) {
|
||||
throw StateError('should not run common on ProgramInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitOutput(OutputUnitInfo info) {
|
||||
void visitOutput(OutputUnitInfo info) {
|
||||
throw StateError('should not run common on OutputUnitInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitConstant(ConstantInfo info) {
|
||||
void visitConstant(ConstantInfo info) {
|
||||
throw StateError('should not run common on ConstantInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitLibrary(LibraryInfo info) {
|
||||
void visitLibrary(LibraryInfo info) {
|
||||
var other = _other as LibraryInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
_commonList(info.topLevelVariables, other.topLevelVariables);
|
||||
|
@ -60,7 +60,7 @@ class _InfoCommonElementFinder extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClass(ClassInfo info) {
|
||||
void visitClass(ClassInfo info) {
|
||||
var other = _other as ClassInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
_commonList(info.fields, other.fields);
|
||||
|
@ -68,34 +68,34 @@ class _InfoCommonElementFinder extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClassType(ClassTypeInfo info) {
|
||||
void visitClassType(ClassTypeInfo info) {
|
||||
var other = _other as ClassInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
}
|
||||
|
||||
@override
|
||||
visitClosure(ClosureInfo info) {
|
||||
void visitClosure(ClosureInfo info) {
|
||||
var other = _other as ClosureInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
_commonList([info.function], [other.function]);
|
||||
}
|
||||
|
||||
@override
|
||||
visitField(FieldInfo info) {
|
||||
void visitField(FieldInfo info) {
|
||||
var other = _other as FieldInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
_commonList(info.closures, other.closures);
|
||||
}
|
||||
|
||||
@override
|
||||
visitFunction(FunctionInfo info) {
|
||||
void visitFunction(FunctionInfo info) {
|
||||
var other = _other as FunctionInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
_commonList(info.closures, other.closures);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedef(TypedefInfo info) {
|
||||
void visitTypedef(TypedefInfo info) {
|
||||
var other = _other as ClassInfo;
|
||||
commonElements.add(CommonElement(info, other));
|
||||
}
|
||||
|
|
|
@ -49,28 +49,28 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitAll(AllInfo info) {
|
||||
void visitAll(AllInfo info) {
|
||||
throw StateError('should not diff AllInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitProgram(ProgramInfo info) {
|
||||
void visitProgram(ProgramInfo info) {
|
||||
throw StateError('should not diff ProgramInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitOutput(OutputUnitInfo info) {
|
||||
void visitOutput(OutputUnitInfo info) {
|
||||
throw StateError('should not diff OutputUnitInfo');
|
||||
}
|
||||
|
||||
// TODO(het): diff constants
|
||||
@override
|
||||
visitConstant(ConstantInfo info) {
|
||||
void visitConstant(ConstantInfo info) {
|
||||
throw StateError('should not diff ConstantInfo');
|
||||
}
|
||||
|
||||
@override
|
||||
visitLibrary(LibraryInfo info) {
|
||||
void visitLibrary(LibraryInfo info) {
|
||||
var other = _other as LibraryInfo;
|
||||
_checkSize(info, other);
|
||||
_diffList(info.topLevelVariables, other.topLevelVariables);
|
||||
|
@ -79,7 +79,7 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClass(ClassInfo info) {
|
||||
void visitClass(ClassInfo info) {
|
||||
var other = _other as ClassInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
|
@ -88,14 +88,14 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitClassType(ClassTypeInfo info) {
|
||||
void visitClassType(ClassTypeInfo info) {
|
||||
var other = _other as ClassTypeInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
}
|
||||
|
||||
@override
|
||||
visitClosure(ClosureInfo info) {
|
||||
void visitClosure(ClosureInfo info) {
|
||||
var other = _other as ClosureInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
|
@ -103,7 +103,7 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitField(FieldInfo info) {
|
||||
void visitField(FieldInfo info) {
|
||||
var other = _other as FieldInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
|
@ -111,7 +111,7 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitFunction(FunctionInfo info) {
|
||||
void visitFunction(FunctionInfo info) {
|
||||
var other = _other as FunctionInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
|
@ -119,7 +119,7 @@ class _InfoDiffer extends InfoVisitor<void> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitTypedef(TypedefInfo info) {
|
||||
void visitTypedef(TypedefInfo info) {
|
||||
var other = _other as TypedefInfo;
|
||||
_checkSize(info, other);
|
||||
_checkDeferredStatus(info, other);
|
||||
|
|
|
@ -288,7 +288,7 @@ class _DominatorFinder<N> {
|
|||
Map<N, int> postOrderId = {};
|
||||
_DominatorFinder(this._graph);
|
||||
|
||||
run(N root) {
|
||||
void run(N root) {
|
||||
immediateDominators[root] = root;
|
||||
bool changed = true;
|
||||
int i = 0;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dart2js_info/binary_serialization.dart' as binary;
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/json_info_codec.dart';
|
||||
import 'package:dart2js_info/binary_serialization.dart' as binary;
|
||||
|
||||
Future<AllInfo> infoFromFile(String fileName) async {
|
||||
var file = File(fileName);
|
||||
|
|
|
@ -149,7 +149,7 @@ String? libraryGroupName(Info info) {
|
|||
}
|
||||
|
||||
/// Produce a string containing [value] padded with white space up to [n] chars.
|
||||
pad(value, n, {bool right = false}) {
|
||||
String pad(value, n, {bool right = false}) {
|
||||
var s = '$value';
|
||||
if (s.length >= n) return s;
|
||||
var pad = ' ' * (n - s.length);
|
||||
|
|
|
@ -6,20 +6,20 @@ import 'dart:convert';
|
|||
import 'dart:io' show File, Platform;
|
||||
import 'dart:typed_data' show BytesBuilder;
|
||||
|
||||
import 'package:dart2js_info/json_info_codec.dart';
|
||||
import 'package:dart2js_info/binary_serialization.dart' as binary;
|
||||
import 'package:dart2js_info/json_info_codec.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
class ByteSink implements Sink<List<int>> {
|
||||
BytesBuilder builder = BytesBuilder();
|
||||
|
||||
@override
|
||||
add(List<int> data) => builder.add(data);
|
||||
void add(List<int> data) => builder.add(data);
|
||||
@override
|
||||
close() {}
|
||||
void close() {}
|
||||
}
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
group('json to proto conversion with deferred files', () {
|
||||
test('hello_world_deferred', () {
|
||||
var uri = Platform.script
|
||||
|
|
|
@ -35,7 +35,7 @@ class Subsub2 extends Subclass {
|
|||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
Super<Object> s = Subclass()..test();
|
||||
Expect.throws(() => s.method(''));
|
||||
dynamic x = Subsub1();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import 'package:dart2js_info/src/graph.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
var graph = makeTestGraph();
|
||||
|
||||
test('preorder traversal', () {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
main() {
|
||||
void main() {
|
||||
print("Hello, World!");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'package:dart2js_info/json_info_codec.dart';
|
|||
import 'package:dart2js_info/proto_info_codec.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
group('json to proto conversion with deferred files', () {
|
||||
test('hello_world_deferred', () {
|
||||
var uri = Platform.script
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'package:dart2js_info/json_info_codec.dart';
|
|||
import 'package:dart2js_info/proto_info_codec.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
group('json to proto conversion', () {
|
||||
test('hello_world', () {
|
||||
var uri = Platform.script.resolve('hello_world/hello_world.js.info.json');
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'dart:io';
|
|||
import 'package:dart2js_info/json_info_codec.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
group('parse', () {
|
||||
test('hello_world', () {
|
||||
var uri = Platform.script.resolve('hello_world/hello_world.js.info.json');
|
||||
|
|
Loading…
Reference in a new issue