mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 05:33:14 +00:00
Update more IdentifierContext type reference recovery
Change-Id: I7268bce4379ac4613ecd182c9d41022f2a08e7c4 Reviewed-on: https://dart-review.googlesource.com/50521 Commit-Queue: Dan Rubel <danrubel@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
8054721512
commit
5c508ff785
|
@ -9147,7 +9147,12 @@ abstract class FormalParameterParserTestMixin
|
|||
|
||||
void test_parseFormalParameterList_prefixedType_partial() {
|
||||
FormalParameterList list = parseFormalParameterList('(io.)', errors: [
|
||||
expectedError(ParserErrorCode.MISSING_IDENTIFIER, 4, 1),
|
||||
expectedError(
|
||||
usingFastaParser
|
||||
? ParserErrorCode.EXPECTED_TYPE_NAME
|
||||
: ParserErrorCode.MISSING_IDENTIFIER,
|
||||
4,
|
||||
1),
|
||||
expectedError(ParserErrorCode.MISSING_IDENTIFIER, 4, 1)
|
||||
]);
|
||||
expect(list, isNotNull);
|
||||
|
@ -9169,7 +9174,12 @@ abstract class FormalParameterParserTestMixin
|
|||
void test_parseFormalParameterList_prefixedType_partial2() {
|
||||
int errorOffset = usingFastaParser ? 4 : 3;
|
||||
FormalParameterList list = parseFormalParameterList('(io.,a)', errors: [
|
||||
expectedError(ParserErrorCode.MISSING_IDENTIFIER, errorOffset, 1),
|
||||
expectedError(
|
||||
usingFastaParser
|
||||
? ParserErrorCode.EXPECTED_TYPE_NAME
|
||||
: ParserErrorCode.MISSING_IDENTIFIER,
|
||||
errorOffset,
|
||||
1),
|
||||
expectedError(ParserErrorCode.MISSING_IDENTIFIER, errorOffset, 1)
|
||||
]);
|
||||
expect(list, isNotNull);
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
import '../../scanner/token.dart' show Token;
|
||||
|
||||
import '../fasta_codes.dart'
|
||||
show Message, Template, templateExpectedIdentifier, templateExpectedType;
|
||||
import '../fasta_codes.dart' show Message, Template, templateExpectedIdentifier;
|
||||
|
||||
import '../scanner/token_constants.dart' show IDENTIFIER_TOKEN;
|
||||
|
||||
|
@ -119,21 +118,16 @@ class IdentifierContext {
|
|||
isBuiltInIdentifierAllowed: false);
|
||||
|
||||
/// Identifier is the start of a reference to a type that starts with prefix.
|
||||
static const prefixedTypeReference = const IdentifierContext(
|
||||
'prefixedTypeReference',
|
||||
isScopeReference: true,
|
||||
isBuiltInIdentifierAllowed: true,
|
||||
recoveryTemplate: templateExpectedType);
|
||||
static const prefixedTypeReference =
|
||||
const TypeReferenceIdentifierContext.prefixed();
|
||||
|
||||
/// Identifier is the start of a reference to a type declared elsewhere.
|
||||
static const typeReference = const TypeReferenceIdentifierContext();
|
||||
|
||||
/// Identifier is part of a reference to a type declared elsewhere, but it's
|
||||
/// not the first identifier of the reference.
|
||||
static const typeReferenceContinuation = const IdentifierContext(
|
||||
'typeReferenceContinuation',
|
||||
isContinuation: true,
|
||||
isBuiltInIdentifierAllowed: false);
|
||||
static const typeReferenceContinuation =
|
||||
const TypeReferenceIdentifierContext.continuation();
|
||||
|
||||
/// Identifier is a name being declared by a top level variable declaration.
|
||||
static const topLevelVariableDeclaration = const IdentifierContext(
|
||||
|
|
|
@ -75,6 +75,16 @@ class TypeReferenceIdentifierContext extends IdentifierContext {
|
|||
isBuiltInIdentifierAllowed: false,
|
||||
recoveryTemplate: fasta.templateExpectedType);
|
||||
|
||||
const TypeReferenceIdentifierContext.continuation()
|
||||
: super('typeReferenceContinuation',
|
||||
isContinuation: true, isBuiltInIdentifierAllowed: false);
|
||||
|
||||
const TypeReferenceIdentifierContext.prefixed()
|
||||
: super('prefixedTypeReference',
|
||||
isScopeReference: true,
|
||||
isBuiltInIdentifierAllowed: true,
|
||||
recoveryTemplate: fasta.templateExpectedType);
|
||||
|
||||
@override
|
||||
Token ensureIdentifier(Token token, Parser parser) {
|
||||
Token next = token.next;
|
||||
|
@ -109,8 +119,10 @@ class TypeReferenceIdentifierContext extends IdentifierContext {
|
|||
if (optional("void", next)) {
|
||||
parser.reportRecoverableError(next, fasta.messageInvalidVoid);
|
||||
} else if (next.type.isBuiltIn) {
|
||||
parser.reportRecoverableErrorWithToken(
|
||||
next, fasta.templateBuiltInIdentifierAsType);
|
||||
if (!isBuiltInIdentifierAllowed) {
|
||||
parser.reportRecoverableErrorWithToken(
|
||||
next, fasta.templateBuiltInIdentifierAsType);
|
||||
}
|
||||
} else {
|
||||
parser.reportRecoverableErrorWithToken(
|
||||
next, fasta.templateExpectedType);
|
||||
|
|
|
@ -2008,8 +2008,6 @@ class Parser {
|
|||
followingValues = [';', '=', ','];
|
||||
} else if (context == IdentifierContext.typedefDeclaration) {
|
||||
followingValues = ['(', '<', ';'];
|
||||
} else if (context == IdentifierContext.typeReferenceContinuation) {
|
||||
followingValues = ['>', ')', ']', '}', ',', ';'];
|
||||
} else if (context == IdentifierContext.typeVariableDeclaration) {
|
||||
followingValues = ['<', '>', ';', '}'];
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue