Commit Graph

36 Commits

Author SHA1 Message Date
Johnni Winther 70a453f55f [model] Add ExperimentalFeatures for the parser
This adds an ExperimentalFeatures interface to make the parser able to know which experimental feature is currently supported. This generalizes the existing dependency on patterns and enhanced parts, and facilitates reporting of unsupported features directly within the parser, avoid the need for duplicate handling of this within analyzer+CFE.

Change-Id: If1752745ee4d753e4b463f2017f440223cd98737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455700
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-10-20 05:25:39 -07:00
Konstantin Shcheglov 44e67b1551 [analyzer] Update SDK constraint to ^3.9.0, format.
Change-Id: I79fe556112b6b9e471b043bf668677c9654b80d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447004
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-08-26 16:55:10 -07:00
Paul Berry 6610e5cbfe [analyzer] Break dependency between analyzer message codegen and analyzer.
This fixes a bootstrapping problem: previously we could get into a
situation where the generated files for analyzer diagnostic messages
were out of date, but the code generator for those messages couldn't
be run, because it imported the analyzer itself, which contained
compiled errors due to the generated files being out of date.

There were two problematic dependencies:

- The `GeneratedContent.check` and `GeneratedContent.checkAll` methods
  relied on invoking the Dart formatter as a library (rather than
  invoking `dart format` as a subprocess); the Dart formatter library
  imports the analyzer. Fortunately, this functionality is not needed
  by the code generators themselves. It's only needed by the _tests_
  that verify that code generation has run. So I was able to break the
  dependency by moving this functionality into a new file,
  `package:analyzer_utilities/generated_content_check.dart`, which is
  imported only by the code generation tests. The new API is slightly
  different: `GeneratedContent.checkAll` has been replaced by an
  extension method `check` on `Iterable<GeneratedContent>`.

- The diagnostic message code generator used to have a post-processing
  step that made use of the scanner to find error messages used by the
  parser that needed to be translated, and issued a warning if it
  found any. This check was useful a long time ago, when we were
  unifying the analyzer and CFE parsers, and is no longer useful, so
  I've removed it.

Change-Id: I509b741faca3b9ae21c23936001105ded731b490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442241
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-07-25 13:18:00 -07:00
Paul Berry fb2d1171e5 Reference all genearted file paths to pkg directory.
Modifies `GeneratedDirectory.outputDirPath` and
`GeneratedFile.outputPath` to be relative to the SDK's `pkg` directory
rather than relative to the containing package. Accordingly, modifies
the `GeneratedContent` methods `check`, `checkAll`, `generate`,
`generateAll`, `output`, as well as the `DirectoryContentsComputer`
and `FileContentsComputer` callbacks, so that their first parameter is
the path to the `pkg` directory rather than the path to the containing
package.

Also modifies the `readApi` functions in `pkg/analysis_server` and
`pkg/analyzer_plugin` to accept a path to the `pkg` directory rather
than a path to the containing package, since these functions are
called by code generation callbacks.

These changes should make code generation logic easier to reason
about. They also will make it easier to move the outputs of code
generation from one package to another, which will pave the way for
some follow-up work in which I intend to start sharing error message
representations belonging to `pkg/analyzer`, `pkg/front_end`, and
`pkg/_fe_analyzer_shared`.

Change-Id: Ia9b369b16f2df931c8a472f91400f2c5a0b8be9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438480
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-07-04 05:04:50 -07:00
Paul Berry c30dd253a3 Use package_root.dart for all analyzer_utilities-based codegen.
All code generation logic that uses the analyzer_utilities package's
`GeneratedContent` class hierarchy is modified to use
`package:analyzer_testing/package_root.dart` to locate the `pkg`
directory in the root of the SDK repo.

This paves the way for some follow-up work in which I intend to modify
the `GeneratedContent` class hierarchy so that it tracks the locations
of all code generation targets relative to the `pkg` directory rather
than the individual package directories. That in turn should make it
easier for code generation logic to be shared between error messages
belonging to `pkg/analyzer`, `pkg/front_end`, and
`pkg/_fe_analyzer_shared`.

Change-Id: Iee59e977e844261f46fb62ed4e222db79db45a25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438061
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-02 17:42:14 -07:00
Sam Rawlins 4ef2725654 Add an analyzer_testing package
We intend to publish and maintain this as a set of testing-related
utilities for the analyzer packages and for analyzer plugins.

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

See the doc: https://docs.google.com/document/d/1jRtd8B1ijPAP6Pz89HRnyIZXw2VMjaZx0vRZTpoNO84/edit?tab=t.0#heading=h.2sz41a544qhi

