Files
sdk/pkg/front_end/parser_testcases/extensions/const.dart.expect
T
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

72 lines
3.0 KiB
Plaintext

Problems reported:
parser/extensions/const:1:1: Expected 'on' after this.
extension const Extension on int {}
^^^^^^^^^
parser/extensions/const:1:11: Expected a type, but got 'const'.
extension const Extension on int {}
^^^^^
parser/extensions/const:1:11: An extension declaration must have a body, even if it is empty.
extension const Extension on int {}
^^^^^
parser/extensions/const:1:27: The const variable 'on' must be initialized.
extension const Extension on int {}
^^
parser/extensions/const:1:27: Expected ';' after this.
extension const Extension on int {}
^^
parser/extensions/const:1:30: A function declaration needs an explicit list of parameters.
extension const Extension on int {}
^^^
beginCompilationUnit(extension)
beginMetadataStar(extension)
endMetadataStar(0)
beginExtensionDeclarationPrelude(extension)
handleNoTypeVariables(const)
beginExtensionDeclaration(null, extension, null)
handleRecoverableError(Message[ExpectedAfterButGot, Expected 'on' after this., null, {string: on}], extension, extension)
handleRecoverableError(Message[ExpectedType, Expected a type, but got 'const'., null, {lexeme: const}], const, const)
handleIdentifier(, typeReference)
handleNoTypeArguments(const)
handleType(, null)
handleRecoverableError(ExpectedExtensionBody, const, const)
beginClassOrMixinOrExtensionBody(DeclarationKind.Extension, {)
endClassOrMixinOrExtensionBody(DeclarationKind.Extension, 0, {, })
endExtensionDeclaration(extension, extension, on, })
endTopLevelDeclaration(})
beginMetadataStar(const)
endMetadataStar(0)
beginTopLevelMember(const)
beginFields(DeclarationKind.TopLevel, null, null, null, null, null, null, const, })
handleIdentifier(Extension, typeReference)
handleNoTypeArguments(on)
handleType(Extension, null)
handleIdentifier(on, topLevelVariableDeclaration)
handleRecoverableError(Message[ConstFieldWithoutInitializer, The const variable 'on' must be initialized., Try adding an initializer ('= expression') to the declaration., {name: on}], on, on)
handleNoFieldInitializer(int)
handleRecoverableError(Message[ExpectedAfterButGot, Expected ';' after this., null, {string: ;}], on, on)
endTopLevelFields(null, null, null, null, null, const, 1, const, ;)
endTopLevelDeclaration(;)
beginMetadataStar(int)
endMetadataStar(0)
beginTopLevelMember(int)
beginTopLevelMethod(;, null, null)
handleNoType(;)
handleIdentifier(int, topLevelFunctionDeclaration)
handleNoTypeVariables({)
handleRecoverableError(MissingFunctionParameters, int, int)
beginFormalParameters((, MemberKind.TopLevelMethod)
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
handleAsyncModifier(null, null)
beginBlockFunctionBody({)
endBlockFunctionBody(0, {, })
endTopLevelMethod(int, null, })
endTopLevelDeclaration(})
endCompilationUnit(3, )