Commit Graph

51 Commits

Author SHA1 Message Date
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 2c5f7e1ab0 Augment. Don't report an error in the parser when a factory constructor has no body.
Change-Id: Ia6df688d4c13bb1ef8b73a0bf810857a1f0fe5b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502300
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-13 11:15:09 -07:00
Konstantin Shcheglov a5ab51b142 CQ. Remove reportScannerErrors flag from Scanner.
Remove the `reportScannerErrors` option from `Scanner.tokenize`. The
parser handles scanner error tokens directly, so the scanner no longer
needs a mode that translates and reports them before parsing.

Update all callers to use the simplified `tokenize()` API. Adjust parser
recovery expectations where diagnostics are now reported at the
synthetic token location chosen by parser.

Change-Id: Ia2d479ba57b3156f1a4bab47c32444892c9d0aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500361
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-06 09:13:11 -07:00
Konstantin Shcheglov e7c6654312 Augment. Allow abstract top-level variables.
Permit `abstract` on top-level variable declarations when the
augmentations feature is enabled. Previously the parser always reported
`abstract` as extraneous at the top level, which rejected valid syntax
and dropped the modifier before later stages could see it.

Thread the abstract token through top-level field parsing, record it on
`TopLevelVariableDeclaration`, and pass it through the front-end
builders. Reorder the field callback arguments so `augment` precedes
`abstract`, matching the augmentation grammar for incomplete top-level
variables and keeping the parser, listener, and outline plumbing
consistent.

Change-Id: I680414a746b707d483e485702685c95f28a9c9ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494564
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-14 16:12:24 -07:00
Fedor Shcheglov 03f20472c4 Do not report missingFunctionBody when augmentation flag is set.
Update tests to only expect the flag on Dart version 3.5 and below, before augmentations were implemented.

Change-Id: I0b46392521701ec3846830a9adc04487c7a8541b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-04-01 11:22:35 -07:00
Konstantin Shcheglov 97130a62a6 CQ. Update ResolvedAstPrinter to output AST in the after-refactoring format.
Bug: https://github.com/dart-lang/sdk/issues/62799
Change-Id: I1cf0bfc8d30bb47723c773500a020f128dbb5232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488980
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-20 10:03:57 -07:00
Konstantin Shcheglov e9d8109258 DeCo. Support empty bodies in membered declarations
Allow enums, extensions, and mixins to use `;` as their body and
represent that form explicitly in the AST. The parser now produces
`EmptyEnumBody` or `EmptyClassBody` for the empty form.

Also replace `LibraryIdentifier` with token-based `DottedName` and store
the full token sequence for dotted names. This preserves periods and
source offsets directly in the AST, which keeps printing, selection, and
directive name handling working with the new shape. See
https://github.com/dart-lang/sdk/issues/62819

See https://github.com/dart-lang/language/issues/4645

Google3 presubmit looks green:
https://fusion2.corp.google.com/presubmit/884063020/OCL:884063020:BASE:884079610:1773618867493:b2110d76

Change-Id: I2d023cd03b6423da634c3e14742e02a61dc3b403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-16 08:56:11 -07:00
Konstantin Shcheglov e34609d78a CQ. Migrate tests to use parseStringWithErrors and remove ParseBase.
Change-Id: I6e8b0ff1ef84401c29d70e35e142d59d59878588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486640
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-10 09:19:56 -07:00
Konstantin Shcheglov 337da7b1a5 CQ. Migrate ErrorParserTest to parseStringWithErrors.
Replace ErrorParserTest's custom Fasta parser setup with the shared
parser diagnostics harness based on parseStringWithErrors().

This updates the test class to extend ParserDiagnosticsTest, rewrites
cases to parse complete source snippets, and switches expectations from
listener-based checks to parse result assertions. Parsing full units or
function bodies makes each case exercise the same entry points used by
the newer diagnostics tests.