Change-Id: I2764b1357a932fa955060b26d78038997eaa9536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425080
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-02 06:58:49 -07:00
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Daco Harkes 98e29db45c [native_assets] Disable experiment on stable and beta channel
We want to avoid users passing `--enable-experiment=native-assets` on
stable and beta, as we'd like to move fast and break things on the
experiment. This aligns the experiment with how the experiment is
working in Flutter: main and dev branch only.

Before this CL, dartdev did not check experiment flags. Unknown
experiments would fail in the VM. After this CL, dartdev checks the
experiment flags and errors out early.

Change-Id: I875ea3272f4b67342da19ea2e4be329a4b380573
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406660
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-02-04 03:36:43 -08:00
Sam Rawlins f1aa891d6a analyzer: Add a test-directory-specific analysis options file
Change-Id: I6f8ce377923756a0ac31a377c75632216bcec0c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365867
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-10 15:52:03 +00:00
pq 98014e0e2e fixed dangling library doc comments
Change-Id: I28f5cd8ae31cb7b69da09028d0328e9f6c76bb69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294681
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-12 00:29:48 +00:00
Sam Rawlins a5912c6c58 Enforce strict-casts in analyzer
Broadly, this _adds_ text to the code, as making something explicit which was previously implicit generally requires adding characters. The fixes are of the form:

