Commit Graph

97 Commits

Author SHA1 Message Date
Sam Rawlins f46967d5c4 analyzer_testing: Fix some flutter mocks
Fixes https://github.com/dart-lang/sdk/issues/62559

Change-Id: I3866dd488132faf9946ca36fc32f38aa335cce3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-22 08:32:49 -07:00
Konstantin Shcheglov da7f207611 CQ. Update resolveTestCodeWithDiagnostics() to use removeDiagnosticExpectations().
Just as parser tests do.
So, there is no interference with extra lines.

Change-Id: I1d49d6d10c69fddc6b0632eeae10ed522c0cda57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505483
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-21 13:14:17 -07:00
Konstantin Shcheglov 3009984866 CQ. Replace many parseStringWithErrors() with parseTestCodeWithDiagnostics().
Change-Id: Id992c63a83bbb8eb2f2539f8735b72ee1c3a2e39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-20 09:34:54 -07:00
Konstantin Shcheglov 5723f42f69 CQ. Trim diagnostic messages in expectations.
See
https://dart-review.googlesource.com/c/sdk/+/501764/comment/6a88eca8_ab5cf6e4/

Change-Id: Ic7752669660b88003460167f9d9e3926e0d19c3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503541
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-14 09:40:43 -07:00
Konstantin Shcheglov 8e49049836 CQ. Convert file paths in expected diagnostics to POSIX.
Change-Id: Ie11519f8e62448b630ddf9a265fa601ecd988216
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503122
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-13 09:24:01 -07:00
Konstantin Shcheglov 1aa7d7321f CQ. Use in-code diagnostic expectations.
Add support for keeping parser diagnostic expectations in the source
snippets they describe. Expectations are written as caret markers and
diagnostic comments, and regenerated from the parser's actual
diagnostics before comparison.

This keeps parser recovery expectations close to the code under test and
removes the need to maintain offset-based `assertErrors` lists by hand.
The updater also removes existing expectation markers before writing the
canonical form, so marked snippets can be refreshed in place.

Migrate recovery parser and class parser tests to the new
`assertExpectedDiagnostics` helper, including no-error cases where an
unmarked snippet is the expected canonical form.

Update `test_runner` to exclude `/pkg/analyzer/` from searching static
error expectations.

Bug: https://github.com/dart-lang/sdk/issues/63335
Change-Id: Ic9866da8cc601c6b360552ba576e8aa1646f89a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-05-07 15:30:45 -07:00
Kallen Tu 8bfb683892 Enable 'primary-constructors' feature flag.
This CL enables the primary constructors feature by default in Dart 3.13.

The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.

This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.

Currently a declaration with a constructor and some fields is written as:

```dart
// Current syntax.
class Point {
  int x;
  int y;
  Point(this.x, this.y);
}
```

With a primary constructor, we would write the above as:

```
class Point(var int x, var int y);
```

If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:

```dart
class Point(var int x, var int y) {
  this : assert(x >= 0) {
    print('Point created at $x, $y');
  }
}
```

