Commit Graph

11 Commits

Author SHA1 Message Date
Jens Johansen fc67d31862 [parser] Listener calls should not be on the next (unrelated) token
When the parser sends events to the listener some events has a pair of
parameters, `beginToken` and `endToken`. Most of these are constructed
in such a way that the `beginToken` is the first token and the
`endToken` is the last token in that construct. This is for instance the
case with `endClassDeclaration`.
It was, however, not the case for `endMetadata` where `endToken` instead
was the next token *not* in the metadata.

In this CL I've found a changed the following to point to the last token
in the construct instead of the next token not in the construct and
renamed the parameter where it made sense:

* `endAssert` --- and renamed `semicolonToken` (which only pointed to
  a semicolon for statements) to `endToken`.
* `endAwaitExpression`
* `endConstLiteral` --- and renamed `token` to `endToken`
* `endConstructorReference`
* `endFieldInitializer` --- and renamed `token` to `endToken`
* `endForIn`
* `endForInBody` --- and renamed `token` to `endToken`
* `endForStatement`
* `endForStatementBody` --- and renamed `token` to `endToken`
* `endFunctionExpression` --- and renamed `token` to `endToken`
* `endInitializer` --- and renamed `token` to `endToken`
* `endInitializers`
* `endInvalidAwaitExpression`
* `endMetadata`
* `endSwitchCase`
* `endTopLevelDeclaration` --- and renamed `nextToken` to `endToken`
* `endWhileStatement`
* `endWhileStatementBody` --- and renamed `token` to `endToken`
* `handleNoConstructorReferenceContinuationAfterTypeArguments`

In the few places in listeners where these values were used I've mostly
updated to do e.g. `endToken.text!` to retain the current behavior.

Change-Id: I25495e160d1eec5c75bcf1313b512cd04bcb1533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364322
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-04-26 06:59:23 +00:00
Johnni Winther 1683fd5c16 [_fe_analyzer_shared] Ensure beginToken on class, enum, mixin, extension and extension type
This passes the first token of these top level declaration directly
to the endX listener method.

In the CFE this is used to ensure that can handle the new modifiers in
the textual outline. Furthermore, support for extension types is added
and having an "unknown chunk" now results in an error. The latter should
help us keep the textual outline up-to-date wrt new features.

Change-Id: I813d6162b6cba0a2bf550ed33a6091abf9bf49f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324702
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-09-15 13:01:10 +00:00
Johnni Winther b745fa8923 [cfe] Avoid "Instance of " in parser intertwined test expectations
Change-Id: I7d7b1c9a001c43ec160d26c478bd71b41505f273
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323361
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-09-04 13:06:29 +00:00
Johnni Winther b1594fa130 [parser] Handle invalid extension type header in error recovery
This expands the existing recovery for class headers to handle
invalid, out-of-order, and duplicate clauses in extension type
declaration headers.

Change-Id: I7b33b91cc718e4c0673137121b8d083fa0ef1562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321900
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-08-24 11:20:18 +00:00
Johnni Winther 29003657e2 [parser] Remove support for 'inline class' syntax
+ removes tests using 'inline class' syntax or replace them with
  extension type syntax.

TEST=existing

Change-Id: Ic98178c4df9a1585ad0167cfd8847caa7b771e3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321120
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-22 11:26:54 +00:00
Kallen Tu f7bc72fce6 [analyzer/cfe] Remove interface mixin, final mixin and sealed mixin.
Added error messages for when users try to use invalid mixins + a language test that tests that (and tests in each of the front ends).

Removed the tokens from the parser listeners.

Removed all behaviours and error reporting related to these invalid mixins.

Change-Id: I558595826dae7e2c176bd1929e97caa2335c167c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290614
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-30 11:56:08 +00:00
Kallen Tu 0936bceaa0 [cfe] Remove tests that use interface mixins, final mixins and sealed mixins.
Remove/change some frontend tests to make for easier removal of these invalid
mixins in https://dart-review.googlesource.com/c/sdk/+/290614.

Change-Id: I50325b8275704eb2542c5871bb6326356bd9b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291053
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-03-27 18:56:46 +00:00
Konstantin Shcheglov 67e7c96962 Fix parser to use correct begin token, to get documentation comments from it.
Change-Id: I9505353c9c6c00082e588aced34e8151c7ab22b7
Bug: https://github.com/dart-lang/sdk/issues/51447
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284441
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-22 17:03:38 +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