* `int x = y /* dynamic */;` --> `var x = y as int;`
* `Map<A, B> x = y; --> `var x = y.cast<A, B>();`

Most of the changes are in code which has parsed YAML or which has parsed arguments. Go figure. :)

Change-Id: I1107688bf4ce9c1ec3ed6a4cef56d4d968048e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278522
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-01-06 01:59:47 +00:00
Sam Rawlins e139fb1527 Tidy some lint issues in analyzer
* Move many identifiers from snake_case or SCREAMING_SNAKE_CASE to
  camelCase. I think I restricted the changes to private API.
* Add an ignore in generated files for constant_identifier_names;
  we often just mirror names found in YAML files or whatever, where
  things are not necessarily named according to Effective Dart
  standards.
* Avoid some implementation imports which I think were accidental.
* Use single quotes in some more places.

Bug: https://github.com/dart-lang/sdk/issues/48784
Change-Id: I439fe50cb9f8f8f5e9c74ce594aea15e394ee7da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-08-10 21:23:21 +00:00
Konstantin Shcheglov 6d5543e01b [analyzer] Update generated experiments
experimental_features.yaml was updated in
https://dart-review.googlesource.com/c/sdk/+/219789
but unfortunately the analyzer code wasn't regenerated.

This CL updates the generated files and adds capability of checking
consistency to the generator. A check of consistency is add next to
the check for consistency used in presubmit for the CFE counterpart.

Was: https://dart-review.googlesource.com/c/sdk/+/224520
Change-Id: I59be4335ee81743aca5dc48eaa0df278d64d3692
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229020
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-20 00:07:36 +00:00
Sam Rawlins e1414089cf Analyzer: avoid dynamic calls while examining Yaml
Change-Id: If569c74bad1d3762deb4cc74ea617d291ec33619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190727
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-03-12 16:50:37 +00:00
Konstantin Shcheglov aa5cf01135 Issue 44889. Enable null safety in tool/experiments/experiments_test
Bug: https://github.com/dart-lang/sdk/issues/44889
Change-Id: I7e424d68f81a7558428e3e92c159d1aea5974188
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183764
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-09 01:06:40 +00:00
Paul Berry cbd8a4582c Analyzer: Fix null safety migration error in experimental flag generation
It's possible for an entry in `tools/experimental_features.yaml` to
lack an `expired` line, so we need to represent it as a `bool?`.

Avoids a crash when running `dart
pkg/analyzer/tool/experiments/generate.dart`.

Change-Id: I8734ccb9e6c5e43754b0ef870b08c304cc1470ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-02-02 17:17:34 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Paul Berry 7d3bc4862d Rename pkg/analysis_tool to pkg/analyzer_utilities.
It's no longer just for the tools in the `tool` directory; it also
contains test utilities for use by the analyzer and related packages.

Change-Id: I0f8cf57f24ea7aad8e2177e43ee2bcb2ab3030da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171704
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-13 17:46:30 +00:00
Paul Berry 596198fb74 Share logic of package_root.dart
This CL unifies the implementations of `package_root.dart` found in
packages `analysis_server`, `analysis_server_client`, `analyzer`, and
`analyzer_plugin`.

This should make it easier to re-use this logic in other packages,
such as `nnbd_migration`.

Change-Id: I0da44edb379b8e929dd0b1c16a6989c1e9418acb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-11 18:09:18 +00:00
Konstantin Shcheglov 39e4dfe571 Update experimental_features.yaml, set experimentalReleaseVersion for non-nullable.
Bug: https://github.com/dart-lang/sdk/issues/43032
Change-Id: I28b27b3416826abd807a185b2d4214782571fb98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159383
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2020-08-20 01:38:48 +00:00
Konstantin Shcheglov 2b7fc8f134 Update FeatureSet to the new rules.
Bug: https://github.com/dart-lang/sdk/issues/43032
Change-Id: I6c7d7dc56fd0d4edcc3c6f6cc6fb0422316b8f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159187
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 18:27:37 +00:00
Konstantin Shcheglov a51f1747e0 Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.
Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 15:12:10 +00:00
Konstantin Shcheglov 7a87766f23 Remove bogus features from analyzer.
R=brianwilkerson@google.com, devoncarew@google.com

Bug: https://github.com/dart-lang/sdk/issues/40860
Change-Id: I9ce962b43cc9d0d865a54d0b31a30245e5f7c001
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153707
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-09 01:23:23 +00:00
Konstantin Shcheglov e77e270cc2 Make all parameters of ExperimentalFeature constructor named required.
Change-Id: Ib0af7526923653992c13002c808197cc16ffa98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152619
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-06-29 17:49:33 +00:00
Sam Rawlins a558d576b7 Use ///-style doc comments in analyzer/tool
Bug: https://github.com/dart-lang/sdk/issues/33892
Change-Id: I67094e84af2ec54ede00b248a2e67d3cebadc576
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152702
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-26 18:46:25 +00:00
Jens Johansen 4291a81a02 Add 'alternative-invalidation-strategy' as an experiment
To be used to enable the alternative invalidation strategy for
incremental compilation.

Change-Id: Ie4b140825d90f98aed8209eb3a5da8f2fa4dc192
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150341
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-06-24 07:18:41 +00:00
Paul Berry 794f70a044 Add currentVersion to experiments.g.dart code generated output.
Change-Id: I0ea91aaeb34068d25c07b61b0a432d24af0dd59a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138104
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-03 19:25:44 +00:00
Paul Berry d0826bdbd5 Add current-version field to tools/experimental_features.yaml.
Previously, each top level key/value pair in the file represented a
feature, so in order to make room for the new field, these were all
moved under a "features:" header.

Code generators have been updated to produce the same result as they
did before; in future CLs I'll update them to generate code based on
the new field.

Change-Id: Ia2266dd0d92796f15460127742eb2b56f64438e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138101
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-03-03 19:25:44 +00:00
Paul Berry b048ac05e6 Fix code generators to avoid generating unnecessary consts
This change fixes pkg/analyzer/tool/summary/generate.dart and
pkg/analyzer/tool/experiments/generate.dart so that the code they
generate corresponds with the changes made in
54b7543c55.

This should fix the broken analyzer-linux-release bot.

Change-Id: I651197da0853687f15bff2f2365f0b85280b5d60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128561
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-12-16 17:21:22 +00:00
Konstantin Shcheglov 364dd8936b Fix unnecessary_new in analyzer.
R=brianwilkerson@google.com

Change-Id: I70f80baa3da4b14c0a52c1f28da16a9ad26d7dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127424
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-06 01:11:30 +00:00
Johnni Winther 00c2962db8 [cfe+analyzer] Move messages, scanner and parser to package:_fe_analyzer_shared
Change-Id: I4fa87aee65f30a9868a6cf8f0342591869ece7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-01 09:37:57 +00:00
Brian Wilkerson 61b4c0f770 Cleanup hints and lints in analyzer packages
Change-Id: I7f1a6ad1ed3610da9616683576ebfb5efd543fd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119164
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-09-27 16:12:44 +00:00
Jens Johansen 74e09abc6e [CFE] Remove/move file that wasn't needed by frontend; cleanup pubspec.yaml a bit
Change-Id: I204b844e7f1cb892a529bca3a13017ed836275f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114074
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-08-23 07:42:03 +00:00
danrubel 1a9801e9fa mark ExperimentalFeature bogus_enabled and bogus_disabled as deprecated
... and update comment and test output to indicate how files should be
regenerated from tools/experimental_features.yaml

Change-Id: I369b93c35b91f7a93c915f0abf9cebdd00c13f8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106003
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Dan Rubel <danrubel@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-13 21:30:05 +00:00
Dan Rubel 9b22dd8e92 remove hard coded feature index
Change-Id: Ib01f2c9b1516987ec39591a5a320bab81138718d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104786
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-06-05 16:49:24 +00:00
Dan Rubel 9197b34a0e generate analyzer experimental flags
Change-Id: I7dc2be03e7266b6ef0a936269a2dbe584096e3db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104785
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-06-05 14:17:35 +00:00