As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
  int x, y;

  // Equivalent to Point(this.x, this.y)
  new(this.x, this.y);

  // Equivalent to Point.origin()
  new origin() : x = 0, y = 0;

  // Equivalent to factory Point.clone(Point other)
  factory clone(Point other) => Point(other.x, other.y);
}
```

To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md

Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-04 15:09:49 -07:00
Konstantin Shcheglov 70577807bd CQ. Use actual, not mock results in analyzer_cli reporter tests.
Change-Id: I050289421791b3b2be56f82fc5ebab6bb048a500
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499423
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 08:23:17 -07:00
Konstantin Shcheglov e20704c3b0 CQ. Move PackageConfigFileBuilder to analyzer_testing.
Move PackageConfigFileBuilder into the analyzer_testing public API and
deprecate the copy exposed from package:analyzer. The builder is only
used by test infrastructure, so keeping it in analyzer_testing makes the
ownership clearer and avoids exposing test-only utilities from analyzer.

Update the builder API to accept a rootFolder instead of a rootPath.
This lets callers pass the resource-provider folder directly, so the
generated rootUri is derived from the same file-system abstraction that
created the test files. This avoids accidentally passing POSIX paths
where resource provider paths are required, such as on Windows.

Update existing test utilities and callers to import the new library and
pass Folder objects. Remove the production analysis server dependency on
the builder by emitting the temporary plugin package config JSON
directly.

Change-Id: I46b14710626e0d6d5884afcdc5a05b23077acfc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499081
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-29 13:18:35 -07:00
Fedor Shcheglov fe0bdac54f Fix a bug where augmentation was incorrectly associated with the macro feature, rather than the augmentations feature.
Added additional tests to ensure validity of this change.

This didn't cause issues in unit tests, because all of them had macros
enabled in their superclasses.

Add TODO for named mixin applications: mixin application classes can't
be augmented.
(https://github.com/dart-lang/language/blob/main/working/augmentations/feature-specification.md#augmenting-class-like-declarations)

Change-Id: Ieaaec84d16ca8cf6d103c9c905fdfa2c0b7c8ca1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-23 07:26:18 -07:00
Ben Konyi 2a83a78213 [ DAS ] Add initial support for widget preview detection service
The Flutter Widget Preview feature is currently implemented within
Flutter Tools, which is responsible for detecting widget preview
annotations in the user's project. When previews are detected, the
Flutter Tool injects code generated based on the detected previews into an artificial widget_preview_scaffold project and performs a hot reload to render updates to the preview set in the scaffold application.

`package:analyzer` is currently being used to detect previews, but this comes with a significant amount of memory overhead. Since widget
previews are mostly being used from within IDEs which already have an
active analysis server, moving widget preview detection into the DAS
will remove the need for creating an additional analysis context in the Flutter Tool itself.

This change includes the initial work to move widget preview detection
into the DAS. It utilizes a pull-based mechanism, where the Flutter Tool listens for file system events and then queries the DAS using the `dart/textDocument/getFlutterWidgetPreviews` and `dart/workspace/getFlutterWidgetPreviews` LSP methods.

Each reported preview contains some generated code based on the annotation used to define the preview. This code has all constants from the original annotation evaluated to either primitive values or constant expressions with namespaces applied to each symbol, allowing for the Flutter Tool to inject this code directly when updating the generated code in the scaffold project.

Towards https://github.com/flutter/flutter/issues/179584

Change-Id: I043cb3235a66b25dda3f852ca7f147bff0e1e537
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478100
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-22 19:19:03 -07:00
Paul Berry 016ea28ede [api_summary] Add unit tests.
These tests cover all the functionality of the API summary tool.

Note that since the `ApiDescription` constructor requires an
`AnalysisContext`, I added a public `contextCollection` getter to the
`PubPackageResolutionTest` base class.

There are a few loose ends I intend to address in follow-up CLs. They
have been noted in TODO comments:

- Annotate when classes are `abstract`, `final`, or `interface`.

- Move `pub_package_resolution.dart` out of
  `package:analyzer_testing/src` (so that when I publish this as a
  separate package, that package won't be dependent on private
  implementation details of `package:analyzer_testing`).

Change-Id: I6a6a69643064115997f6586ff5161ddf4c9f96ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-20 10:41:40 -08:00
Paul Berry e2c31151a5 [analyzer_testing] Sort declarations in pub_package_resolution.dart.
Change-Id: I6a6a69649bba8bebde0d8b89df08660fefd1555f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482121
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-19 18:40:21 -08:00
Robert Nystrom c82716b216 Enable "private-named-parameters" experiment flag.
TEST=many language, co19, and other tests

Bug: https://github.com/dart-lang/sdk/issues/61629
Change-Id: I24d761cc2dc3fa2707a2486a39bfde1b8e847b1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480384
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2026-02-18 15:26:18 -08:00
TejasSojitra12 fb04feed13 [analyzer_testing] Add missing Flutter mock types
Adds MediaQuery, RichText, Wrap, and Sliver classes to the Flutter package mock.

Fixes #62559

Change-Id: If2f41fba8a12bdaf3d1a14eadb516eb13cc2d609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477620
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-18 10:03:59 -08:00
Paul Berry 2b5e655c34 [messages] Fix test failure output.
Changes the test logic in `analysis_server` and `analyzer_testing` so
that after printing `To accept the current state, expect:`, it prints
diagnostic codes in their proper camelCase format.

Also removes some bogus code from
`pkg/analyzer_testing/lib/analysis_rule/analysis_rule.dart` that
erroneously suggested passing a `name:` parameter to the top level
`error` function. This function does not accept any parameter called
`name`.

Previously, only tests in `pkg/analyzer/test` printed the diagnostic
codes correctly.

Fixes https://github.com/dart-lang/sdk/issues/62651.

Change-Id: I6a6a6964b17cf798c1355e09f9a4633e1fbe388c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480041
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-12 10:15:31 -08:00
Paul Berry 599f4bf94e [messages] Move string extensions into analyzer_testing.
These extensions were previously in `pkg/analyzer_utilities`, which is
not published on `pub`. That meant they could not be used from within
the `lib` directory of any package that *is* published on
`pub`. Specifically, they could not be used from within
`pkg/analyzer_testing/lib`.

In a follow-up CL, I will modify the testing logic so that after
printing `To accept the current state, expect:`, it prints diagnostic
codes in their proper camelCase format.

Change-Id: I6a6a696432d7162906b2c235ea88310dc0aa1fa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480040
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-12 10:12:02 -08:00
Sam Rawlins 39f8aa4ba8 analyzer_testing: Remove old mock APIs and old mock sources
Change-Id: If0f40090eb689438598f092877f72525a9ba7325
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477764
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-03 08:18:19 -08:00
Sam Rawlins 1c87e41254 analyzer_testing: Flip to new flutter mock sources
Fixes https://github.com/dart-lang/sdk/issues/61597

* Remove the old caching mechanism for the old way of sourcing files.
* Remove BlazeMockPackages._addFiles, and rename _addFiles2 to
  _addFiles.

A few trailing fixing included:

* Flex.new has a required direction parameter.
* TextOverflow comes from
  'package:flutter/src/painting/text_painter.dart'.
* A few stray imports needed to resolve types.
* DiagnosticableTree.debugDescribeChildren is marked external so
  that subclasses need not implement it themselves.
* In sort_child_properties_last, RawMaterialButton is in the material
  library.

Change-Id: I092bad587ea39bceb7af0951eada3963b1eb48bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473542
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-29 08:59:08 -08:00
Sam Rawlins dfdb1f9f72 analyzer_testing: Add imports to resolve more types in mock flutter; add missing components
Work towards https://github.com/dart-lang/sdk/issues/61597

Change-Id: I40c323f118bb7e9cf2394a5146ba4147098bce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476151
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-29 06:18:50 -08:00
Sam Rawlins ae41760d93 analyzer_testing: Add many imports and some elements to flutter mocks;
Work towards https://github.com/dart-lang/sdk/issues/61597

* DiagnosticsTreeStyle is used just below in DiagnosticsProperty.
* BoxConstraints is used in the `flutter_completion_benchmark`.
* Constraints is the superclass of BoxConstraints.
* The vector_math export is so that a few tests have access to the
  Matrix4 class.
* FutureBuilder and StreamBuilder are needed for the
  flutter_wrap_builder correction producer.

All of these changes bring the mocks/stubs closer to the real sources
(none are a divergence).


Change-Id: I80d746db3372417d7125aa1f3c2b0604a143f43b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476144
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-28 12:58:49 -08:00
Sam Rawlins be20f9421c analyzer_testing: prepare for abstract State.build method
Work towards https://github.com/dart-lang/sdk/issues/61597

State.build is abstract in the real flutter sources; making our stub
version of State the same allows it to be generated, and requires us
to make our tests more "real world."

Change-Id: Iff4c6e701402a83635575f3b980bf6d60b64b6d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475860
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-27 15:59:53 -08:00
Sam Rawlins d898aca90c analyzer_testing: Remove ClipRect.rect
Work towards https://github.com/dart-lang/sdk/issues/61597

Change-Id: Ib44d8a813d9a59cf7ebf2eb901140b2e9482b156
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-27 10:52:20 -08:00
Sam Rawlins 7e5885e78a analyzer: Allow awaitNotRequired on a Future-returning typedef
This includes bumping meta to 1.18.1.

To support https://github.com/flutter/flutter/issues/168555

Change-Id: I6830a413efcf9939467e97faf58b1255d2d3d8eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-26 18:14:50 -08:00
Sam Rawlins 46a8211c92 analyzer_testing: Add many missing stub members to flutter stubs
Work towards https://github.com/dart-lang/sdk/issues/61597

* I found many members of dart:ui were missing, needed generally by
  various tests, or members of package:flutter/painting.dart.
* Rename 'package:ui/ui.dart' to 'dart:ui' in a few places.
* `BoxDecoration.color` is nullable.
* `BoxDecoration.backgroundBlendMode` is a `BlendMode?`.
* Add the inherited_theme.dart library, with InheritedTheme, needed by
  other text widget classes.
* Add MultiChildRenderObjectWidget as a missing parent class.
* Add concrete implementations to many `State` members. In the real
  State class, these are concrete, and we have tests with concrete
  subclasses of State, without overrides of these members. So the State
  members themselves must be concrete.
* Add new classes: ParentData, ProxyWidget, InheritedWidget,
  ParentDataWidget.
* In widgets/text.dart, import dart:ui as ui, and fix many type
  signatures. The real widgets/text.dart has this import prefix, and it
  makes some signatures more understandable.
* Add some doc comments to various Text members, for the
  widget_descriptions code; we have tests that use these doc comments.

Change-Id: I1e38918b4e5381a56ce29440e1181d76e9d56f4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475702
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-26 14:18:54 -08:00
Sam Rawlins 97826545ea analyzer_testing: export Size from painting/basic_types.dart
With these new exports, we have a lot of "unnecessary import" warnings
in our tests.

As we move to generating these stubs, they will stick closer to their
real counterparts, and include exports like these.

Change-Id: Id63eec30f3a33c8c9751cbf1f213f8d4bf3c41d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475501
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-24 19:28:41 -08:00
Sam Rawlins f0c737d6c2 analyzer_testing: Widget is @immutable
This requires some changes to tests, where fields should be final. In
tests where it seemed like the mutability of a field was important, I
just ignored the warning. Otherwise, I made fields final.

I do like keeping this stub in-line with the real Widget class. If
anything, it keeps in mind that flutter Widgets should generally no
have mutable fields.

Change-Id: Ib7dc1fbd6aa013dc72925404c4be8186ddcddaa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-23 12:25:21 -08:00
Sam Rawlins 99ce676aaa analyzer_testing: DefaultTextStyle.new has a required "style" parameter
Change-Id: Idee2108dd99fa36ddc6e7dccd2a4e1d6f6d6305f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475128
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-22 18:26:42 -08:00
Sam Rawlins 3bc6a133fe analyzer_testing: Use real color values in flutter package mocks/stubs
Work towards https://github.com/dart-lang/sdk/issues/61597

First, it doesn't really look any harder to test with the real color
values, and second, when we generate these stubs, it will certainly
be harder to track which constant values and constructor calls we
change.

Change-Id: Ib8255d1c92bd661dbe379978f78ec64a810d864d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474942
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-22 11:10:09 -08:00
Sam Rawlins da68d458e1 meta: Introduce TargetKind.exportDirective, .partOfDirective, and deprecate .directive
Work towards https://github.com/dart-lang/sdk/issues/62366

Change-Id: I05ff73fcb5c7fdef88412213d68eb814c2ef2492
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-14 13:33:59 -08:00
Sam Rawlins 9062f80146 analyzer_testing: Deprecate the flutter_test mock; only used in two DAS tests.
Work towards https://github.com/dart-lang/sdk/issues/61597

Change-Id: I32caa38bff42ad9117829cca9be8b892da228a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472960
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-14 11:03:09 -08:00
Danny Tuppeny dfd316f498 [analyzer_testing] Fix up embedded_libs paths for Windows
Fixes some broken Windows bots/tests that fail to get the correct library names. The original code wrote half-windows-half-linux paths into the file, and the backslashes in the Windows paths resulted in "Invalid escape sequence" during loading (which was not visible because of an empty catch block in `EmbeddedSdk`)

Change-Id: I02677570a4c39515603aae49d94e21bedc0b39ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472905
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-14 08:05:50 -08:00
Sam Rawlins 25f0d80c15 analyzer: Refactor how the mock 'dart:ui' library is discovered
Fixes https://github.com/dart-lang/sdk/issues/62234 by making the
'dart:ui' library discoverable in the same way that the real one is
discoverable: by the sky_engine _embedder.yaml file.

Coupled with this change is the motivation: the stubs are out-of-date,
with `double width` and `double height` parameters on the Preview
constructor. But this has been changed to use a `Size` object, and
`Size` is written in 'dart:ui'. So to write a test that uses `Size`, the
test now needs proper access to 'dart:ui', and we should not write
'package:ui/ui.dart' in our test cases. These changes are in
`.../lib/mock_packages/package_content/flutter/lib/src/widget_previews/widget_previews.dart`
and in `invalid_widget_preview_private_argument_test.dart`.

Change-Id: I6f608eb3e1f431ad576ba8f3572454e42a39f9f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-13 15:32:51 -08:00
Sam Rawlins ed640293af meta: Annotate _Literal with TargetKind.constructor
Work towards https://github.com/dart-lang/sdk/issues/62253

The removed tests are for code which is no longer related to this
warning. Reporting on an extension type or a method is the purview of
the `invalid_annotation_target` warning. I'll note this in the summary.

Change-Id: Ide349bc1e414da339b9e89da25e383859a8144a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469761
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-12-30 09:29:37 -08:00
Sam Rawlins 89250d64b9 meta: Annotate nonVirtual with TargetKind.overridableMember
In the analyzer, reduce our custom warning for `nonVirtual`, (largely
replaced by the existing `invalid_annotation_target` warning). The
tests for that warning are mostly covered by the existing
`invalid_annotation_target` tests, but I added a few to fill some gaps.

Otherwise, we still report a specific warning for this annotation being
placed on an abstract member, or an instance member of an extension
type.

Work towards https://github.com/dart-lang/sdk/issues/62253

Change-Id: Ibcde2f99cf53460bff636bfc8bbf07e80779a942
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469104
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-23 09:47:27 -08:00
Sam Rawlins 971aa0b12a meta: Annotate visibleForOverriding and visibleForTesting with TargetKinds
In the analyzer, remove our custom warning for `visibleForOverriding`,
`invalid_visible_for_overriding_annotation` (replaced by the existing
`invalid_annotation_target` warning). The tests for that warning are
mostly covered by the existing `invalid_annotation_target` tests, but
I added a few to fill some gaps.

Work towards https://github.com/dart-lang/sdk/issues/62253

Change-Id: Ie960db6ebe007afde787f68e4b6b9f20a1835639
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468702
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-18 12:05:43 -08:00
Sam Rawlins 2e090517db analyzer_testing: Move last flutter mocks to multi-line strings
Work towards https://github.com/dart-lang/sdk/issues/61597

Change-Id: Idbd74c5b6ef8f4f68624c790686cf8bf8b05f9a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-10 14:58:21 -08:00
Sam Rawlins 43404dd651 analyzer_testing: Add mixed-in types; other fixes
My generator was not writing "with clauses," so this corrects that.

Additionally:

* `Diagnosticable.debugFillProperties` has annotations that I missed.
* `DiagnosticableTree.debugDescribeChildren` has an annotation that I
  missed, and can be abstract.
* VoidCallback was moved to `dart:ui`, and I had missed this.

Change-Id: I6c4c79a1532ede84e8fdbeed754662b67e5c8282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2025-12-10 10:23:29 -08:00
Sam Rawlins 49dc34715e analyzer plugins: Document how to add a stub package in tests
Fixes https://github.com/dart-lang/sdk/issues/61915

I add documentation to a few APIs, and primarily document `newPackage`
and `PackageBuilder.addFile`, which already have sufficient doc
comments.

Change-Id: Ice088c2d76604ccb991d895a1e4bb408c492b963
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-12-09 14:53:52 -08:00
Sam Rawlins ccb30ca650 analyzer_testing: Move Flutter rendering and widgets mocks to multi-line strings
Work towards https://github.com/dart-lang/sdk/issues/61597

Change-Id: I3ddd08896c91f297d4a993fb39f75e8777cd4cea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466980
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-09 13:30:49 -08:00
Paul Berry b23165db60 [messages] Use lower case diagnostic names in analyzer_testing.
Changes the logic in `pkg/analyzer_testing` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`. This
ensures that diagnostic codes are matched in a case-insensitive
fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` getter.

Change-Id: I6a6a69640838d820e8e466c23289bdf2c30eb517
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:41:22 -08:00
Paul Berry 7ac6ad6d42 [messages] Make lint name matching case insensitive.
Adjusts the logic in the lint `Registry` class so that lint names are
matched in case-insensitive fashion. For the most part this is
accomplished by adding calls to `.toLowerCase()` inside the `Registry`
class, preserving its API.

For the `enabled` method, preserving the API would have been a pain (I
would have had to translate the keys in the `ruleConfigs` parameter to
lower case). So instead I added an assertion to verify that the keys
were lower case, and pushed the responsibility to the callers to
create lower case keys.

This paves the way for a follow-up CL that will translate diagnostic
codes to `lower_snake_case` conventions.

It also solves a longstanding problem with the mixed case lint rules
`no_runtimeType_toString`, `prefer_for_elements_to_map_fromIterable`,
`prefer_iterable_whereType`. Previously, the user had to carefully
imitate the capitalization of the lint rules when specifying them in
the `analysis_options.yaml` file, even though `// ignore:` comments
for the lints matched in case insensitive fashion. With this CL, the
lint rule names in `analysis_options.yaml` are matched in case
insensitive fashion as well.