The migration also adjusts expected offsets and diagnostics in places
where the surrounding context changes recovery, and adds parsed-node
assertions for selected cases to verify that recovery still produces the
intended AST shape.

Switch to using `ParserDiagnosticsTest` infrastructure, with
`latestWithExperiments` features caused the tests to begin testing with
the "primary constructors" and "enhanced parts" features enabled, and so
test expectations were changed in `test_functionTypedParameter_var`,
`test_invalidTopLevelVar`, `test_invalidTypedef`, and
`test_multiplePartOfDirectives`.

Change-Id: Ibce6274d92ce484cd9b7eb4c5393b312f1b4e6a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485680
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-06 09:42:11 -08:00
Konstantin Shcheglov 51003df5c3 CQ. Move constructor body diagnostics into ErrorVerifier
Centralize diagnostics for illegal constructor/method bodies in
ErrorVerifier instead of reporting them from the AST builder and Fasta
error conversion.

This consolidates several overlapping checks and fixes inconsistent
error locations (for example, reporting at `external`/`const` instead of
at `{`/`=>`).

Key changes:
- Remove constructor-body validation from AstBuilder (const bodies, const
  factories) and stop converting the corresponding Fasta codes to analyzer
  diagnostics to avoid duplicate reporting.
- Add a single verifier entry point that validates whether a body is allowed
  based on:
  - factory vs generative
  - const vs non-const
  - external vs non-external
  - redirecting vs non-redirecting
- Reuse the same validation for both regular constructors and primary
  constructors, and report at the body token for stable source ranges.
- Add a shared check for `external` functions/methods with block or expression
  bodies, and apply it consistently to top-level functions and class members.
- Align expectation files to the new, body-based error ranges and remove
  formatter-crash classification where the new reporting no longer triggers it.

Change-Id: Ie91ea08a7b5505d3e6443b12317c45359bac1c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-03 11:38:23 -08:00
Konstantin Shcheglov 034681fe8d CQ. Consolidate and extend constructor body tests
Constructor-body related expectations were split across generated parser
tests and a dedicated diagnostic test, with uneven coverage for primary
constructors and newer declaration forms (enums, extension types). This
made it easy for behavior to drift and hard to add new cases
consistently.

Refactor and expand the test coverage:

- Replace the standalone const-constructor-with-body suite with a unified
  constructor_body_test.dart that exercises primary and secondary constructors
  across classes, enums, and extension types, covering:
  - const vs non-const generative constructors
  - factory vs redirecting constructors
  - external modifiers and the interaction with bodies
  - block, empty, and (where applicable) expression-body forms
- Add a focused external_method_with_body_test.dart to cover external methods,
  getters/setters, operators, and top-level functions with bodies.
- Remove redundant constructor-body cases from generated error/parser tests and
  update a few remaining assertions to check the exact diagnostics now that
  highlighting spans are stable.
- Wire the new suites into diagnostics/test_all.dart.

This reduces duplication, centralizes the behavior matrix in one place,
and makes future language-feature coverage extensions straightforward.

Change-Id: Iafa6458531bfa19862390567f193a36a88558c03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-03 09:19:32 -08:00
Konstantin Shcheglov ba57159a6a CQ. Consolidate variable initialization diagnostics
Stop converting front end `constNotInitialized` and
`finalNotInitialized` reports, and instead centralize these diagnostics
in `ErrorVerifier`. This avoids duplicate reporting and keeps
initialization rules consistent with analyzer resolution.

Unify variable/field initialization checks by:
- Verifying `const` declarations without initializers in the verifier for fields, top-level variables, and local declarations.
- Reporting `finalNotInitialized` for non-late, non-external, non-abstract
  declarations that cannot be initialized elsewhere.
- Reporting non-nullable uninitialized diagnostics based on the resolved
  element type, distinguishing instance fields from static/top-level
  variables.
- Treating a primary-constructor body as intent to have a generative
  constructor, deferring instance-field initialization validation to the
  constructor-field verifier.

