Skip to content

Commit

Permalink
Enable analysis for all of dart:ui (flutter#34988)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored Jul 29, 2022
1 parent 5080fd6 commit 818baca
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ analyzer:
import_internal_library: ignore
# Turned off until null-safe rollout is complete.
unnecessary_null_comparison: ignore
# TODO(goderbauer): remove when https://github.com/dart-lang/sdk/issues/49563 is fixed.
ffi_native_unexpected_number_of_parameters: ignore

linter:
rules:
Expand Down
4 changes: 1 addition & 3 deletions ci/analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function follow_links() (
SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
FLUTTER_DIR="$SRC_DIR/flutter"
SKY_ENGINE_DIR="$SRC_DIR/out/host_debug_unopt/gen/dart-pkg/sky_engine"
DART_BIN="$SRC_DIR/out/host_debug_unopt/dart-sdk/bin"
DART="$DART_BIN/dart"

Expand All @@ -47,8 +46,7 @@ echo "Using dart from $DART_BIN"
"$DART" --version
echo ""

(cd $SKY_ENGINE_DIR && "$DART" pub get --offline)
"$DART" analyze "$SKY_ENGINE_DIR/lib/ui/ui.dart"
"$DART" analyze "$FLUTTER_DIR/lib/ui"

"$DART" analyze "$FLUTTER_DIR/lib/spirv"

Expand Down
4 changes: 2 additions & 2 deletions lib/ui/geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1720,13 +1720,13 @@ class RSTransform {
/// The `translateX` and `translateY` parameters give the coordinate of the
/// offset by which to translate.
///
/// This constructor computes the arguments of the [new RSTransform]
/// This constructor computes the arguments of the [RSTransform.new]
/// constructor and then defers to that constructor to actually create the
/// object. If many [RSTransform] objects are being created and there is a way
/// to factor out the computations of the sine and cosine of the rotation
/// (which are computed each time this constructor is called) and reuse them
/// over multiple [RSTransform] objects, it may be more efficient to directly
/// use the more direct [new RSTransform] constructor instead.
/// use the more direct [RSTransform.new] constructor instead.
factory RSTransform.fromComponents({
required double rotation,
required double scale,
Expand Down
25 changes: 8 additions & 17 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3522,7 +3522,7 @@ class _ErodeImageFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(radiusX, radiusY);
int get hashCode => Object.hash(radiusX, radiusY);
}

class _ComposeImageFilter implements ImageFilter {
Expand Down Expand Up @@ -4042,7 +4042,7 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
/// compiler. The constructed object should then be reused via the [shader]
/// method to create [Shader] objects that can be used by [Shader.paint].
static Future<FragmentProgram> fromAsset(String assetKey) {
FragmentProgram? program = _shaderRegistry[assetKey]?.target;
final FragmentProgram? program = _shaderRegistry[assetKey]?.target;
if (program != null) {
return Future<FragmentProgram>.value(program);
}
Expand All @@ -4061,13 +4061,6 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
static Map<String, WeakReference<FragmentProgram>> _shaderRegistry =
<String, WeakReference<FragmentProgram>>{};

FragmentProgram._() {
assert(
false,
'FragmentProgram should only be initialized via "fromAsset".',
);
}

@pragma('vm:entry-point')
FragmentProgram._fromAsset(String assetKey) {
_constructor();
Expand All @@ -4093,7 +4086,7 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
return;
}

final result = program._initFromAsset(assetKey);
final String result = program._initFromAsset(assetKey);
if (result.isNotEmpty) {
throw result;
}
Expand Down Expand Up @@ -4164,9 +4157,7 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
Float32List? floatUniforms,
List<ImageShader>? samplerUniforms,
}) {
if (floatUniforms == null) {
floatUniforms = Float32List(_uniformFloatCount);
}
floatUniforms ??= Float32List(_uniformFloatCount);
if (floatUniforms.length != _uniformFloatCount) {
throw ArgumentError(
'floatUniforms size: ${floatUniforms.length} must match given shader '
Expand Down Expand Up @@ -4291,7 +4282,7 @@ class Vertices extends NativeFieldWrapperClass1 {
}

/// Creates a set of vertex data for use with [Canvas.drawVertices], directly
/// using the encoding methods of [new Vertices].
/// using the encoding methods of [Vertices.new].
/// Note that this constructor uses raw typed data lists,
/// so it runs faster than the [Vertices()] constructor
/// because it doesn't require any conversion from Dart lists.
Expand Down Expand Up @@ -5057,8 +5048,8 @@ class Canvas extends NativeFieldWrapperClass1 {
/// first.
///
/// To align the text, set the `textAlign` on the [ParagraphStyle] object
/// passed to the [new ParagraphBuilder] constructor. For more details see
/// [TextAlign] and the discussion at [new ParagraphStyle].
/// passed to the [ParagraphBuilder.new] constructor. For more details see
/// [TextAlign] and the discussion at [ParagraphStyle.new].
///
/// If the text is left aligned or justified, the left margin will be at the
/// position specified by the `offset` argument's [Offset.dx] coordinate.
Expand Down Expand Up @@ -5129,7 +5120,7 @@ class Canvas extends NativeFieldWrapperClass1 {
/// All parameters must not be null.
///
/// See also:
/// * [new Vertices], which creates a set of vertices to draw on the canvas.
/// * [Vertices.new], which creates a set of vertices to draw on the canvas.
/// * [Vertices.raw], which creates the vertices using typed data lists
/// rather than unencoded lists.
/// * [paint], Image shaders can be used to draw images on a triangular mesh.
Expand Down
7 changes: 4 additions & 3 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ class ParagraphConstraints {
/// follows).
///
/// The width influences how ellipses are applied. See the discussion at
/// [new ParagraphStyle] for more details.
/// [ParagraphStyle.new] for more details.
///
/// This width is also used to position glyphs according to the [TextAlign]
/// alignment described in the [ParagraphStyle] used when building the
Expand Down Expand Up @@ -2717,7 +2717,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
/// constraint.
///
/// See the discussion of the `maxLines` and `ellipsis` arguments at
/// [new ParagraphStyle].
/// [ParagraphStyle.new].
@FfiNative<Bool Function(Pointer<Void>)>('Paragraph::didExceedMaxLines', isLeaf: true)
external bool get didExceedMaxLines;

Expand Down Expand Up @@ -2886,7 +2886,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
///
/// To set the paragraph's alignment, truncation, and ellipsizing behavior, pass
/// an appropriately-configured [ParagraphStyle] object to the
/// [new ParagraphBuilder] constructor.
/// [ParagraphBuilder.new] constructor.
///
/// Then, call combinations of [pushStyle], [addText], and [pop] to add styled
/// text to the object.
Expand Down Expand Up @@ -3164,6 +3164,7 @@ Future<void> loadFontFromList(Uint8List list, {String? fontFamily}) {
return _futurize(
(_Callback<void> callback) {
_loadFontFromList(list, callback, fontFamily ?? '');
return null;
}
).then((_) => _sendFontChangeMessage());
}
Expand Down

0 comments on commit 818baca

Please sign in to comment.