Change-Id: I6a6a6964d83241e49878bbf96ef9b94cbb12098b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465964
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-03 13:14:49 -08:00
Sam Rawlins 81f561c7f6 analyzer_testing: Migrate flutter painting mock libraries
Change-Id: Ia29fd5f1413e0b3d0b32e24c7232c755d7f2bafb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465960
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-03 12:06:02 -08:00
Sam Rawlins c5b86a3dd8 analyzer_testing: Migrate flutter mocks to in-code Strings
(just animation, foundation, and widget_previews)

Work towards https://github.com/dart-lang/sdk/issues/61597
Work towards https://github.com/dart-lang/sdk/issues/61943

In this CL, I try to keep the elements generally the same as they
are in `pkg/analyzer_testing/lib/mock_packages/package_content/flutter`
and only correcting things that are wrong/out of date. To that end:

* AnimationController extends Animation, which is defined in
  `lib/src/animation/animation.dart`, so we add that.
* FlutterErrorDetails.new has many more parameters.
* Listenable and ValueListenable are necessary, so those are added in
  `lib/src/foundation/change_notifier.dart`.
* There is no `Key._` constructor, but there is now `Key.empty`.
* Preview no longer has a `width` or `height` property (or constructor
  parameter) but now has `size`.

Change-Id: I7e73d26e6fdf9896b24e1d908f0bf2950f67db16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465660
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-02 14:02:40 -08:00
Konstantin Shcheglov 20085c0902 DeCo. Don't remove experiment from shared experimentsForTests.
Change-Id: If746609320113a42c161021f7c7328cf79bd46fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465483
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-01 16:07:30 -08:00
Sam Rawlins 870c08b50a analyzer_testing: Migrate dart:ui mocks to live in source strings
Change-Id: Idf51f83dfdf5c6173bbbdedabcd41d76c928cc8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465160
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-01 14:54:50 -08:00
Kallen Tu 2110e90d68 Rename 'declaring-constructors' to 'primary-constructors' experiment flag.
Changed the flag to `primary-constructors` to align with the rest of
the feature's public naming.

Renamed tests and existing usages of the flag.

Bug: https://github.com/dart-lang/sdk/issues/61526
Change-Id: Id649447a50917ba5bcddb49661555889dc81ba14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464761
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2025-12-01 13:54:52 -08:00
Sam Rawlins 701af8d0d1 analyzer_testing: Move mock meta package into strings
Change-Id: I80c4c888be656f230ea3bc9a53154c5f632e22e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-21 08:30:41 -08:00
Sam Rawlins b65b23650e analyzer_testing: Add deprecation to required annotations
When generating the mock packages from the real packages, I found this
discrepancy; we're missing this deprecation. To keep things aligned as
close as possible, we should add it.

Change-Id: Ibbfd9164be5b344c358a4546542723f7deaff73d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463162
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-20 13:46:18 -08:00
Konstantin Shcheglov 429062a0eb Fine. Use 'withFineDependencies: true' in analyzer_testing/.
Change-Id: I85dad7f6c51bbdf120174af0fa009fcb797e3562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-14 14:59:11 -08:00