Improve error positioning for `primaryConstructorBodyWithoutDeclaration`
by anchoring the diagnostic on the `this` token, producing a tighter and
more actionable source range.

Change-Id: Id01b5a36b9fcc00e8ed282466db2d845c06e3b40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-02 09:10:23 -08:00
Konstantin Shcheglov 0349520b98 DeCo. Migrate everything to new AST.
No more flag, always parse into the new AST, always visit new AST nodes,
always return them as child entities, parent-child structure reflects
the new AST.

So, use `namePart` and `body` where possible. Deprecate previous
properties.

This is still de jure a breaking change, because `parent` of deprecated
properties changes. De facto this required very few changes in google3.

Once this CL lands, I will publish `analyzer 10.0.0`, migrate everything
to new properties, delete deprecated properties, and publish `analyzer
11.0.0`.

Maybe deprecate `NamedCompilationUnitMember.name` and migrate to
subclass specific `name` or `namePart` properties before publishing
`analyzer 10.0.0`. This part is not breaking per se.

* Deprecations in `ClassDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `EnumDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `ExtensionDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
* Deprecations in `ExtensionTypeDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `constKeyword`, `name`, `representation`, `typeParameters` are deprecated,
    use `primaryConstructor` instead.
* **Breaking Change:** While the deprecated members mentioned  above still exist in the AST,
  their parent nodes have changed. This means that code  relying on specific parent-child
  relationships for these nodes might break.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ic48104da8b029c9b454bbd2336574b7823025565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461841
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-17 08:57:36 -08:00
Paul Berry 9f6d1c1029 [messages] Start using toplevel diagnostic constants.
Changes the analyzer and related packages so that when they refer to
diagnostic constants, they do so via the import prefix `diag`, which
refers to the appropriate `diagnostic.dart` file containing the top
level diagnostic constant declarations, rather than the static
declarations inside `DiagnosticCode`-derived classes (which will soon
be removed).

This CL was created by the following steps:

- Run the script
  `pkg/analyzer_utilities/tool/messages/switch_to_toplevel_diagnostics.dart`.

- Execute `dart fix --apply --code=unused_import,unnecessary_import`
  on the following directories (this removes imports that are no
  longer necessary due to the change):
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end`
  - `pkg/analyzer_cli`

- Execute `dart format` on the following files and directories:
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end/test/scanner_test.dart`

  (Note that `pkg/front_end` and `pkg/analyzer_cli` are not
  re-formatted as whole directories because they contain `.dart` files
  that are test cases rather than source code, and reformatting those
  files might change test expectations.)

- Manually add `diag` to
  pkg/front_end/test/spell_checking_list_tests.txt.

- Manually fix the ignore comment in
  `pkg/analyzer_testing/lib/src/analysis_rule/pub_package_resolution.dart`. (The
  script `switch_to_toplevel_diagnostics.dart` automatically adds it
  after `import 'package:analyzer/src/diagnostic/diagnostic.dart' as
  diag;`, but then executing `dart format` bumps the ignore comment to
  the following line, where it has no effect.)

Change-Id: I6a6a69643022aab2b5a6224fb4124eead243260d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461521
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-12 16:53:42 -08:00
FMorschel 240eda5647 [analyzer] Migrates to contexMessages from analyzer_testing package
This also includes some small refactorings for parameter names to start using the diagnostic wording instead of error. As well as a small change to `contextMessage` and related to use a list of `Pattern`s instead of a single `String` for better matching.

In future CLs, the TODOs added in this one will be addressed so we can fully migrate this. Added them because of the size of the CL.

