From 9f946d0d90c195226bcf5aeaa4af80a0bbb5720a Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 7 Jan 2019 16:16:59 -0800 Subject: [PATCH 1/9] fix up analysis for Dart in Engine --- analysis_options.yaml | 4 -- lib/snapshot/snapshot.dart | 2 + lib/snapshot/snapshot_fuchsia.dart | 2 + lib/ui/compositing.dart | 2 + lib/ui/hooks.dart | 3 + lib/ui/isolate_name_server.dart | 2 + lib/ui/natives.dart | 5 +- lib/ui/painting.dart | 2 + lib/ui/semantics.dart | 2 + lib/ui/text.dart | 2 + lib/ui/ui.dart | 3 + lib/ui/window.dart | 2 + runtime/fixtures/simple_main.dart | 2 +- testing/dart/canvas_test.dart | 37 ++++++----- testing/dart/codec_test.dart | 71 ++++++++++----------- testing/dart/color_test.dart | 14 ++-- testing/dart/encoding_test.dart | 74 ++++++++++++---------- testing/dart/gradient_test.dart | 3 +- testing/dart/isolate_name_server_test.dart | 35 +++++----- testing/dart/locale_test.dart | 26 ++++---- testing/dart/paragraph_builder_test.dart | 2 +- testing/dart/path_test.dart | 4 +- testing/dart/plugin_utilities_test.dart | 16 ++--- testing/dart/pubspec.yaml | 6 ++ testing/dart/rect_test.dart | 36 +++++------ testing/dart/window_test.dart | 2 +- testing/fail_test.dart | 3 + testing/symbols/verify_exported.dart | 2 +- 28 files changed, 199 insertions(+), 165 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 6420a5457adca..561108e9626af 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,9 +10,6 @@ # private fields, especially on the Window object): analyzer: - language: - enableStrictCallChecks: true - enableSuperMixins: true strong-mode: implicit-dynamic: false errors: @@ -94,7 +91,6 @@ linter: # - parameter_assignments # we do this commonly - prefer_adjacent_string_concatenation - prefer_asserts_in_initializer_lists - - prefer_bool_in_asserts - prefer_collection_literals - prefer_conditional_assignment - prefer_const_constructors diff --git a/lib/snapshot/snapshot.dart b/lib/snapshot/snapshot.dart index c411f09a22eae..038e312208495 100644 --- a/lib/snapshot/snapshot.dart +++ b/lib/snapshot/snapshot.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: unused_import,uri_does_not_exist + import 'dart:async'; import 'dart:collection'; import 'dart:convert'; diff --git a/lib/snapshot/snapshot_fuchsia.dart b/lib/snapshot/snapshot_fuchsia.dart index 5fafa124d8b2f..c0f52efae2ea7 100644 --- a/lib/snapshot/snapshot_fuchsia.dart +++ b/lib/snapshot/snapshot_fuchsia.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: unused_import,uri_does_not_exist + import 'dart:async'; import 'dart:collection'; import 'dart:convert'; diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index df79b0db86ce3..2df7e5b2a6c16 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; /// An opaque object representing a composited scene. diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index 1262a51ec12cf..8cd7583d4537c 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(dnfield): Remove this when https://github.com/dart-lang/sdk/issues/35164 is resolved. +// ignore_for_file: unused_element + part of dart.ui; String _decodeUTF8(ByteData message) { diff --git a/lib/ui/isolate_name_server.dart b/lib/ui/isolate_name_server.dart index 4c1833bc52646..cc0c7b0a8f973 100644 --- a/lib/ui/isolate_name_server.dart +++ b/lib/ui/isolate_name_server.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; /// Contains methods to allow for simple sharing of SendPorts across isolates. diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index 7da89828c06f0..28c062b01a856 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(dnfield): remove unused_element when https://github.com/dart-lang/sdk/issues/35164 is resolved. +// ignore_for_file: native_function_body_in_non_sdk_code,unused_element + part of dart.ui; // Corelib 'print' implementation. @@ -80,4 +83,4 @@ Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; // entry point into the VM. This prevents the precompiler from tree shaking // away "main". @pragma('vm:entry-point') -Function _getMainClosure() => main; +Function _getMainClosure() => main; // ignore: undefined_identifier diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index 9a89891ffd75c..95f67d8a6ca38 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; // Some methods in this file assert that their arguments are not null. These diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index 8ebce7de15abf..d23c2be2a01ff 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; /// The possible actions that can be conveyed from the operating system diff --git a/lib/ui/text.dart b/lib/ui/text.dart index e77f4a8156bf4..de0b3984a0690 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; /// Whether to slant the glyphs in the font diff --git a/lib/ui/ui.dart b/lib/ui/ui.dart index 47fa1bb53bc37..5b2844dd59e00 100644 --- a/lib/ui/ui.dart +++ b/lib/ui/ui.dart @@ -9,6 +9,9 @@ /// This library exposes the lowest-level services that Flutter frameworks use /// to bootstrap applications, such as classes for driving the input, graphics /// text, layout, and rendering subsystems. + +// ignore_for_file: import_internal_library, unused_import + library dart.ui; import 'dart:_internal' hide Symbol; diff --git a/lib/ui/window.dart b/lib/ui/window.dart index b9c8298c2c76c..dc64198821a88 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: native_function_body_in_non_sdk_code + part of dart.ui; /// Signature of callbacks that have no arguments and return no data. diff --git a/runtime/fixtures/simple_main.dart b/runtime/fixtures/simple_main.dart index 55187d8642bfa..f47442176160f 100644 --- a/runtime/fixtures/simple_main.dart +++ b/runtime/fixtures/simple_main.dart @@ -3,5 +3,5 @@ // found in the LICENSE file. void main() { - print("Hello"); + print('Hello'); } diff --git a/testing/dart/canvas_test.dart b/testing/dart/canvas_test.dart index 9d4704038e9f0..a5095cd9baa3b 100644 --- a/testing/dart/canvas_test.dart +++ b/testing/dart/canvas_test.dart @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui'; +// ignore_for_file: empty_catches + import 'dart:typed_data'; +import 'dart:ui'; import 'package:test/test.dart'; -typedef void CanvasCallback(Canvas canvas); +typedef CanvasCallback = void Function(Canvas canvas); void testCanvas(CanvasCallback callback) { try { @@ -16,19 +18,20 @@ void testCanvas(CanvasCallback callback) { } void main() { - test("canvas APIs should not crash", () { - Paint paint = Paint(); - Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan); - RRect rrect = RRect.fromRectAndCorners(rect); - Offset offset = Offset(double.nan, double.nan); - Path path = Path(); - Color color = Color(0); - Paragraph paragraph = ParagraphBuilder(ParagraphStyle()).build(); + test('canvas APIs should not crash', () { + final Paint paint = Paint(); + final Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan); + final RRect rrect = RRect.fromRectAndCorners(rect); + const Offset offset = Offset(double.nan, double.nan); + final Path path = Path(); + const Color color = Color(0); + final Paragraph paragraph = ParagraphBuilder(ParagraphStyle()).build(); - PictureRecorder recorder = PictureRecorder(); - Canvas recorderCanvas = Canvas(recorder); - Picture picture = recorder.endRecording(); - Image image = picture.toImage(1, 1); + final PictureRecorder recorder = PictureRecorder(); + final Canvas recorderCanvas = Canvas(recorder); + recorderCanvas.scale(1.0, 1.0); + final Picture picture = recorder.endRecording(); + final Image image = picture.toImage(1, 1); try { Canvas(null, null); } catch (error) { } try { Canvas(null, rect); } catch (error) { } @@ -46,7 +49,7 @@ void main() { testCanvas((Canvas canvas) => canvas.clipRect(rect)); testCanvas((Canvas canvas) => canvas.clipRRect(rrect)); testCanvas((Canvas canvas) => canvas.drawArc(rect, 0.0, 0.0, false, paint)); - testCanvas((Canvas canvas) => canvas.drawAtlas(image, [], [], [], BlendMode.src, rect, paint)); + testCanvas((Canvas canvas) => canvas.drawAtlas(image, [], [], [], BlendMode.src, rect, paint)); testCanvas((Canvas canvas) => canvas.drawCircle(offset, double.nan, paint)); testCanvas((Canvas canvas) => canvas.drawColor(color, BlendMode.src)); testCanvas((Canvas canvas) => canvas.drawDRRect(rrect, rrect, paint)); @@ -59,7 +62,7 @@ void main() { testCanvas((Canvas canvas) => canvas.drawParagraph(paragraph, offset)); testCanvas((Canvas canvas) => canvas.drawPath(path, paint)); testCanvas((Canvas canvas) => canvas.drawPicture(picture)); - testCanvas((Canvas canvas) => canvas.drawPoints(PointMode.points, [], paint)); + testCanvas((Canvas canvas) => canvas.drawPoints(PointMode.points, [], paint)); testCanvas((Canvas canvas) => canvas.drawRawAtlas(image, Float32List(0), Float32List(0), Int32List(0), BlendMode.src, rect, paint)); testCanvas((Canvas canvas) => canvas.drawRawPoints(PointMode.points, Float32List(0), paint)); testCanvas((Canvas canvas) => canvas.drawRect(rect, paint)); @@ -67,7 +70,7 @@ void main() { testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, null)); testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, false)); testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, true)); - testCanvas((Canvas canvas) => canvas.drawVertices(Vertices(VertexMode.triangles, []), null, paint)); + testCanvas((Canvas canvas) => canvas.drawVertices(Vertices(VertexMode.triangles, []), null, paint)); testCanvas((Canvas canvas) => canvas.getSaveCount()); testCanvas((Canvas canvas) => canvas.restore()); testCanvas((Canvas canvas) => canvas.rotate(double.nan)); diff --git a/testing/dart/codec_test.dart b/testing/dart/codec_test.dart index 78b6930f5ea6c..728bfdcc269c1 100644 --- a/testing/dart/codec_test.dart +++ b/testing/dart/codec_test.dart @@ -2,10 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; import 'dart:io'; -import 'dart:ui' as ui; import 'dart:typed_data'; +import 'dart:ui' as ui; import 'package:test/test.dart'; import 'package:path/path.dart' as path; @@ -27,7 +26,7 @@ void main() { }); test('Fails with invalid data', () async { - Uint8List data = new Uint8List.fromList([1, 2, 3]); + final Uint8List data = Uint8List.fromList([1, 2, 3]); expect( ui.instantiateImageCodec(data), throwsA(exceptionWithMessage('operation failed')) @@ -35,64 +34,64 @@ void main() { }); test('nextFrame', () async { - Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes(); - ui.Codec codec = await ui.instantiateImageCodec(data); - List> decodedFrameInfos = []; + final Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes(); + final ui.Codec codec = await ui.instantiateImageCodec(data); + final List> decodedFrameInfos = >[]; for (int i = 0; i < 5; i++) { - ui.FrameInfo frameInfo = await codec.getNextFrame(); - decodedFrameInfos.add([ + final ui.FrameInfo frameInfo = await codec.getNextFrame(); + decodedFrameInfos.add([ frameInfo.duration.inMilliseconds, frameInfo.image.width, frameInfo.image.height, ]); } - expect(decodedFrameInfos, equals([ - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], + expect(decodedFrameInfos, equals(>[ + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], ])); }); test('decodedCacheRatioCap', () async { // No real way to test the native layer, but a smoke test here to at least // verify that animation is still consistent with caching disabled. - Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes(); - ui.Codec codec = await ui.instantiateImageCodec(data, decodedCacheRatioCap: 1.0); - List> decodedFrameInfos = []; + final Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes(); + final ui.Codec codec = await ui.instantiateImageCodec(data, decodedCacheRatioCap: 1.0); + final List> decodedFrameInfos = >[]; for (int i = 0; i < 5; i++) { - ui.FrameInfo frameInfo = await codec.getNextFrame(); - decodedFrameInfos.add([ + final ui.FrameInfo frameInfo = await codec.getNextFrame(); + decodedFrameInfos.add([ frameInfo.duration.inMilliseconds, frameInfo.image.width, frameInfo.image.height, ]); } - expect(decodedFrameInfos, equals([ - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], - [200, 640, 479], + expect(decodedFrameInfos, equals(>[ + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], + [200, 640, 479], ])); }); test('non animated image', () async { - Uint8List data = await _getSkiaResource('baby_tux.png').readAsBytes(); - ui.Codec codec = await ui.instantiateImageCodec(data); - List> decodedFrameInfos = []; + final Uint8List data = await _getSkiaResource('baby_tux.png').readAsBytes(); + final ui.Codec codec = await ui.instantiateImageCodec(data); + final List> decodedFrameInfos = >[]; for (int i = 0; i < 2; i++) { - ui.FrameInfo frameInfo = await codec.getNextFrame(); - decodedFrameInfos.add([ + final ui.FrameInfo frameInfo = await codec.getNextFrame(); + decodedFrameInfos.add([ frameInfo.duration.inMilliseconds, frameInfo.image.width, frameInfo.image.height, ]); } - expect(decodedFrameInfos, equals([ - [0, 240, 246], - [0, 240, 246], + expect(decodedFrameInfos, equals(>[ + [0, 240, 246], + [0, 240, 246], ])); }); } @@ -104,13 +103,13 @@ File _getSkiaResource(String fileName) { // assuming the curent working directory is engine/src. // This is fragile and should be changed once the Platform.script issue is // resolved. - String assetPath = + final String assetPath = path.join('third_party', 'skia', 'resources', 'images', fileName); - return new File(assetPath); + return File(assetPath); } Matcher exceptionWithMessage(String m) { - return predicate((e) { + return predicate((Exception e) { return e is Exception && e.toString().contains(m); }); } diff --git a/testing/dart/color_test.dart b/testing/dart/color_test.dart index 785c819aa7380..c70d2c7182f21 100644 --- a/testing/dart/color_test.dart +++ b/testing/dart/color_test.dart @@ -12,7 +12,7 @@ class NotAColor extends Color { void main() { test('color accessors should work', () { - final Color foo = const Color(0x12345678); + const Color foo = Color(0x12345678); expect(foo.alpha, equals(0x12)); expect(foo.red, equals(0x34)); expect(foo.green, equals(0x56)); @@ -20,7 +20,7 @@ void main() { }); test('paint set to black', () { - final Color c = const Color(0x00000000); + const Color c = Color(0x00000000); final Paint p = new Paint(); p.color = c; expect(c.toString(), equals('Color(0x00000000)')); @@ -28,7 +28,7 @@ void main() { test('color created with out of bounds value', () { try { - final Color c = const Color(0x100 << 24); + const Color c = Color(0x100 << 24); final Paint p = new Paint(); p.color = c; } catch (e) { @@ -38,7 +38,7 @@ void main() { test('color created with wildly out of bounds value', () { try { - final Color c = const Color(1 << 1000000); + const Color c = Color(1 << 1000000); final Paint p = new Paint(); p.color = c; } catch (e) { @@ -48,7 +48,7 @@ void main() { test('two colors are only == if they have the same runtime type', () { expect(const Color(123), equals(const Color(123))); - expect(const Color(123), equals(new Color(123))); + expect(const Color(123), equals(Color(123))); // ignore: prefer_const_constructors expect(const Color(123), isNot(equals(const Color(321)))); expect(const Color(123), isNot(equals(const NotAColor(123)))); expect(const NotAColor(123), isNot(equals(const Color(123)))); @@ -123,14 +123,14 @@ void main() { test('compute gray luminance', () { // Each color component is at 20%. - final Color lightGray = const Color(0xFF333333); + const Color lightGray = Color(0xFF333333); // Relative luminance's formula is just the linearized color value for gray. // ((0.2 + 0.055) / 1.055) ^ 2.4. expect(lightGray.computeLuminance(), equals(0.033104766570885055)); }); test('compute color luminance', () { - final Color brightRed = const Color(0xFFFF3B30); + const Color brightRed = Color(0xFFFF3B30); // 0.2126 * ((1.0 + 0.055) / 1.055) ^ 2.4 + // 0.7152 * ((0.23137254902 +0.055) / 1.055) ^ 2.4 + // 0.0722 * ((0.18823529411 + 0.055) / 1.055) ^ 2.4 diff --git a/testing/dart/encoding_test.dart b/testing/dart/encoding_test.dart index 28bba46303e92..81e53046fb68c 100644 --- a/testing/dart/encoding_test.dart +++ b/testing/dart/encoding_test.dart @@ -3,9 +3,9 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:ui'; -import 'dart:typed_data'; import 'dart:io'; +import 'dart:typed_data'; +import 'dart:ui'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; @@ -20,14 +20,14 @@ void main() { group('Image.toByteData', () { group('RGBA format', () { test('works with simple image', () async { - ByteData data = await Square4x4Image.image.toByteData(); - expect(new Uint8List.view(data.buffer), Square4x4Image.bytes); + final ByteData data = await Square4x4Image.image.toByteData(); + expect(Uint8List.view(data.buffer), Square4x4Image.bytes); }); test('converts grayscale images', () async { - Image image = await GrayscaleImage.load(); - ByteData data = await image.toByteData(); - Uint8List bytes = data.buffer.asUint8List(); + final Image image = await GrayscaleImage.load(); + final ByteData data = await image.toByteData(); + final Uint8List bytes = data.buffer.asUint8List(); expect(bytes, hasLength(16)); expect(bytes, GrayscaleImage.bytesAsRgba); }); @@ -35,15 +35,15 @@ void main() { group('Unmodified format', () { test('works with simple image', () async { - Image image = Square4x4Image.image; - ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); - expect(new Uint8List.view(data.buffer), Square4x4Image.bytes); + final Image image = Square4x4Image.image; + final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); + expect(Uint8List.view(data.buffer), Square4x4Image.bytes); }); test('works with grayscale images', () async { - Image image = await GrayscaleImage.load(); - ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); - Uint8List bytes = data.buffer.asUint8List(); + final Image image = await GrayscaleImage.load(); + final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); + final Uint8List bytes = data.buffer.asUint8List(); expect(bytes, hasLength(4)); expect(bytes, GrayscaleImage.bytesUnmodified); }); @@ -51,46 +51,48 @@ void main() { group('PNG format', () { test('works with simple image', () async { - Image image = Square4x4Image.image; - ByteData data = await image.toByteData(format: ImageByteFormat.png); - List expected = await readFile('square.png'); - expect(new Uint8List.view(data.buffer), expected); + final Image image = Square4x4Image.image; + final ByteData data = await image.toByteData(format: ImageByteFormat.png); + final List expected = await readFile('square.png'); + expect(Uint8List.view(data.buffer), expected); }); }); }); } class Square4x4Image { + Square4x4Image._(); + static Image get image { - double width = _kWidth.toDouble(); - double radius = _kRadius.toDouble(); - double innerWidth = (_kWidth - 2 * _kRadius).toDouble(); + final double width = _kWidth.toDouble(); + final double radius = _kRadius.toDouble(); + final double innerWidth = (_kWidth - 2 * _kRadius).toDouble(); - PictureRecorder recorder = new PictureRecorder(); - Canvas canvas = - new Canvas(recorder, new Rect.fromLTWH(0.0, 0.0, width, width)); + final PictureRecorder recorder = PictureRecorder(); + final Canvas canvas = + Canvas(recorder, Rect.fromLTWH(0.0, 0.0, width, width)); - Paint black = new Paint() + final Paint black = Paint() ..strokeWidth = 1.0 ..color = _kBlack; - Paint green = new Paint() + final Paint green = Paint() ..strokeWidth = 1.0 ..color = _kGreen; - canvas.drawRect(new Rect.fromLTWH(0.0, 0.0, width, width), black); + canvas.drawRect(Rect.fromLTWH(0.0, 0.0, width, width), black); canvas.drawRect( - new Rect.fromLTWH(radius, radius, innerWidth, innerWidth), green); + Rect.fromLTWH(radius, radius, innerWidth, innerWidth), green); return recorder.endRecording().toImage(_kWidth, _kWidth); } static List get bytes { - int bytesPerChannel = 4; - List result = new List(_kWidth * _kWidth * bytesPerChannel); + const int bytesPerChannel = 4; + final List result = List(_kWidth * _kWidth * bytesPerChannel); - fillWithColor(Color color, int min, int max) { + void fillWithColor(Color color, int min, int max) { for (int i = min; i < max; i++) { for (int j = min; j < max; j++) { - int offset = i * bytesPerChannel + j * _kWidth * bytesPerChannel; + final int offset = i * bytesPerChannel + j * _kWidth * bytesPerChannel; result[offset] = color.red; result[offset + 1] = color.green; result[offset + 2] = color.blue; @@ -107,9 +109,11 @@ class Square4x4Image { } class GrayscaleImage { + GrayscaleImage._(); + static Future load() async { - Uint8List bytes = await readFile('4x4.png'); - Completer completer = new Completer(); + final Uint8List bytes = await readFile('4x4.png'); + final Completer completer = Completer(); decodeImageFromList(bytes, (Image image) => completer.complete(image)); return await completer.future; } @@ -126,7 +130,7 @@ class GrayscaleImage { static List get bytesUnmodified => [255, 127, 127, 0]; } -Future readFile(fileName) async { - final file = new File(path.join('flutter', 'testing', 'resources', fileName)); +Future readFile(String fileName) async { + final File file = File(path.join('flutter', 'testing', 'resources', fileName)); return await file.readAsBytes(); } diff --git a/testing/dart/gradient_test.dart b/testing/dart/gradient_test.dart index b0160d019fd05..5e1bd6fd6ff13 100644 --- a/testing/dart/gradient_test.dart +++ b/testing/dart/gradient_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:typed_data' show Float64List; import 'dart:ui'; import 'package:test/test.dart'; @@ -66,7 +65,7 @@ void main() { Offset.zero, 1.0, ), - throwsA(const isInstanceOf()), + throwsA(const TypeMatcher()), ); }); } diff --git a/testing/dart/isolate_name_server_test.dart b/testing/dart/isolate_name_server_test.dart index d48eefc084815..5a02d9722dd4d 100644 --- a/testing/dart/isolate_name_server_test.dart +++ b/testing/dart/isolate_name_server_test.dart @@ -2,24 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; import 'dart:isolate'; import 'dart:ui'; import 'package:test/test.dart'; -const kPortName = 'foobar'; -const kErrorCode = -1; -const kStartCode = 0; -const kCloseCode = 1; -const kDeletedCode = 2; +const String kPortName = 'foobar'; +const int kErrorCode = -1; +const int kStartCode = 0; +const int kCloseCode = 1; +const int kDeletedCode = 2; void isolateSpawnEntrypoint(SendPort port) { - sendHelper(int code, [String message = '']) { + void sendHelper(int code, [String message = '']) { port.send([code, message]); } - SendPort shared = IsolateNameServer.lookupPortByName(kPortName); + final SendPort shared = IsolateNameServer.lookupPortByName(kPortName); if (shared == null) { sendHelper(kErrorCode, 'Could not find port: $kPortName'); return; @@ -35,7 +34,7 @@ void isolateSpawnEntrypoint(SendPort port) { // send another message to ensure we don't crash. shared.send('garbage'); - bool result = IsolateNameServer.removePortNameMapping(kPortName); + final bool result = IsolateNameServer.removePortNameMapping(kPortName); if (result) { sendHelper(kDeletedCode); } else { @@ -55,14 +54,14 @@ void main() { expect(IsolateNameServer.removePortNameMapping(kPortName), isFalse); // Register a SendPort. - final receivePort = new ReceivePort(); - final sendPort = receivePort.sendPort; + final ReceivePort receivePort = ReceivePort(); + final SendPort sendPort = receivePort.sendPort; expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue); expect(IsolateNameServer.lookupPortByName(kPortName), sendPort); // Check we can't register the same name twice. - final receivePort2 = new ReceivePort(); - final sendPort2 = receivePort2.sendPort; + final ReceivePort receivePort2 = ReceivePort(); + final SendPort sendPort2 = receivePort2.sendPort; expect( IsolateNameServer.registerPortWithName(sendPort2, kPortName), isFalse); expect(IsolateNameServer.lookupPortByName(kPortName), sendPort); @@ -83,13 +82,13 @@ void main() { test('isolate name server multi-isolate', () async { // Register our send port with the name server. - final receivePort = new ReceivePort(); - final sendPort = receivePort.sendPort; + final ReceivePort receivePort = ReceivePort(); + final SendPort sendPort = receivePort.sendPort; expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue); // Test driver. - final testReceivePort = new ReceivePort(); - testReceivePort.listen(expectAsync1((response) { + final ReceivePort testReceivePort = ReceivePort(); + testReceivePort.listen(expectAsync1((dynamic response) { final int code = response[0]; final String message = response[1]; switch (code) { @@ -110,7 +109,7 @@ void main() { } }, count: 3)); - receivePort.listen(expectAsync1((message) { + receivePort.listen(expectAsync1((dynamic message) { // If we don't get this message, we timeout and fail. expect(message, kPortName); })); diff --git a/testing/dart/locale_test.dart b/testing/dart/locale_test.dart index 9fcab7334ac5d..576df68af7064 100644 --- a/testing/dart/locale_test.dart +++ b/testing/dart/locale_test.dart @@ -8,12 +8,12 @@ import 'package:test/test.dart'; void main() { test('Locale', () { - final Null $null = null; + const Null $null = null; expect(const Locale('en').toString(), 'en'); - expect(const Locale('en'), new Locale('en', $null)); - expect(const Locale('en').hashCode, new Locale('en', $null).hashCode); - expect(const Locale('en'), isNot(new Locale('en', ''))); - expect(const Locale('en').hashCode, isNot(new Locale('en', '').hashCode)); + expect(const Locale('en'), const Locale('en', $null)); + expect(const Locale('en').hashCode, const Locale('en', $null).hashCode); + expect(const Locale('en'), isNot(const Locale('en', ''))); + expect(const Locale('en').hashCode, isNot(const Locale('en', '').hashCode)); expect(const Locale('en', 'US').toString(), 'en_US'); expect(const Locale('iw').toString(), 'he'); expect(const Locale('iw', 'DD').toString(), 'he_DE'); @@ -32,17 +32,17 @@ void main() { expect(const Locale.fromSubtags(countryCode: 'US').toString(), 'und_US'); expect(const Locale.fromSubtags(countryCode: 'US').countryCode, 'US'); - expect(Locale.fromSubtags(languageCode: 'es', countryCode: '419').toString(), 'es_419'); - expect(Locale.fromSubtags(languageCode: 'es', countryCode: '419').languageCode, 'es'); - expect(Locale.fromSubtags(languageCode: 'es', countryCode: '419').countryCode, '419'); + expect(const Locale.fromSubtags(languageCode: 'es', countryCode: '419').toString(), 'es_419'); + expect(const Locale.fromSubtags(languageCode: 'es', countryCode: '419').languageCode, 'es'); + expect(const Locale.fromSubtags(languageCode: 'es', countryCode: '419').countryCode, '419'); - expect(Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN').toString(), 'zh_Hans_CN'); + expect(const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN').toString(), 'zh_Hans_CN'); }); test('Locale equality', () { - expect(Locale.fromSubtags(languageCode: 'en'), - isNot(Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn'))); - expect(Locale.fromSubtags(languageCode: 'en').hashCode, - isNot(Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode)); + expect(const Locale.fromSubtags(languageCode: 'en'), + isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn'))); + expect(const Locale.fromSubtags(languageCode: 'en').hashCode, + isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode)); }); } diff --git a/testing/dart/paragraph_builder_test.dart b/testing/dart/paragraph_builder_test.dart index 0743825f8e29b..ba0b9376aa9c4 100644 --- a/testing/dart/paragraph_builder_test.dart +++ b/testing/dart/paragraph_builder_test.dart @@ -13,7 +13,7 @@ void main() { final Paragraph paragraph = builder.build(); expect(paragraph, isNotNull); - paragraph.layout(ParagraphConstraints(width: 800.0)); + paragraph.layout(const ParagraphConstraints(width: 800.0)); expect(paragraph.width, isNonZero); expect(paragraph.height, isNonZero); }); diff --git a/testing/dart/path_test.dart b/testing/dart/path_test.dart index 1c569dd5ea286..a4b4a609461f3 100644 --- a/testing/dart/path_test.dart +++ b/testing/dart/path_test.dart @@ -93,7 +93,7 @@ void main() { test('transformation tests', () { final Rect bounds = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0); final Path p = new Path()..addRect(bounds); - final Float64List scaleMatrix = new Float64List.fromList([ + final Float64List scaleMatrix = Float64List.fromList([ 2.5, 0.0, 0.0, 0.0, // first col 0.0, 0.5, 0.0, 0.0, // second col 0.0, 0.0, 1.0, 0.0, // third col @@ -178,7 +178,7 @@ void main() { final double midPoint = simpleMetricsDiagonal.iterator.current.length / 2; final Tangent posTanDiagonal = simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint); - expect(posTanDiagonal.position, equals(new Offset(5.0, 5.0))); + expect(posTanDiagonal.position, equals(const Offset(5.0, 5.0))); expect(posTanDiagonal.angle, closeTo(-0.7853981633974483, .00001)); // ~45 degrees diff --git a/testing/dart/plugin_utilities_test.dart b/testing/dart/plugin_utilities_test.dart index 27d7d60d57138..057b17cf76a4c 100644 --- a/testing/dart/plugin_utilities_test.dart +++ b/testing/dart/plugin_utilities_test.dart @@ -6,7 +6,7 @@ import 'dart:ui'; import 'package:test/test.dart'; -String top() => "top"; +String top() => 'top'; class Foo { const Foo(); @@ -19,29 +19,29 @@ const Foo foo = const Foo(); void main() { test('PluginUtilities Callback Handles', () { // Top level callback. - final hTop = PluginUtilities.getCallbackHandle(top); + final CallbackHandle hTop = PluginUtilities.getCallbackHandle(top); expect(hTop, isNotNull); expect(hTop, isNot(0)); expect(PluginUtilities.getCallbackHandle(top), hTop); - final topClosure = PluginUtilities.getCallbackFromHandle(hTop); + final Function topClosure = PluginUtilities.getCallbackFromHandle(hTop); expect(topClosure, isNotNull); - expect(topClosure(), "top"); + expect(topClosure(), 'top'); // Static method callback. - final hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt); + final CallbackHandle hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt); expect(hGetInt, isNotNull); expect(hGetInt, isNot(0)); expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt); - final getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt); + final Function getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt); expect(getIntClosure, isNotNull); expect(getIntClosure(), 1); // Instance method callbacks cannot be looked up. - final foo = new Foo(); + const Foo foo = Foo(); expect(PluginUtilities.getCallbackHandle(foo.getDouble), isNull); // Anonymous closures cannot be looked up. - final anon = (int a, int b) => a + b; + final Function anon = (int a, int b) => a + b; expect(PluginUtilities.getCallbackHandle(anon), isNull); }); } diff --git a/testing/dart/pubspec.yaml b/testing/dart/pubspec.yaml index ec3ea88b2ac6d..ccffd1626119b 100644 --- a/testing/dart/pubspec.yaml +++ b/testing/dart/pubspec.yaml @@ -2,3 +2,9 @@ name: engine_tests dependencies: test: 1.3.0 path: 1.6.2 + +dependency_overrides: + sky_engine: + path: ../../../out/host_debug_unopt/gen/dart-pkg/sky_engine + sky_services: + path: ../../../out/host_debug_unopt/gen/dart-pkg/sky_services \ No newline at end of file diff --git a/testing/dart/rect_test.dart b/testing/dart/rect_test.dart index ed352a1474491..b392932c662ea 100644 --- a/testing/dart/rect_test.dart +++ b/testing/dart/rect_test.dart @@ -7,16 +7,16 @@ import 'dart:ui'; import 'package:test/test.dart'; void main() { - test("rect accessors", () { - final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); + test('rect accessors', () { + final Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); expect(r.left, equals(1.0)); expect(r.top, equals(3.0)); expect(r.right, equals(5.0)); expect(r.bottom, equals(7.0)); }); - test("rect created by width and height", () { - final Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); + test('rect created by width and height', () { + final Rect r = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); expect(r.left, equals(1.0)); expect(r.top, equals(3.0)); expect(r.right, equals(6.0)); @@ -25,9 +25,9 @@ void main() { expect(r.longestSide, equals(7.0)); }); - test("rect intersection", () { - final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); - final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); + test('rect intersection', () { + final Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); + final Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); final Rect r3 = r1.intersect(r2); expect(r3.left, equals(50.0)); expect(r3.top, equals(50.0)); @@ -37,9 +37,9 @@ void main() { expect(r4, equals(r3)); }); - test("rect expandToInclude overlapping rects", () { - final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); - final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); + test('rect expandToInclude overlapping rects', () { + final Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); + final Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); final Rect r3 = r1.expandToInclude(r2); expect(r3.left, equals(0.0)); expect(r3.top, equals(0.0)); @@ -49,9 +49,9 @@ void main() { expect(r4, equals(r3)); }); - test("rect expandToInclude crossing rects", () { - final Rect r1 = new Rect.fromLTRB(50.0, 0.0, 50.0, 200.0); - final Rect r2 = new Rect.fromLTRB(0.0, 50.0, 200.0, 50.0); + test('rect expandToInclude crossing rects', () { + final Rect r1 = Rect.fromLTRB(50.0, 0.0, 50.0, 200.0); + final Rect r2 = Rect.fromLTRB(0.0, 50.0, 200.0, 50.0); final Rect r3 = r1.expandToInclude(r2); expect(r3.left, equals(0.0)); expect(r3.top, equals(0.0)); @@ -61,17 +61,17 @@ void main() { expect(r4, equals(r3)); }); - test("size created from doubles", () { - final Size size = new Size(5.0, 7.0); + test('size created from doubles', () { + const Size size = Size(5.0, 7.0); expect(size.width, equals(5.0)); expect(size.height, equals(7.0)); expect(size.shortestSide, equals(5.0)); expect(size.longestSide, equals(7.0)); }); - test("rounded rect created from rect and radii", () { - final Rect baseRect = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); - final RRect r = new RRect.fromRectXY(baseRect, 1.0, 1.0); + test('rounded rect created from rect and radii', () { + final Rect baseRect = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); + final RRect r = RRect.fromRectXY(baseRect, 1.0, 1.0); expect(r.left, equals(1.0)); expect(r.top, equals(3.0)); expect(r.right, equals(6.0)); diff --git a/testing/dart/window_test.dart b/testing/dart/window_test.dart index 110e9af4ec86f..e9b20ebd327c9 100644 --- a/testing/dart/window_test.dart +++ b/testing/dart/window_test.dart @@ -12,7 +12,7 @@ void main() { test('window.sendPlatformMessage preserves callback zone', () { runZoned(() { final Zone innerZone = Zone.current; - window.sendPlatformMessage('test', new ByteData.view(new Uint8List(0).buffer), expectAsync((ByteData data) { + window.sendPlatformMessage('test', new ByteData.view(new Uint8List(0).buffer), expectAsync1((ByteData data) { final Zone runZone = Zone.current; expect(runZone, isNotNull); expect(runZone, same(innerZone)); diff --git a/testing/fail_test.dart b/testing/fail_test.dart index 5d88caaaa5d47..561b7f2cc924b 100644 --- a/testing/fail_test.dart +++ b/testing/fail_test.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(dnfield): move this to somewhere with a pubspec +// ignore_for_file: uri_does_not_exist,undefined_function,undefined_identifier + import 'package:test/test.dart'; void main() { diff --git a/testing/symbols/verify_exported.dart b/testing/symbols/verify_exported.dart index 37ff8f5be5f6a..e2c61e0ba1267 100644 --- a/testing/symbols/verify_exported.dart +++ b/testing/symbols/verify_exported.dart @@ -30,7 +30,7 @@ void main(List arguments) { final Iterable releaseBuilds = new Directory(outPath).listSync() .where((FileSystemEntity entity) => entity is Directory) - .map((FileSystemEntity dir) => p.basename(dir.path)) + .map((FileSystemEntity dir) => p.basename(dir.path)) .where((String s) => s.contains('_release')); final Iterable iosReleaseBuilds = releaseBuilds From ed09b300aa9319442ee8ae47536141d0cbb0c68f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 09:15:47 -0800 Subject: [PATCH 2/9] Avoid ignore_for_file --- analysis_options.yaml | 1 + ci/analyze.sh | 11 +----- lib/snapshot/snapshot.dart | 20 +++++------ lib/snapshot/snapshot_fuchsia.dart | 26 +++++++------- lib/ui/compositing.dart | 54 ++++++++++++++---------------- lib/ui/isolate_name_server.dart | 8 ++--- lib/ui/natives.dart | 23 ++++++------- lib/ui/painting.dart | 2 -- lib/ui/semantics.dart | 2 -- lib/ui/text.dart | 2 -- lib/ui/ui.dart | 6 ++-- lib/ui/window.dart | 2 -- testing/dart/canvas_test.dart | 14 ++++---- 13 files changed, 71 insertions(+), 100 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 561108e9626af..699ca970ef474 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -17,6 +17,7 @@ analyzer: missing_required_param: warning # treat missing returns as a warning (not a hint) missing_return: warning + native_function_body_in_non_sdk_code: ignore # allow having TODOs in the code todo: ignore # `flutter analyze` (without `--watch`) just ignores directories diff --git a/ci/analyze.sh b/ci/analyze.sh index c86d506858e0c..8d6e3bf18e96f 100755 --- a/ci/analyze.sh +++ b/ci/analyze.sh @@ -2,16 +2,7 @@ echo "Analyzing dart:ui library..." RESULTS=`dartanalyzer \ --options flutter/analysis_options.yaml \ - out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \ - 2>&1 \ - | grep -v "Native functions can only be declared in the SDK and code that is loaded through native extensions" \ - | grep -Ev "The function '.+' (is not|isn't) used" \ - | grep -Ev "The top level variable '.+' isn't used" \ - | grep -Ev "Undefined name 'main'" \ - | grep -v "The library 'dart:_internal' is internal" \ - | grep -Ev "Unused import.+ui\.dart" \ - | grep -Ev "[0-9]+ errors.*found\." \ - | grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"` + out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart` echo "$RESULTS" if [ -n "$RESULTS" ]; then diff --git a/lib/snapshot/snapshot.dart b/lib/snapshot/snapshot.dart index 038e312208495..b2fc465821856 100644 --- a/lib/snapshot/snapshot.dart +++ b/lib/snapshot/snapshot.dart @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: unused_import,uri_does_not_exist - -import 'dart:async'; -import 'dart:collection'; -import 'dart:convert'; +import 'dart:async'; // ignore: unused_import +import 'dart:collection'; // ignore: unused_import +import 'dart:convert'; // ignore: unused_import import 'dart:core'; -import 'dart:developer'; -import 'dart:io'; -import 'dart:isolate'; -import 'dart:math'; -import 'dart:typed_data'; -import 'dart:ui'; +import 'dart:developer'; // ignore: unused_import +import 'dart:io'; // ignore: unused_import +import 'dart:isolate'; // ignore: unused_import +import 'dart:math'; // ignore: unused_import +import 'dart:typed_data'; // ignore: unused_import +import 'dart:ui'; // ignore: uri_does_not_exist diff --git a/lib/snapshot/snapshot_fuchsia.dart b/lib/snapshot/snapshot_fuchsia.dart index c0f52efae2ea7..83507acadb907 100644 --- a/lib/snapshot/snapshot_fuchsia.dart +++ b/lib/snapshot/snapshot_fuchsia.dart @@ -2,18 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: unused_import,uri_does_not_exist - -import 'dart:async'; -import 'dart:collection'; -import 'dart:convert'; +import 'dart:async'; // ignore: unused_import +import 'dart:collection'; // ignore: unused_import +import 'dart:convert'; // ignore: unused_import import 'dart:core'; -import 'dart:developer'; -import 'dart:fuchsia'; -import 'dart:io'; -import 'dart:isolate'; -import 'dart:math'; -import 'dart:mozart.internal'; -import 'dart:typed_data'; -import 'dart:ui'; -import 'dart:zircon'; +import 'dart:developer'; // ignore: unused_import +import 'dart:fuchsia'; // ignore: uri_does_not_exist +import 'dart:io'; // ignore: unused_import +import 'dart:isolate'; // ignore: unused_import +import 'dart:math'; // ignore: unused_import +import 'dart:mozart.internal'; // ignore: uri_does_not_exist +import 'dart:typed_data'; // ignore: unused_import +import 'dart:ui'; // ignore: uri_does_not_exist +import 'dart:zircon'; // ignore: uri_does_not_exist diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index 2df7e5b2a6c16..3cc9d3947a2ed 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; /// An opaque object representing a composited scene. @@ -32,12 +30,12 @@ class Scene extends NativeFieldWrapperClass2 { ); } - String _toImage(int width, int height, _Callback callback) native 'Scene_toImage'; + String _toImage(int width, int height, _Callback callback) native 'Scene_toImage'; // ignore: native_function_body_in_non_sdk_code /// Releases the resources used by this scene. /// /// After calling this function, the scene is cannot be used further. - void dispose() native 'Scene_dispose'; + void dispose() native 'Scene_dispose'; // ignore: native_function_body_in_non_sdk_code } /// Builds a [Scene] containing the given visuals. @@ -51,7 +49,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// Creates an empty [SceneBuilder] object. @pragma('vm:entry-point') SceneBuilder() { _constructor(); } - void _constructor() native 'SceneBuilder_constructor'; + void _constructor() native 'SceneBuilder_constructor'; // ignore: native_function_body_in_non_sdk_code /// Pushes a transform operation onto the operation stack. /// @@ -65,14 +63,14 @@ class SceneBuilder extends NativeFieldWrapperClass2 { throw new ArgumentError('"matrix4" must have 16 entries.'); return _pushTransform(matrix4); } - EngineLayer _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform'; + EngineLayer _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform'; // ignore: native_function_body_in_non_sdk_code /// Pushes an offset operation onto the operation stack. /// /// This is equivalent to [pushTransform] with a matrix with only translation. /// /// See [pop] for details about the operation stack. - EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset'; + EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset'; // ignore: native_function_body_in_non_sdk_code /// Pushes a rectangular clip operation onto the operation stack. /// @@ -89,7 +87,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double right, double top, double bottom, - int clipBehavior) native 'SceneBuilder_pushClipRect'; + int clipBehavior) native 'SceneBuilder_pushClipRect'; // ignore: native_function_body_in_non_sdk_code /// Pushes a rounded-rectangular clip operation onto the operation stack. /// @@ -102,7 +100,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(clipBehavior != Clip.none); return _pushClipRRect(rrect._value, clipBehavior.index); } - EngineLayer _pushClipRRect(Float32List rrect, int clipBehavior) native 'SceneBuilder_pushClipRRect'; + EngineLayer _pushClipRRect(Float32List rrect, int clipBehavior) native 'SceneBuilder_pushClipRRect'; // ignore: native_function_body_in_non_sdk_code /// Pushes a path clip operation onto the operation stack. /// @@ -115,7 +113,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(clipBehavior != Clip.none); return _pushClipPath(path, clipBehavior.index); } - EngineLayer _pushClipPath(Path path, int clipBehavior) native 'SceneBuilder_pushClipPath'; + EngineLayer _pushClipPath(Path path, int clipBehavior) native 'SceneBuilder_pushClipPath'; // ignore: native_function_body_in_non_sdk_code /// Pushes an opacity operation onto the operation stack. /// @@ -128,7 +126,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushOpacity(int alpha, {Offset offset = Offset.zero}) { return _pushOpacity(alpha, offset.dx, offset.dy); } - EngineLayer _pushOpacity(int alpha, double dx, double dy) native 'SceneBuilder_pushOpacity'; + EngineLayer _pushOpacity(int alpha, double dx, double dy) native 'SceneBuilder_pushOpacity'; // ignore: native_function_body_in_non_sdk_code /// Pushes a color filter operation onto the operation stack. /// @@ -139,7 +137,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushColorFilter(Color color, BlendMode blendMode) { return _pushColorFilter(color.value, blendMode.index); } - EngineLayer _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; + EngineLayer _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; // ignore: native_function_body_in_non_sdk_code /// Pushes a backdrop filter operation onto the operation stack. /// @@ -147,7 +145,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// rasterizing the given objects. /// /// See [pop] for details about the operation stack. - EngineLayer pushBackdropFilter(ImageFilter filter) native 'SceneBuilder_pushBackdropFilter'; + EngineLayer pushBackdropFilter(ImageFilter filter) native 'SceneBuilder_pushBackdropFilter'; // ignore: native_function_body_in_non_sdk_code /// Pushes a shader mask operation onto the operation stack. /// @@ -168,7 +166,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double maskRectRight, double maskRectTop, double maskRectBottom, - int blendMode) native 'SceneBuilder_pushShaderMask'; + int blendMode) native 'SceneBuilder_pushShaderMask'; // ignore: native_function_body_in_non_sdk_code /// Pushes a physical layer operation for an arbitrary shape onto the /// operation stack. @@ -186,7 +184,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushPhysicalShape({ Path path, double elevation, Color color, Color shadowColor, Clip clipBehavior = defaultClipBehavior}) { return _pushPhysicalShape(path, elevation, color.value, shadowColor?.value ?? 0xFF000000, clipBehavior.index); } - EngineLayer _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native + EngineLayer _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native // ignore: native_function_body_in_non_sdk_code 'SceneBuilder_pushPhysicalShape'; /// Ends the effect of the most recently pushed operation. @@ -195,7 +193,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// operations in the stack applies to each of the objects added to the scene. /// Calling this function removes the most recently added operation from the /// stack. - void pop() native 'SceneBuilder_pop'; + void pop() native 'SceneBuilder_pop'; // ignore: native_function_body_in_non_sdk_code /// Add a retained engine layer subtree from previous frames. /// @@ -205,7 +203,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// Therefore, when implementing a subclass of the [Layer] concept defined in /// the rendering layer of Flutter's framework, once this is called, there's /// no need to call [addToScene] for its children layers. - EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained'; + EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained'; // ignore: native_function_body_in_non_sdk_code /// Adds an object to the scene that displays performance statistics. /// @@ -242,7 +240,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double left, double right, double top, - double bottom) native 'SceneBuilder_addPerformanceOverlay'; + double bottom) native 'SceneBuilder_addPerformanceOverlay'; // ignore: native_function_body_in_non_sdk_code /// Adds a [Picture] to the scene. /// @@ -255,7 +253,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { hints |= 2; _addPicture(offset.dx, offset.dy, picture, hints); } - void _addPicture(double dx, double dy, Picture picture, int hints) native 'SceneBuilder_addPicture'; + void _addPicture(double dx, double dy, Picture picture, int hints) native 'SceneBuilder_addPicture'; // ignore: native_function_body_in_non_sdk_code /// Adds a backend texture to the scene. /// @@ -272,7 +270,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(offset != null, 'Offset argument was null'); _addTexture(offset.dx, offset.dy, width, height, textureId, freeze); } - void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze) native 'SceneBuilder_addTexture'; + void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze) native 'SceneBuilder_addTexture'; // ignore: native_function_body_in_non_sdk_code /// Adds a platform view (e.g an iOS UIView) to the scene. /// @@ -294,7 +292,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(offset != null, 'Offset argument was null'); _addPlatformView(offset.dx, offset.dy, width, height, viewId); } - void _addPlatformView(double dx, double dy, double width, double height, int viewId) native 'SceneBuilder_addPlatformView'; + void _addPlatformView(double dx, double dy, double width, double height, int viewId) native 'SceneBuilder_addPlatformView'; // ignore: native_function_body_in_non_sdk_code /// (Fuchsia-only) Adds a scene rendered by another application to the scene /// for this application. @@ -317,7 +315,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double width, double height, SceneHost sceneHost, - bool hitTestable) native 'SceneBuilder_addChildScene'; + bool hitTestable) native 'SceneBuilder_addChildScene'; // ignore: native_function_body_in_non_sdk_code /// Sets a threshold after which additional debugging information should be recorded. /// @@ -325,7 +323,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). /// We'll hopefully be able to figure out how to make this feature more useful /// to you. - void setRasterizerTracingThreshold(int frameInterval) native 'SceneBuilder_setRasterizerTracingThreshold'; + void setRasterizerTracingThreshold(int frameInterval) native 'SceneBuilder_setRasterizerTracingThreshold'; // ignore: native_function_body_in_non_sdk_code /// Sets whether the raster cache should checkerboard cached entries. This is /// only useful for debugging purposes. @@ -342,13 +340,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// Currently this interface is difficult to use by end-developers. If you're /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). - void setCheckerboardRasterCacheImages(bool checkerboard) native 'SceneBuilder_setCheckerboardRasterCacheImages'; + void setCheckerboardRasterCacheImages(bool checkerboard) native 'SceneBuilder_setCheckerboardRasterCacheImages'; // ignore: native_function_body_in_non_sdk_code /// Sets whether the compositor should checkerboard layers that are rendered /// to offscreen bitmaps. /// /// This is only useful for debugging purposes. - void setCheckerboardOffscreenLayers(bool checkerboard) native 'SceneBuilder_setCheckerboardOffscreenLayers'; + void setCheckerboardOffscreenLayers(bool checkerboard) native 'SceneBuilder_setCheckerboardOffscreenLayers'; // ignore: native_function_body_in_non_sdk_code /// Finishes building the scene. /// @@ -358,7 +356,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// After calling this function, the scene builder object is invalid and /// cannot be used further. - Scene build() native 'SceneBuilder_build'; + Scene build() native 'SceneBuilder_build'; // ignore: native_function_body_in_non_sdk_code } /// (Fuchsia-only) Hosts content provided by another application. @@ -378,10 +376,10 @@ class SceneHost extends NativeFieldWrapperClass2 { SceneHost(dynamic exportTokenHandle) { _constructor(exportTokenHandle); } - void _constructor(dynamic exportTokenHandle) native 'SceneHost_constructor'; + void _constructor(dynamic exportTokenHandle) native 'SceneHost_constructor'; // ignore: native_function_body_in_non_sdk_code /// Releases the resources associated with the child scene host. /// /// After calling this function, the child scene host cannot be used further. - void dispose() native 'SceneHost_dispose'; + void dispose() native 'SceneHost_dispose'; // ignore: native_function_body_in_non_sdk_code } diff --git a/lib/ui/isolate_name_server.dart b/lib/ui/isolate_name_server.dart index cc0c7b0a8f973..04784026f4756 100644 --- a/lib/ui/isolate_name_server.dart +++ b/lib/ui/isolate_name_server.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; /// Contains methods to allow for simple sharing of SendPorts across isolates. @@ -37,9 +35,9 @@ abstract class IsolateNameServer { } static SendPort _lookupPortByName(String name) - native 'IsolateNameServerNatives_LookupPortByName'; + native 'IsolateNameServerNatives_LookupPortByName'; // ignore: native_function_body_in_non_sdk_code static bool _registerPortWithName(SendPort port, String name) - native 'IsolateNameServerNatives_RegisterPortWithName'; + native 'IsolateNameServerNatives_RegisterPortWithName'; // ignore: native_function_body_in_non_sdk_code static bool _removePortNameMapping(String name) - native 'IsolateNameServerNatives_RemovePortNameMapping'; + native 'IsolateNameServerNatives_RemovePortNameMapping'; // ignore: native_function_body_in_non_sdk_code } diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index 28c062b01a856..a5ca2d81cb02e 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(dnfield): remove unused_element when https://github.com/dart-lang/sdk/issues/35164 is resolved. -// ignore_for_file: native_function_body_in_non_sdk_code,unused_element +// TODO(dnfield): remove unused_element ignores when https://github.com/dart-lang/sdk/issues/35164 is resolved. part of dart.ui; @@ -13,7 +12,7 @@ void _print(dynamic arg) { } class _Logger { - static void _printString(String s) native 'Logger_PrintString'; + static void _printString(String s) native 'Logger_PrintString'; // ignore: native_function_body_in_non_sdk_code } // A service protocol extension to schedule a frame to be rendered into the @@ -31,7 +30,7 @@ Future _scheduleFrame( } @pragma('vm:entry-point') -void _setupHooks() { +void _setupHooks() { // ignore: unused_element assert(() { // In debug mode, register the schedule frame extension. developer.registerExtension('ext.ui.window.scheduleFrame', _scheduleFrame); @@ -62,20 +61,20 @@ List saveCompilationTrace() { return result; } -dynamic _saveCompilationTrace() native 'SaveCompilationTrace'; +dynamic _saveCompilationTrace() native 'SaveCompilationTrace'; // ignore: native_function_body_in_non_sdk_code -void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask'; +void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask'; // ignore: native_function_body_in_non_sdk_code -int _getCallbackHandle(Function closure) native 'GetCallbackHandle'; -Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle'; +int _getCallbackHandle(Function closure) native 'GetCallbackHandle'; // ignore: native_function_body_in_non_sdk_code +Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle'; // ignore: native_function_body_in_non_sdk_code // Required for gen_snapshot to work correctly. -int _isolateId; +int _isolateId; // ignore: unused_element @pragma('vm:entry-point') -Function _getPrintClosure() => _print; +Function _getPrintClosure() => _print; // ignore: unused_element @pragma('vm:entry-point') -Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; +Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; // ignore: unused_element // Though the "main" symbol is not included in any of the libraries imported // above, the builtin library will be included manually during VM setup. This @@ -83,4 +82,4 @@ Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; // entry point into the VM. This prevents the precompiler from tree shaking // away "main". @pragma('vm:entry-point') -Function _getMainClosure() => main; // ignore: undefined_identifier +Function _getMainClosure() => main; // ignore: unused_element, undefined_identifier diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index 95f67d8a6ca38..9a89891ffd75c 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; // Some methods in this file assert that their arguments are not null. These diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index d23c2be2a01ff..8ebce7de15abf 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; /// The possible actions that can be conveyed from the operating system diff --git a/lib/ui/text.dart b/lib/ui/text.dart index de0b3984a0690..e77f4a8156bf4 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; /// Whether to slant the glyphs in the font diff --git a/lib/ui/ui.dart b/lib/ui/ui.dart index 5b2844dd59e00..49b450c7ca908 100644 --- a/lib/ui/ui.dart +++ b/lib/ui/ui.dart @@ -10,16 +10,14 @@ /// to bootstrap applications, such as classes for driving the input, graphics /// text, layout, and rendering subsystems. -// ignore_for_file: import_internal_library, unused_import - library dart.ui; -import 'dart:_internal' hide Symbol; +import 'dart:_internal' hide Symbol; // ignore: import_internal_library, unused_import import 'dart:async'; import 'dart:collection' as collection; import 'dart:convert'; import 'dart:developer' as developer; -import 'dart:io'; +import 'dart:io'; // ignore: unused_import import 'dart:isolate' show SendPort; import 'dart:math' as math; import 'dart:nativewrappers'; diff --git a/lib/ui/window.dart b/lib/ui/window.dart index dc64198821a88..b9c8298c2c76c 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: native_function_body_in_non_sdk_code - part of dart.ui; /// Signature of callbacks that have no arguments and return no data. diff --git a/testing/dart/canvas_test.dart b/testing/dart/canvas_test.dart index a5095cd9baa3b..4a14a92da6624 100644 --- a/testing/dart/canvas_test.dart +++ b/testing/dart/canvas_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: empty_catches - import 'dart:typed_data'; import 'dart:ui'; @@ -14,7 +12,7 @@ typedef CanvasCallback = void Function(Canvas canvas); void testCanvas(CanvasCallback callback) { try { callback(Canvas(PictureRecorder(), Rect.fromLTRB(0.0, 0.0, 0.0, 0.0))); - } catch (error) { } + } catch (error) { } // ignore: empty_catches } void main() { @@ -33,17 +31,17 @@ void main() { final Picture picture = recorder.endRecording(); final Image image = picture.toImage(1, 1); - try { Canvas(null, null); } catch (error) { } - try { Canvas(null, rect); } catch (error) { } - try { Canvas(PictureRecorder(), null); } catch (error) { } - try { Canvas(PictureRecorder(), rect); } catch (error) { } + try { Canvas(null, null); } catch (error) { } // ignore: empty_catches + try { Canvas(null, rect); } catch (error) { } // ignore: empty_catches + try { Canvas(PictureRecorder(), null); } catch (error) { } // ignore: empty_catches + try { Canvas(PictureRecorder(), rect); } catch (error) { } // ignore: empty_catches try { PictureRecorder() ..endRecording() ..endRecording() ..endRecording(); - } catch (error) { } + } catch (error) { } // ignore: empty_catches testCanvas((Canvas canvas) => canvas.clipPath(path)); testCanvas((Canvas canvas) => canvas.clipRect(rect)); From 977ce3c32f9cd8105e9bb67514390b3cb8ced6e7 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 09:16:51 -0800 Subject: [PATCH 3/9] fix analyze.sh --- ci/analyze.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/analyze.sh b/ci/analyze.sh index 8d6e3bf18e96f..09bf3e12f3993 100755 --- a/ci/analyze.sh +++ b/ci/analyze.sh @@ -2,7 +2,10 @@ echo "Analyzing dart:ui library..." RESULTS=`dartanalyzer \ --options flutter/analysis_options.yaml \ - out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart` + out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \ + 2>&1 \ + | grep -Ev "No issues found!" \ + | grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"` echo "$RESULTS" if [ -n "$RESULTS" ]; then From 3cc6e7aa3b1488bfb7d9b1d96c8e20c33cfdd596 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 09:17:42 -0800 Subject: [PATCH 4/9] add missing files --- lib/ui/hooks.dart | 16 ++++++++++++++-- testing/dart/window_hooks_integration_test.dart | 8 +++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index 8cd7583d4537c..465e596ec4c25 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -2,20 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(dnfield): Remove this when https://github.com/dart-lang/sdk/issues/35164 is resolved. -// ignore_for_file: unused_element +// TODO(dnfield): Remove unused_import ignores when https://github.com/dart-lang/sdk/issues/35164 is resolved. part of dart.ui; +// ignore: unused_element String _decodeUTF8(ByteData message) { return message != null ? utf8.decoder.convert(message.buffer.asUint8List()) : null; } +// ignore: unused_element dynamic _decodeJSON(String message) { return message != null ? json.decode(message) : null; } @pragma('vm:entry-point') +// ignore: unused_element void _updateWindowMetrics(double devicePixelRatio, double width, double height, @@ -53,9 +55,11 @@ String _localeClosure() { } @pragma('vm:entry-point') +// ignore: unused_element _LocaleClosure _getLocaleClosure() => _localeClosure; @pragma('vm:entry-point') +// ignore: unused_element void _updateLocales(List locales) { const int stringsPerLocale = 4; final int numLocales = locales.length ~/ stringsPerLocale; @@ -74,6 +78,7 @@ void _updateLocales(List locales) { } @pragma('vm:entry-point') +// ignore: unused_element void _updateUserSettingsData(String jsonData) { final Map data = json.decode(jsonData); if (data.isEmpty) { @@ -93,12 +98,14 @@ void _updateAlwaysUse24HourFormat(bool alwaysUse24HourFormat) { } @pragma('vm:entry-point') +// ignore: unused_element void _updateSemanticsEnabled(bool enabled) { window._semanticsEnabled = enabled; _invoke(window.onSemanticsEnabledChanged, window._onSemanticsEnabledChangedZone); } @pragma('vm:entry-point') +// ignore: unused_element void _updateAccessibilityFeatures(int values) { final AccessibilityFeatures newFeatures = new AccessibilityFeatures._(values); if (newFeatures == window._accessibilityFeatures) @@ -125,12 +132,14 @@ void _dispatchPlatformMessage(String name, ByteData data, int responseId) { } @pragma('vm:entry-point') +// ignore: unused_element void _dispatchPointerDataPacket(ByteData packet) { if (window.onPointerDataPacket != null) _invoke1(window.onPointerDataPacket, window._onPointerDataPacketZone, _unpackPointerDataPacket(packet)); } @pragma('vm:entry-point') +// ignore: unused_element void _dispatchSemanticsAction(int id, int action, ByteData args) { _invoke3( window.onSemanticsAction, @@ -142,11 +151,13 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) { } @pragma('vm:entry-point') +// ignore: unused_element void _beginFrame(int microseconds) { _invoke1(window.onBeginFrame, window._onBeginFrameZone, new Duration(microseconds: microseconds)); } @pragma('vm:entry-point') +// ignore: unused_element void _drawFrame() { _invoke(window.onDrawFrame, window._onDrawFrameZone); } @@ -180,6 +191,7 @@ void _invoke1(void callback(A a), Zone zone, A arg) { } /// Invokes [callback] inside the given [zone] passing it [arg1] and [arg2]. +// ignore: unused_element void _invoke2(void callback(A1 a1, A2 a2), Zone zone, A1 arg1, A2 arg2) { if (callback == null) return; diff --git a/testing/dart/window_hooks_integration_test.dart b/testing/dart/window_hooks_integration_test.dart index 446f5ac8ab6a5..fe3e27c305e19 100644 --- a/testing/dart/window_hooks_integration_test.dart +++ b/testing/dart/window_hooks_integration_test.dart @@ -6,15 +6,13 @@ library dart.ui; import 'dart:async'; -import 'dart:io'; -import 'dart:typed_data'; +// this needs to be imported because painting.dart expects it this way +import 'dart:collection' as collection; import 'dart:convert'; import 'dart:developer' as developer; import 'dart:math' as math; -import 'dart:nativewrappers'; +import 'dart:typed_data'; -// this needs to be imported because painting.dart expects it this way -import 'dart:collection' as collection; import 'package:test/test.dart'; From 68b95c63373bb96b10b290ce34efae43e368ab86 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 09:23:42 -0800 Subject: [PATCH 5/9] move failure test to its own pubspec --- testing/run_tests.sh | 2 +- testing/{ => smoke_test_failure}/fail_test.dart | 3 --- testing/smoke_test_failure/pubspec.yaml | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) rename testing/{ => smoke_test_failure}/fail_test.dart (69%) create mode 100644 testing/smoke_test_failure/pubspec.yaml diff --git a/testing/run_tests.sh b/testing/run_tests.sh index 38fcaf7ba6ee0..85968fa9ff454 100755 --- a/testing/run_tests.sh +++ b/testing/run_tests.sh @@ -21,7 +21,7 @@ run_test () { } # Verify that a failing test returns a failure code. -! run_test flutter/testing/fail_test.dart +! run_test flutter/testing/smoke_test_failure/fail_test.dart for TEST_SCRIPT in flutter/testing/dart/*.dart; do run_test $TEST_SCRIPT diff --git a/testing/fail_test.dart b/testing/smoke_test_failure/fail_test.dart similarity index 69% rename from testing/fail_test.dart rename to testing/smoke_test_failure/fail_test.dart index 561b7f2cc924b..5d88caaaa5d47 100644 --- a/testing/fail_test.dart +++ b/testing/smoke_test_failure/fail_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(dnfield): move this to somewhere with a pubspec -// ignore_for_file: uri_does_not_exist,undefined_function,undefined_identifier - import 'package:test/test.dart'; void main() { diff --git a/testing/smoke_test_failure/pubspec.yaml b/testing/smoke_test_failure/pubspec.yaml new file mode 100644 index 0000000000000..9eb330ef6f4e7 --- /dev/null +++ b/testing/smoke_test_failure/pubspec.yaml @@ -0,0 +1,4 @@ +name: smoke_test_failure +dependencies: + test: 1.3.0 + path: 1.6.2 From 297d830290b5a7285d0673d53b08cc47291bd304 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 10:03:49 -0800 Subject: [PATCH 6/9] add missing import for window hooks --- testing/dart/window_hooks_integration_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/dart/window_hooks_integration_test.dart b/testing/dart/window_hooks_integration_test.dart index fe3e27c305e19..a7a8b81a9a1ad 100644 --- a/testing/dart/window_hooks_integration_test.dart +++ b/testing/dart/window_hooks_integration_test.dart @@ -11,6 +11,7 @@ import 'dart:collection' as collection; import 'dart:convert'; import 'dart:developer' as developer; import 'dart:math' as math; +import 'dart:nativewrappers'; // ignore: unused_import import 'dart:typed_data'; From 06a752253ab63c1e43a01ea573e720453fce96f6 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 14:36:01 -0800 Subject: [PATCH 7/9] add back ignore --- lib/ui/natives.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index a576025ad7145..7e2ef42713e93 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -74,4 +74,4 @@ int _isolateId; // ignore: unused_element @pragma('vm:entry-point') Function _getPrintClosure() => _print; // ignore: unused_element @pragma('vm:entry-point') -Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; +Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; // ignore: unused_element From 0fd421ea0997d239b2bdc9cd5a7e41739959f851 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Jan 2019 15:06:05 -0800 Subject: [PATCH 8/9] remove unnecessary ignores --- lib/ui/compositing.dart | 52 ++++++++++++++++----------------- lib/ui/isolate_name_server.dart | 6 ++-- lib/ui/natives.dart | 10 +++---- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index 3cc9d3947a2ed..df79b0db86ce3 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -30,12 +30,12 @@ class Scene extends NativeFieldWrapperClass2 { ); } - String _toImage(int width, int height, _Callback callback) native 'Scene_toImage'; // ignore: native_function_body_in_non_sdk_code + String _toImage(int width, int height, _Callback callback) native 'Scene_toImage'; /// Releases the resources used by this scene. /// /// After calling this function, the scene is cannot be used further. - void dispose() native 'Scene_dispose'; // ignore: native_function_body_in_non_sdk_code + void dispose() native 'Scene_dispose'; } /// Builds a [Scene] containing the given visuals. @@ -49,7 +49,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// Creates an empty [SceneBuilder] object. @pragma('vm:entry-point') SceneBuilder() { _constructor(); } - void _constructor() native 'SceneBuilder_constructor'; // ignore: native_function_body_in_non_sdk_code + void _constructor() native 'SceneBuilder_constructor'; /// Pushes a transform operation onto the operation stack. /// @@ -63,14 +63,14 @@ class SceneBuilder extends NativeFieldWrapperClass2 { throw new ArgumentError('"matrix4" must have 16 entries.'); return _pushTransform(matrix4); } - EngineLayer _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform'; // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform'; /// Pushes an offset operation onto the operation stack. /// /// This is equivalent to [pushTransform] with a matrix with only translation. /// /// See [pop] for details about the operation stack. - EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset'; // ignore: native_function_body_in_non_sdk_code + EngineLayer pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset'; /// Pushes a rectangular clip operation onto the operation stack. /// @@ -87,7 +87,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double right, double top, double bottom, - int clipBehavior) native 'SceneBuilder_pushClipRect'; // ignore: native_function_body_in_non_sdk_code + int clipBehavior) native 'SceneBuilder_pushClipRect'; /// Pushes a rounded-rectangular clip operation onto the operation stack. /// @@ -100,7 +100,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(clipBehavior != Clip.none); return _pushClipRRect(rrect._value, clipBehavior.index); } - EngineLayer _pushClipRRect(Float32List rrect, int clipBehavior) native 'SceneBuilder_pushClipRRect'; // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushClipRRect(Float32List rrect, int clipBehavior) native 'SceneBuilder_pushClipRRect'; /// Pushes a path clip operation onto the operation stack. /// @@ -113,7 +113,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(clipBehavior != Clip.none); return _pushClipPath(path, clipBehavior.index); } - EngineLayer _pushClipPath(Path path, int clipBehavior) native 'SceneBuilder_pushClipPath'; // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushClipPath(Path path, int clipBehavior) native 'SceneBuilder_pushClipPath'; /// Pushes an opacity operation onto the operation stack. /// @@ -126,7 +126,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushOpacity(int alpha, {Offset offset = Offset.zero}) { return _pushOpacity(alpha, offset.dx, offset.dy); } - EngineLayer _pushOpacity(int alpha, double dx, double dy) native 'SceneBuilder_pushOpacity'; // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushOpacity(int alpha, double dx, double dy) native 'SceneBuilder_pushOpacity'; /// Pushes a color filter operation onto the operation stack. /// @@ -137,7 +137,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushColorFilter(Color color, BlendMode blendMode) { return _pushColorFilter(color.value, blendMode.index); } - EngineLayer _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; /// Pushes a backdrop filter operation onto the operation stack. /// @@ -145,7 +145,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// rasterizing the given objects. /// /// See [pop] for details about the operation stack. - EngineLayer pushBackdropFilter(ImageFilter filter) native 'SceneBuilder_pushBackdropFilter'; // ignore: native_function_body_in_non_sdk_code + EngineLayer pushBackdropFilter(ImageFilter filter) native 'SceneBuilder_pushBackdropFilter'; /// Pushes a shader mask operation onto the operation stack. /// @@ -166,7 +166,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double maskRectRight, double maskRectTop, double maskRectBottom, - int blendMode) native 'SceneBuilder_pushShaderMask'; // ignore: native_function_body_in_non_sdk_code + int blendMode) native 'SceneBuilder_pushShaderMask'; /// Pushes a physical layer operation for an arbitrary shape onto the /// operation stack. @@ -184,7 +184,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { EngineLayer pushPhysicalShape({ Path path, double elevation, Color color, Color shadowColor, Clip clipBehavior = defaultClipBehavior}) { return _pushPhysicalShape(path, elevation, color.value, shadowColor?.value ?? 0xFF000000, clipBehavior.index); } - EngineLayer _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native // ignore: native_function_body_in_non_sdk_code + EngineLayer _pushPhysicalShape(Path path, double elevation, int color, int shadowColor, int clipBehavior) native 'SceneBuilder_pushPhysicalShape'; /// Ends the effect of the most recently pushed operation. @@ -193,7 +193,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// operations in the stack applies to each of the objects added to the scene. /// Calling this function removes the most recently added operation from the /// stack. - void pop() native 'SceneBuilder_pop'; // ignore: native_function_body_in_non_sdk_code + void pop() native 'SceneBuilder_pop'; /// Add a retained engine layer subtree from previous frames. /// @@ -203,7 +203,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// Therefore, when implementing a subclass of the [Layer] concept defined in /// the rendering layer of Flutter's framework, once this is called, there's /// no need to call [addToScene] for its children layers. - EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained'; // ignore: native_function_body_in_non_sdk_code + EngineLayer addRetained(EngineLayer retainedLayer) native 'SceneBuilder_addRetained'; /// Adds an object to the scene that displays performance statistics. /// @@ -240,7 +240,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double left, double right, double top, - double bottom) native 'SceneBuilder_addPerformanceOverlay'; // ignore: native_function_body_in_non_sdk_code + double bottom) native 'SceneBuilder_addPerformanceOverlay'; /// Adds a [Picture] to the scene. /// @@ -253,7 +253,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { hints |= 2; _addPicture(offset.dx, offset.dy, picture, hints); } - void _addPicture(double dx, double dy, Picture picture, int hints) native 'SceneBuilder_addPicture'; // ignore: native_function_body_in_non_sdk_code + void _addPicture(double dx, double dy, Picture picture, int hints) native 'SceneBuilder_addPicture'; /// Adds a backend texture to the scene. /// @@ -270,7 +270,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(offset != null, 'Offset argument was null'); _addTexture(offset.dx, offset.dy, width, height, textureId, freeze); } - void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze) native 'SceneBuilder_addTexture'; // ignore: native_function_body_in_non_sdk_code + void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze) native 'SceneBuilder_addTexture'; /// Adds a platform view (e.g an iOS UIView) to the scene. /// @@ -292,7 +292,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(offset != null, 'Offset argument was null'); _addPlatformView(offset.dx, offset.dy, width, height, viewId); } - void _addPlatformView(double dx, double dy, double width, double height, int viewId) native 'SceneBuilder_addPlatformView'; // ignore: native_function_body_in_non_sdk_code + void _addPlatformView(double dx, double dy, double width, double height, int viewId) native 'SceneBuilder_addPlatformView'; /// (Fuchsia-only) Adds a scene rendered by another application to the scene /// for this application. @@ -315,7 +315,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double width, double height, SceneHost sceneHost, - bool hitTestable) native 'SceneBuilder_addChildScene'; // ignore: native_function_body_in_non_sdk_code + bool hitTestable) native 'SceneBuilder_addChildScene'; /// Sets a threshold after which additional debugging information should be recorded. /// @@ -323,7 +323,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). /// We'll hopefully be able to figure out how to make this feature more useful /// to you. - void setRasterizerTracingThreshold(int frameInterval) native 'SceneBuilder_setRasterizerTracingThreshold'; // ignore: native_function_body_in_non_sdk_code + void setRasterizerTracingThreshold(int frameInterval) native 'SceneBuilder_setRasterizerTracingThreshold'; /// Sets whether the raster cache should checkerboard cached entries. This is /// only useful for debugging purposes. @@ -340,13 +340,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// Currently this interface is difficult to use by end-developers. If you're /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). - void setCheckerboardRasterCacheImages(bool checkerboard) native 'SceneBuilder_setCheckerboardRasterCacheImages'; // ignore: native_function_body_in_non_sdk_code + void setCheckerboardRasterCacheImages(bool checkerboard) native 'SceneBuilder_setCheckerboardRasterCacheImages'; /// Sets whether the compositor should checkerboard layers that are rendered /// to offscreen bitmaps. /// /// This is only useful for debugging purposes. - void setCheckerboardOffscreenLayers(bool checkerboard) native 'SceneBuilder_setCheckerboardOffscreenLayers'; // ignore: native_function_body_in_non_sdk_code + void setCheckerboardOffscreenLayers(bool checkerboard) native 'SceneBuilder_setCheckerboardOffscreenLayers'; /// Finishes building the scene. /// @@ -356,7 +356,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// After calling this function, the scene builder object is invalid and /// cannot be used further. - Scene build() native 'SceneBuilder_build'; // ignore: native_function_body_in_non_sdk_code + Scene build() native 'SceneBuilder_build'; } /// (Fuchsia-only) Hosts content provided by another application. @@ -376,10 +376,10 @@ class SceneHost extends NativeFieldWrapperClass2 { SceneHost(dynamic exportTokenHandle) { _constructor(exportTokenHandle); } - void _constructor(dynamic exportTokenHandle) native 'SceneHost_constructor'; // ignore: native_function_body_in_non_sdk_code + void _constructor(dynamic exportTokenHandle) native 'SceneHost_constructor'; /// Releases the resources associated with the child scene host. /// /// After calling this function, the child scene host cannot be used further. - void dispose() native 'SceneHost_dispose'; // ignore: native_function_body_in_non_sdk_code + void dispose() native 'SceneHost_dispose'; } diff --git a/lib/ui/isolate_name_server.dart b/lib/ui/isolate_name_server.dart index 04784026f4756..4c1833bc52646 100644 --- a/lib/ui/isolate_name_server.dart +++ b/lib/ui/isolate_name_server.dart @@ -35,9 +35,9 @@ abstract class IsolateNameServer { } static SendPort _lookupPortByName(String name) - native 'IsolateNameServerNatives_LookupPortByName'; // ignore: native_function_body_in_non_sdk_code + native 'IsolateNameServerNatives_LookupPortByName'; static bool _registerPortWithName(SendPort port, String name) - native 'IsolateNameServerNatives_RegisterPortWithName'; // ignore: native_function_body_in_non_sdk_code + native 'IsolateNameServerNatives_RegisterPortWithName'; static bool _removePortNameMapping(String name) - native 'IsolateNameServerNatives_RemovePortNameMapping'; // ignore: native_function_body_in_non_sdk_code + native 'IsolateNameServerNatives_RemovePortNameMapping'; } diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index 7e2ef42713e93..1e9a0798f96f6 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -12,7 +12,7 @@ void _print(dynamic arg) { } class _Logger { - static void _printString(String s) native 'Logger_PrintString'; // ignore: native_function_body_in_non_sdk_code + static void _printString(String s) native 'Logger_PrintString'; } // A service protocol extension to schedule a frame to be rendered into the @@ -61,12 +61,12 @@ List saveCompilationTrace() { return result; } -dynamic _saveCompilationTrace() native 'SaveCompilationTrace'; // ignore: native_function_body_in_non_sdk_code +dynamic _saveCompilationTrace() native 'SaveCompilationTrace'; -void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask'; // ignore: native_function_body_in_non_sdk_code +void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask'; -int _getCallbackHandle(Function closure) native 'GetCallbackHandle'; // ignore: native_function_body_in_non_sdk_code -Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle'; // ignore: native_function_body_in_non_sdk_code +int _getCallbackHandle(Function closure) native 'GetCallbackHandle'; +Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle'; // Required for gen_snapshot to work correctly. int _isolateId; // ignore: unused_element From fa1b3a9b57e77d5061705f60a00c83a16a94a380 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 11 Jan 2019 12:41:57 -0800 Subject: [PATCH 9/9] remove blank line --- lib/ui/ui.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ui/ui.dart b/lib/ui/ui.dart index 49b450c7ca908..cef4db81cee0e 100644 --- a/lib/ui/ui.dart +++ b/lib/ui/ui.dart @@ -9,7 +9,6 @@ /// This library exposes the lowest-level services that Flutter frameworks use /// to bootstrap applications, such as classes for driving the input, graphics /// text, layout, and rendering subsystems. - library dart.ui; import 'dart:_internal' hide Symbol; // ignore: import_internal_library, unused_import