mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[pkg/frontend_server] analyze using package:lints
Change-Id: I8890c6afc14e63c32c3f1a3cf8c082251dd1eda2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250774 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
397c8d26dd
commit
d60cf4938e
|
@ -10,7 +10,6 @@ Otherwise these changes will need to be carefully coordinated with the flutter t
|
|||
|
||||
This API stability does not cover any of the source code APIs.
|
||||
|
||||
|
||||
### Stable subset
|
||||
|
||||
* The frontend_server kernel compilation and expression evaluation for kernel should be considered "stable".
|
||||
|
|
1
pkg/frontend_server/analysis_options.yaml
Normal file
1
pkg/frontend_server/analysis_options.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
include: package:lints/core.yaml
|
|
@ -4,7 +4,7 @@ library frontend_server;
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../lib/frontend_server.dart';
|
||||
import 'package:frontend_server/frontend_server.dart';
|
||||
|
||||
Future<Null> main(List<String> args) async {
|
||||
exitCode = await starter(args);
|
||||
|
|
|
@ -634,7 +634,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
return errors.isEmpty;
|
||||
}
|
||||
|
||||
void _outputDependenciesDelta(Iterable<Uri> compiledSources) async {
|
||||
Future<void> _outputDependenciesDelta(Iterable<Uri> compiledSources) async {
|
||||
if (!_printIncrementalDependencies) {
|
||||
return;
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
final procedure = await expressionCompiler.compileExpressionToJs(
|
||||
libraryUri, line, column, jsFrameValues, expression);
|
||||
|
||||
final result = errors.length > 0 ? errors[0] : procedure;
|
||||
final result = errors.isNotEmpty ? errors[0] : procedure;
|
||||
|
||||
// TODO(annagrin): kernelBinaryFilename is too specific
|
||||
// rename to _outputFileName?
|
||||
|
@ -1271,8 +1271,9 @@ StreamSubscription<String> listenAndCompile(CompilerInterface compiler,
|
|||
if (string == boundaryKey) {
|
||||
compiler.recompileDelta(entryPoint: recompileEntryPoint);
|
||||
state = _State.READY_FOR_INSTRUCTION;
|
||||
} else
|
||||
} else {
|
||||
compiler.invalidate(Uri.base.resolve(string));
|
||||
}
|
||||
break;
|
||||
case _State.COMPILE_EXPRESSION_EXPRESSION:
|
||||
compileExpressionRequest.expression = string;
|
||||
|
|
|
@ -161,8 +161,7 @@ class JavaScriptBundler {
|
|||
// Source locations come through as absolute file uris. In order to
|
||||
// make relative paths in the source map we get the absolute uri for
|
||||
// the module and make them relative to that.
|
||||
sourceMapBase =
|
||||
p.dirname((await _packageConfig.resolve(moduleUri)).path);
|
||||
sourceMapBase = p.dirname((_packageConfig.resolve(moduleUri)).path);
|
||||
}
|
||||
|
||||
final code = jsProgramToCode(
|
||||
|
|
|
@ -82,7 +82,7 @@ class StrongComponents {
|
|||
final List<List<Library>> results =
|
||||
computeStrongComponents(_LibraryGraph(entrypoint, loadedLibraries));
|
||||
for (List<Library> component in results) {
|
||||
assert(component.length > 0);
|
||||
assert(component.isNotEmpty);
|
||||
final Uri moduleUri = component
|
||||
.firstWhere((lib) => lib.importUri == mainUri,
|
||||
orElse: () => component.first)
|
||||
|
|
|
@ -22,5 +22,6 @@ dependencies:
|
|||
|
||||
# Use 'any' constraints here; we get our versions from the DEPS file.
|
||||
dev_dependencies:
|
||||
lints: any
|
||||
mockito: any
|
||||
test: any
|
||||
|
|
|
@ -13,7 +13,7 @@ import 'package:front_end/src/api_prototype/language_version.dart'
|
|||
import 'package:front_end/src/api_unstable/vm.dart'
|
||||
show CompilerOptions, NnbdMode, StandardFileSystem;
|
||||
|
||||
import '../lib/frontend_server.dart';
|
||||
import 'package:frontend_server/frontend_server.dart';
|
||||
|
||||
main(List<String> args) async {
|
||||
String flutterDir;
|
||||
|
@ -70,7 +70,7 @@ Future compileTests(String flutterDir, String flutterPlatformDir, Logger logger,
|
|||
f.uri
|
||||
.toString()
|
||||
.endsWith("/flutter_patched_sdk/platform_strong.dill")));
|
||||
if (platformFiles.length < 1) {
|
||||
if (platformFiles.isEmpty) {
|
||||
throw "Expected to find a flutter platform file but didn't.";
|
||||
}
|
||||
flutterPlatformDirectoryTmp = platformFiles.first.parent;
|
||||
|
|
|
@ -182,8 +182,8 @@ void runSuite(SuiteConfiguration configuration) async {
|
|||
}
|
||||
}
|
||||
|
||||
void writeLinesToFile(Uri uri, List<String> lines) async {
|
||||
await File.fromUri(uri).writeAsString(lines.map((line) => "$line\n").join());
|
||||
void writeLinesToFile(Uri uri, List<String> lines) {
|
||||
File.fromUri(uri).writeAsStringSync(lines.map((line) => "$line\n").join());
|
||||
}
|
||||
|
||||
main([List<String> arguments = const <String>[]]) async {
|
||||
|
@ -254,8 +254,8 @@ main([List<String> arguments = const <String>[]]) async {
|
|||
// Write results.json and logs.json.
|
||||
Uri resultJsonUri = options.outputDirectory.resolve("results.json");
|
||||
Uri logsJsonUri = options.outputDirectory.resolve("logs.json");
|
||||
await writeLinesToFile(resultJsonUri, results);
|
||||
await writeLinesToFile(logsJsonUri, logs);
|
||||
writeLinesToFile(resultJsonUri, results);
|
||||
writeLinesToFile(logsJsonUri, logs);
|
||||
print("Log files written to ${resultJsonUri.toFilePath()} and"
|
||||
" ${logsJsonUri.toFilePath()}");
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// @dart = 2.9
|
||||
// ignore_for_file: empty_catches
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
@ -7,6 +9,7 @@ import 'dart:typed_data';
|
|||
|
||||
import 'package:_fe_analyzer_shared/src/macros/compiler/request_channel.dart';
|
||||
import 'package:front_end/src/api_unstable/vm.dart';
|
||||
import 'package:frontend_server/frontend_server.dart';
|
||||
import 'package:kernel/ast.dart' show Component;
|
||||
import 'package:kernel/binary/ast_to_binary.dart';
|
||||
import 'package:kernel/kernel.dart' show loadComponentFromBinary;
|
||||
|
@ -16,8 +19,6 @@ import 'package:path/path.dart' as path;
|
|||
import 'package:test/test.dart';
|
||||
import 'package:vm/incremental_compiler.dart';
|
||||
|
||||
import '../lib/frontend_server.dart';
|
||||
|
||||
void main() async {
|
||||
group('basic', () {
|
||||
final CompilerInterface compiler = _MockedCompiler();
|
||||
|
@ -499,10 +500,9 @@ void main() async {
|
|||
file.writeAsStringSync("main() {\n}\n");
|
||||
var dillFile = File('${tempDir.path}/app.dill');
|
||||
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -521,7 +521,7 @@ void main() async {
|
|||
'--incremental',
|
||||
'--platform=${platformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2024,10 +2024,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
test('compile to JavaScript', () async {
|
||||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync("main() {\n}\n");
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2048,7 +2047,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--incremental',
|
||||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
'--target=dartdevc',
|
||||
file.path,
|
||||
];
|
||||
|
@ -2190,10 +2189,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync("main() {\n\n}\n");
|
||||
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2226,7 +2224,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2269,10 +2267,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
test('compile to JavaScript with metadata', () async {
|
||||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync("main() {\n\n}\n");
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2307,7 +2304,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
'--experimental-emit-debug-metadata',
|
||||
'--emit-debug-symbols',
|
||||
];
|
||||
|
@ -2361,10 +2358,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
var dillFile = File('${tempDir.path}/app.dill');
|
||||
var sourceFile = File('${dillFile.path}.sources');
|
||||
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2386,7 +2382,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernelWeak.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}'
|
||||
'--packages=${packageConfig.path}'
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2444,10 +2440,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
file = File('${tempDir.path}/bar.dart')..createSync();
|
||||
file.writeAsStringSync("void Function(int) fn = (int i) => null;\n");
|
||||
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2471,7 +2466,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2524,10 +2519,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
test('compile expression to Javascript', () async {
|
||||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync("main() {\n}\n");
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2556,7 +2550,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2645,10 +2639,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync(
|
||||
"main() {print(const bool.fromEnvironment('dart.library.html'));}\n");
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2677,7 +2670,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -2753,10 +2746,9 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
test('mixed compile expression commands with web target', () async {
|
||||
var file = File('${tempDir.path}/foo.dart')..createSync();
|
||||
file.writeAsStringSync("main() {\n\n}\n");
|
||||
var package_config =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
var packageConfig = File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
|
@ -2784,7 +2776,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--target=dartdevc',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
];
|
||||
|
||||
final StreamController<List<int>> streamController =
|
||||
|
@ -3124,7 +3116,7 @@ void main(List<String> arguments, SendPort sendPort) {
|
|||
main() {}
|
||||
method(int i) => i?.isEven;
|
||||
""");
|
||||
var package_config =
|
||||
var packageConfig =
|
||||
File('${tempDir.path}/.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('''
|
||||
|
@ -3148,7 +3140,7 @@ method(int i) => i?.isEven;
|
|||
'--incremental',
|
||||
'--platform=${ddcPlatformKernel.path}',
|
||||
'--output-dill=${dillFile.path}',
|
||||
'--packages=${package_config.path}',
|
||||
'--packages=${packageConfig.path}',
|
||||
'--target=dartdevc',
|
||||
if (hideWarnings) '--verbosity=error',
|
||||
file.path,
|
||||
|
|
|
@ -145,7 +145,7 @@ void main() {
|
|||
|
||||
test('converts package: uris into /packages/ uris', () async {
|
||||
var importUri = Uri.parse('package:a/a.dart');
|
||||
var fileUri = await packageConfig.resolve(importUri);
|
||||
var fileUri = packageConfig.resolve(importUri);
|
||||
final library = Library(
|
||||
importUri,
|
||||
fileUri: fileUri,
|
||||
|
|
Loading…
Reference in a new issue