Bug: https://github.com/dart-lang/sdk/issues/61557
Change-Id: I5557668a1baed98faff977255c9f22e0d9d96008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452180
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-20 13:37:00 -07:00
Paul Berry 081f93dc67 [messages] Remove redundant ScannerErrorCode.expectedToken.
Removes the analyzer error code `ScannerErrorCode.expectedToken` and
replaces usages of it with `ParserErrorCode.expectedToken`. This
avoids an ambiguity between the two messages.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Change-Id: I6a6a696491a41a9d220a4502bfa9b96410580a19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-10-17 07:48:54 -07:00
Paul Berry 9dd0f99b2c [messages] Remove redundant ScannerErrorCode.missingIdentifier.
Removes the analyzer error code `ScannerErrorCode.missingIdentifier`
and replaces usages of it with
`ParserErrorCode.missingIdentifier`. This avoids an ambiguity between
the two messages.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Change-Id: I6a6a696467b91740c152278f538b9fed763e258f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:45:07 -07:00
Paul Berry 11140abcce [messages] Clean up sharing of FieldInitializerOutsideConstructor.
Changes the shared error code `FieldInitializerOutsideConstructor` so
that it generates
`CompileTimeErrorCode.fieldInitializerOutsideConstructor` rather than
`ParserErrorCode.fieldInitializerOutsideConstructor`, replacing the
old analyzer-only
`CompileTimeErrorCode.fieldInitializerOutsideConstructor`. This
eliminates unnecessary code duplication between
`pkg/analyzer/messages.yaml` and
`pkg/_fe_analyzer_shared/messages.yaml`.

Removes logic from `pkg/analyzer/lib/src/fasta/ast_builder.dart` that
previously reported
`ParserErrorCode.fieldInitializerOutsideConstructor`. This logic was
unreliable (it only triggered for method parameters and local function
declarations) and unnecessary (because it duplicated logic in the
`ErrorVerifier`). This improves the user experience by eliminating
duplicate errors.

Change-Id: I6a6a69648a9958db531bb0c84bc604358dd0af6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455466
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:29:00 -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 f2123a8f7c [analyzer] Rename error constants to camelCase.
This change was generated by the following process:

- The script `pkg/analyzer/tool/messages/rename_error_constants.dart`
  was run. This generated the vast majority of the diffs.

- Then all modified files were reformatted using
  `tools/sdk/dart-sdk/bin/dart/format`.

- Finally, the script `pkg/analyzer/tool/messages/generate.dart` was
  run, to rebuild generated code.

Change-Id: I6a6a69644ed8740ad6269d98cb169076151824ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-08-13 22:02:42 -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
Konstantin Shcheglov 86e5463c37 Parts. Support for parsing and (not) reporting errors.
Change-Id: I4f352b7cc0c782eba96cd63e5b4a605657fd5c5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375541
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-07-15 20:43:17 +00:00
Sam Rawlins 030b79dc1c analyzer: Report bare 'super' expression as ExpressionFunctionBody
Fixes https://github.com/dart-lang/sdk/issues/55525

Change-Id: Id6e1321d093b4b77f0504748e931db8f460c1b45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369122
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-06-03 17:24:26 +00:00
pq 643b9ae8f7 remove unused parser error codes
The error codes are not being generated and the mapping to `EXTRANEOUS_MODIFIER` in tests is unnecessary.

This logic is likely a hold over from when the analyzer had it’s own parser with temporary conversion logic to align it with fasta. With only one parser, these bits are stale and should be safe to remove.


Change-Id: I5b29f0081953c61771b313025595910eef055c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367540
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-22 15:08:18 +00:00
Konstantin Shcheglov b65887829e Augment. Report enums without constants after parsing.
Change-Id: I5af7fbc398bfa4ad2463fb9f37cef3757dd42151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-22 15:22:32 +00:00
Konstantin Shcheglov 0ef8f05c6c Fix 'unnecessary_final' in analyzer/.
But don't enable it yet, pending https://github.com/dart-lang/linter/issues/4938

Change-Id: I42df6e5c2699b08d729518c0565165d81e07ad3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-16 21:46:15 +00:00
pq fe6950eceb enable flutter_style_todos
Change-Id: Ic82963b754404d54e37f5fb03819aebc3fa67954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336502
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-15 23:04:19 +00:00
Johnni Winther e3621561aa [parser] Refactor BlockKind
Refactors BlockKind to pass an explicit template/message instead
of injecting words directly into the message which leads to
grammatically incorrect english in the output message.

Change-Id: I3b91abf2e5a748f3dfca2cc0a6c877e77b3ad7d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322121
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-09-04 09:40:21 +00:00
Sam Rawlins cabe213d91 Fix constructor initializer with invalid assignment expression
Fixes https://github.com/dart-lang/sdk/issues/52670

Change-Id: Ic28600c1b6c8cf309462ed28ed73ab0249c08844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317143
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-08-02 14:43:58 +00:00
Kallen Tu 2954986a7e [parser] Add errors for using class modifiers on enums.
Otherwise, in its current state, there's no clear error for any modifiers when used before an enum declaration.
This follows the same format to FINAL_MIXIN_CLASS and those groups of errors.

Bug: https://github.com/dart-lang/sdk/issues/51935
Change-Id: I8174b6894c95fef5c0f4704927b161942c19d3ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294122
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-13 14:59:57 +00:00
Robert Nystrom 56eaffb392 [flip-patterns] Enable "records" and "patterns" experiment flags.
This turns on the flags for these two language features and makes
them generally accessible.

Doing so causes a number of tests to fail, but the failures are
approved and there are filed issues for them. Most of the
failures are minor or only affect code using the new language
features.

This CL:

- Enables the features in experimental_features.yaml.
- Re-generates all of the various files generated from that.
- Makes some analyzer and front end changes that this CL
  inherited from Paul's original CL flipping all of the 3.0
  feature flags. I don't know what these changes are about, but
  I assume they are necessary.
- Pins a couple of tests to 2.19 since they deliberately test
  behavior that is specific to 2.19. (For most test changes, I've
  landed them separately, but there are a couple of stragglers
  in this CL.)

This doesn't enable "class-modifiers" or "sealed-types" and doesn't
include the core lib changes related to those.

TEST=On bots

Change-Id: Id387753772286a958e20a3589a6e983995f2e4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286344
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-10 20:02:23 +00:00
Kallen Tu ca974e5c4f [analyzer/cfe] Reland: Parse final class modifier.
Reland same files as https://dart-review.googlesource.com/c/sdk/+/278090
The only major change is parser_impl.dart parsing changes for 'final'

This change should allow 'final' for classes and mixins and maintain prior final behaviour for other constructs such as enums, typedefs, or the breaking line which was 'final library = ...;'

Change-Id: I3d84fc47479f39df6d5b0dcbe8f92d1fb78a826a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279076
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-01-19 16:08:28 +00:00
Kallen Tu ed1157acc4 Revert "[analyzer/cfe] Parse final class modifier."
This reverts commit 2f1372b460.

Reason for revert: Breaks the build. Unsure if there are other affected failures.

Original change's description:
> [analyzer/cfe] Parse final class modifier.
>
> Change-Id: Ia554c4f8f9617cc883a472eeb819aab2fd849077
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278090
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Kallen Tu <kallentu@google.com>

TBR=scheglov@google.com,johnniwinther@google.com,kallentu@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5dd74202bd46d69b7261d6d30d8cf3b1a40dbc99
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279040
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-01-13 21:04:01 +00:00
Kallen Tu 2f1372b460 [analyzer/cfe] Parse final class modifier.
Change-Id: Ia554c4f8f9617cc883a472eeb819aab2fd849077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278090
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-01-13 19:16:20 +00:00
Sam Rawlins 9896f1c647 Enable the unnamed-libraries experiment by default in 2.19.0
TEST=tests/language/library/unnamed_library_test.dart

Bug: https://github.com/dart-lang/language/issues/1073
Change-Id: I1c7fa7b4ee4450e344a7613525765e4ab590cc8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265381
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-10-25 21:10:57 +00:00
Jens Johansen e860cf241b [parser] Empty record
https://github.com/dart-lang/language/pull/2535

Change-Id: I8241119ee858ce39673472056b88c9393799e1a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-06 06:34:58 +00:00
Sam Rawlins 51114fca8a Unnamed libraries
Fixes https://github.com/dart-lang/language/issues/1073

Spec: https://github.com/dart-lang/language/blob/master/accepted/future-releases/unnamed-libraries/feature-specification.md

This work allows library directives without a name. Every single one would look like this:

```
library;
```

:) it was a little anti-climactic implementing a non-feature like this, but there it is.

The affordance for a library directive without a name is guarded by an experiment flag, `--unnamed-libraries`.

Change-Id: I8612238359e88d6082f7e89d0d0fc624fdb45273
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257490
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2022-09-23 05:37:39 +00:00
Konstantin Shcheglov e03170035a Deprecate 'get name2', use 'get name' instead.
Change-Id: Iee8ef5fb6700d96c857a22a99dc61dac3da88572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260443
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-22 02:22:47 +00:00
Jens Johansen a4352d09e1 [parser] Record literals can be const and one-element only
This should bring parsing of record literals up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Change-Id: If39bb1834137da55ef8bd1923106bbc614ea319b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256461
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-08-30 10:54:08 +00:00
Konstantin Shcheglov 01173e2aa2 Deprecate 'name' in AST, use 'name2' token instead.
Change-Id: I867f009dca12208f835199297d2ea85c203c8556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252566
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-02 16:25:34 +00:00
Jens Johansen fd4e41a7af [parser-ish] Better errors on invalid unicode escapes
https://github.com/dart-lang/sdk/issues/48542

Change-Id: Icbdcc939a93c737914091c00aaefa3c4efb2dde0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-17 13:57:45 +00:00
Konstantin Shcheglov fd885fd309 Prepare for enabling language features by default.
See https://dart-review.googlesource.com/c/sdk/+/234704

Change-Id: Ia3c72d787aa886df2566d7a852c8d04d20e95490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-03-01 23:41:28 +00:00
Jens Johansen c2b2aa5b9a [parser] Add beforeSynthetic to Synthetic*
Follow-up to https://dart-review.googlesource.com/c/sdk/+/205799

Change-Id: I620bf4548095d0597b89e4b6305c2301bcbed144
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230242
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 08:54:13 +00:00
Jens Johansen 5caa4365d7 [parser] Add beforeSynthetic to SyntheticStringToken
E.g. if reporting a missing ";" after a SyntheticStringToken (e.g. a
inserted identifier) before this CL it would go to the next token and
say we expected the ";" after that, when really we expected it *before*
that token.

Change-Id: I2c358e017edb2f661e307eba03dddaee889086d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205799
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-30 11:56:30 +00:00
Jens Johansen 7bf731a547 [parser] Special-casing of '}' (like eof) wrt. looksLikeName
Change-Id: I55fb4c10931831630f9c1621addef7fbe9d5a9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205797
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-19 06:41:58 +00:00
Konstantin Shcheglov 766113bc54 Update latestSdkLanguageVersion to 2.13
Bug: https://buganizer.corp.google.com/issues/195648511
Change-Id: I7f882edaec42c6224a0863be96a41e1abd5b3329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-10 11:56:43 +00:00
Konstantin Shcheglov 4af81e2a5b Issue 45459. Report EXPERIMENT_NOT_ENABLED instead of INVALID_GENERIC_FUNCTION_TYPE when nonfunction_type_aliases is not enabled.
Bug: https://github.com/dart-lang/sdk/issues/45459
Change-Id: I0773f15e4697620427f4449622a592e40b5a5de4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-25 21:43:04 +00:00
pq 706758a142 linter 1.2.1
Change-Id: I4d2ccc0bcc4128d60d76ea5119594d946fec35c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-03-23 15:01:16 +00:00
Sam Rawlins 237c84249b Remove unnecessary imports in analyzer
Change-Id: Ifb9a5c0a31cf3669febf2981b1d26b84f5b9d237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180781
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-02-02 14:40:24 +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