Rename TypeInfo subclasses and constants

Rename the TypeInfo constants and related constants in preparation
for refactoring and improving type argument and type parameter parsing.

Change-Id: I5a741ee06f373800973942c233490fe83916e39c
Reviewed-on: https://dart-review.googlesource.com/52140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
Dan Rubel 2018-04-20 16:07:39 +00:00 committed by commit-bot@chromium.org
parent a456753267
commit 313b5bd191
4 changed files with 185 additions and 198 deletions

View file

@ -92,7 +92,7 @@ import 'type_info.dart'
computeType,
isGeneralizedFunctionType,
isValidTypeReference,
noTypeInfo;
noType;
import 'util.dart' show optional;
@ -1262,7 +1262,7 @@ class Parser {
TypeInfo typeInfo = computeType(token, inFunctionType);
token = typeInfo.skipType(token);
next = token.next;
if (typeInfo == noTypeInfo &&
if (typeInfo == noType &&
(optional('.', next) ||
(next.isIdentifier && optional('.', next.next)))) {
// Recovery: Malformed type reference.
@ -1322,7 +1322,7 @@ class Parser {
token = next.endGroup;
next = token.next;
}
if (typeInfo != noTypeInfo &&
if (typeInfo != noType &&
varFinalOrConst != null &&
optional('var', varFinalOrConst)) {
reportRecoverableError(varFinalOrConst, fasta.messageTypeAfterVar);
@ -2794,7 +2794,7 @@ class Parser {
covariantToken = null;
}
}
if (typeInfo == noTypeInfo) {
if (typeInfo == noType) {
if (varFinalOrConst == null) {
reportRecoverableError(
beforeName.next, fasta.messageMissingConstFinalVarOrType);
@ -3443,7 +3443,7 @@ class Parser {
typeInfo,
getOrSet);
}
} else if (typeInfo == noTypeInfo && varFinalOrConst == null) {
} else if (typeInfo == noType && varFinalOrConst == null) {
Token next2 = next.next;
if (next2.isUserDefinableOperator && next2.endGroup == null) {
String value = next2.next.stringValue;
@ -5268,7 +5268,7 @@ class Parser {
assert(optional('const', constToken));
if (!isModifier(constToken.next)) {
TypeInfo typeInfo = computeType(constToken, false);
if (typeInfo == noTypeInfo) {
if (typeInfo == noType) {
Token next = constToken.next;
if (!next.isIdentifier) {
return parseExpressionStatement(start);
@ -5399,11 +5399,11 @@ class Parser {
// identifier, then allow ensureIdentifier to report an error
// and don't report errors here.
if (varFinalOrConst == null) {
if (typeInfo == noTypeInfo) {
if (typeInfo == noType) {
reportRecoverableError(next, fasta.messageMissingConstFinalVarOrType);
}
} else if (optional('var', varFinalOrConst)) {
if (typeInfo != noTypeInfo) {
if (typeInfo != noType) {
reportRecoverableError(varFinalOrConst, fasta.messageTypeAfterVar);
}
}

View file

@ -10,15 +10,7 @@ import '../scanner/token_constants.dart' show IDENTIFIER_TOKEN, KEYWORD_TOKEN;
import 'parser.dart' show Parser;
import 'type_info_impl.dart'
show
ComplexTypeInfo,
NoTypeInfo,
PrefixedTypeInfo,
SimpleTypeArgumentsInfo,
SimpleTypeInfo,
VoidTypeInfo,
looksLikeName;
import 'type_info_impl.dart';
import 'util.dart' show optional;
@ -63,26 +55,26 @@ abstract class TypeInfo {
Token skipType(Token token);
}
/// [NoTypeInfo] is a specialized [TypeInfo] returned by [computeType] when
/// [NoType] is a specialized [TypeInfo] returned by [computeType] when
/// there is no type information in the source.
const TypeInfo noTypeInfo = const NoTypeInfo();
const TypeInfo noType = const NoType();
/// [VoidTypeInfo] is a specialized [TypeInfo] returned by [computeType] when
/// [VoidType] is a specialized [TypeInfo] returned by [computeType] when
/// there is a single identifier as the type reference.
const TypeInfo voidTypeInfo = const VoidTypeInfo();
const TypeInfo voidType = const VoidType();
/// [SimpleTypeInfo] is a specialized [TypeInfo] returned by [computeType]
/// [SimpleType] is a specialized [TypeInfo] returned by [computeType]
/// when there is a single identifier as the type reference.
const TypeInfo simpleTypeInfo = const SimpleTypeInfo();
const TypeInfo simpleType = const SimpleType();
/// [PrefixedTypeInfo] is a specialized [TypeInfo] returned by [computeType]
/// [PrefixedType] is a specialized [TypeInfo] returned by [computeType]
/// when the type reference is of the form: identifier `.` identifier.
const TypeInfo prefixedTypeInfo = const PrefixedTypeInfo();
const TypeInfo prefixedType = const PrefixedType();
/// [SimpleTypeArgumentsInfo] is a specialized [TypeInfo] returned by
/// [SimpleTypeWith1Argument] is a specialized [TypeInfo] returned by
/// [computeType] when the type reference is of the form:
/// identifier `<` identifier `>`.
const TypeInfo simpleTypeArgumentsInfo = const SimpleTypeArgumentsInfo();
const TypeInfo simpleTypeWith1Argument = const SimpleTypeWith1Argument();
Token insertSyntheticIdentifierAfter(Token token, Parser parser) {
Token identifier = new SyntheticStringToken(
@ -142,7 +134,7 @@ TypeInfo computeType(final Token token, bool required) {
// Recovery: looks like prefixed type missing the prefix
return new ComplexTypeInfo(token).computePrefixedType(required);
}
return noTypeInfo;
return noType;
}
if (optional('void', next)) {
@ -152,7 +144,7 @@ TypeInfo computeType(final Token token, bool required) {
return new ComplexTypeInfo(token).computeVoidGFT(required);
}
// `void`
return voidTypeInfo;
return voidType;
}
if (isGeneralizedFunctionType(next)) {
@ -176,10 +168,10 @@ TypeInfo computeType(final Token token, bool required) {
if (!isGeneralizedFunctionType(next)) {
if (required || looksLikeName(next)) {
// identifier `<` identifier `>` identifier
return simpleTypeArgumentsInfo;
return simpleTypeWith1Argument;
} else {
// identifier `<` identifier `>` non-identifier
return noTypeInfo;
return noType;
}
}
}
@ -193,7 +185,7 @@ TypeInfo computeType(final Token token, bool required) {
.computeSimpleWithTypeArguments(required);
}
// identifier `<`
return required ? simpleTypeInfo : noTypeInfo;
return required ? simpleType : noType;
}
if (optional('.', next)) {
@ -204,10 +196,10 @@ TypeInfo computeType(final Token token, bool required) {
if (!optional('<', next) && !isGeneralizedFunctionType(next)) {
if (required || looksLikeName(next)) {
// identifier `.` identifier identifier
return prefixedTypeInfo;
return prefixedType;
} else {
// identifier `.` identifier non-identifier
return noTypeInfo;
return noType;
}
}
// identifier `.` identifier
@ -216,7 +208,7 @@ TypeInfo computeType(final Token token, bool required) {
// identifier `.` non-identifier
return required
? new ComplexTypeInfo(token).computePrefixedType(required)
: noTypeInfo;
: noType;
}
if (isGeneralizedFunctionType(next)) {
@ -226,7 +218,7 @@ TypeInfo computeType(final Token token, bool required) {
if (required || looksLikeName(next)) {
// identifier identifier
return simpleTypeInfo;
return simpleType;
}
return noTypeInfo;
return noType;
}

View file

@ -22,9 +22,9 @@ import 'type_info.dart';
import 'util.dart' show optional;
/// See documentation on the [noTypeInfo] const.
class NoTypeInfo implements TypeInfo {
const NoTypeInfo();
/// See documentation on the [noType] const.
class NoType implements TypeInfo {
const NoType();
@override
bool get couldBeExpression => false;
@ -34,7 +34,7 @@ class NoTypeInfo implements TypeInfo {
parser.reportRecoverableErrorWithToken(
token.next, fasta.templateExpectedType);
insertSyntheticIdentifierAfter(token, parser);
return simpleTypeInfo.parseType(token, parser);
return simpleType.parseType(token, parser);
}
@override
@ -57,9 +57,9 @@ class NoTypeInfo implements TypeInfo {
}
}
/// See documentation on the [prefixedTypeInfo] const.
class PrefixedTypeInfo implements TypeInfo {
const PrefixedTypeInfo();
/// See documentation on the [prefixedType] const.
class PrefixedType implements TypeInfo {
const PrefixedType();
@override
bool get couldBeExpression => true;
@ -103,9 +103,9 @@ class PrefixedTypeInfo implements TypeInfo {
}
}
/// See documentation on the [simpleTypeArgumentsInfo] const.
class SimpleTypeArgumentsInfo implements TypeInfo {
const SimpleTypeArgumentsInfo();
/// See documentation on the [simpleTypeWith1Argument] const.
class SimpleTypeWith1Argument implements TypeInfo {
const SimpleTypeWith1Argument();
@override
bool get couldBeExpression => false;
@ -133,7 +133,7 @@ class SimpleTypeArgumentsInfo implements TypeInfo {
assert(optional('<', token));
listener.beginTypeArguments(token);
token = simpleTypeInfo.parseTypeNotVoid(token, parser);
token = simpleType.parseTypeNotVoid(token, parser);
token = token.next;
assert(optional('>', token));
@ -150,9 +150,9 @@ class SimpleTypeArgumentsInfo implements TypeInfo {
}
}
/// See documentation on the [simpleTypeInfo] const.
class SimpleTypeInfo implements TypeInfo {
const SimpleTypeInfo();
/// See documentation on the [simpleType] const.
class SimpleType implements TypeInfo {
const SimpleType();
@override
bool get couldBeExpression => true;
@ -186,9 +186,9 @@ class SimpleTypeInfo implements TypeInfo {
}
}
/// See documentation on the [voidTypeInfo] const.
class VoidTypeInfo implements TypeInfo {
const VoidTypeInfo();
/// See documentation on the [voidType] const.
class VoidType implements TypeInfo {
const VoidType();
@override
bool get couldBeExpression => false;
@ -197,7 +197,7 @@ class VoidTypeInfo implements TypeInfo {
Token ensureTypeNotVoid(Token token, Parser parser) {
// Report an error, then parse `void` as if it were a type name.
parser.reportRecoverableError(token.next, fasta.messageInvalidVoid);
return simpleTypeInfo.parseTypeNotVoid(token, parser);
return simpleType.parseTypeNotVoid(token, parser);
}
@override
@ -306,11 +306,11 @@ class ComplexTypeInfo implements TypeInfo {
// A function type without return type.
// Push the non-existing return type first. The loop below will
// generate the full type.
noTypeInfo.parseTypeNotVoid(token, parser);
noType.parseTypeNotVoid(token, parser);
} else {
Token typeRefOrPrefix = token.next;
if (optional('void', typeRefOrPrefix)) {
token = voidTypeInfo.parseType(token, parser);
token = voidType.parseType(token, parser);
} else {
if (!optional('.', typeRefOrPrefix) &&
!optional('.', typeRefOrPrefix.next)) {
@ -368,7 +368,7 @@ class ComplexTypeInfo implements TypeInfo {
computeRest(start, required);
if (gftHasReturnType == null) {
return required ? simpleTypeInfo : noTypeInfo;
return required ? simpleType : noType;
}
assert(end != null);
return this;
@ -382,7 +382,7 @@ class ComplexTypeInfo implements TypeInfo {
computeRest(start.next, required);
if (gftHasReturnType == null) {
return voidTypeInfo;
return voidType;
}
assert(end != null);
return this;
@ -418,7 +418,7 @@ class ComplexTypeInfo implements TypeInfo {
computeRest(start.next, required);
if (gftHasReturnType == null) {
return simpleTypeInfo;
return simpleType;
}
assert(end != null);
return this;
@ -433,13 +433,13 @@ class ComplexTypeInfo implements TypeInfo {
Token token = skipTypeArguments(typeArguments);
if (token == null) {
return required ? simpleTypeInfo : noTypeInfo;
return required ? simpleType : noType;
}
end = token;
computeRest(token.next, required);
if (!required && !looksLikeName(end.next) && gftHasReturnType == null) {
return noTypeInfo;
return noType;
}
assert(end != null);
return this;
@ -464,7 +464,7 @@ class ComplexTypeInfo implements TypeInfo {
typeArguments = token;
token = skipTypeArguments(token);
if (token == null) {
return required ? prefixedTypeInfo : noTypeInfo;
return required ? prefixedType : noType;
}
end = token;
token = token.next;
@ -472,7 +472,7 @@ class ComplexTypeInfo implements TypeInfo {
computeRest(token, required);
if (!required && !looksLikeName(end.next) && gftHasReturnType == null) {
return noTypeInfo;
return noType;
}
assert(end != null);
return this;

View file

@ -22,15 +22,15 @@ class TokenInfoTest {
void test_noType() {
final Token start = scanString('before ;').tokens;
expect(noTypeInfo.couldBeExpression, isFalse);
expect(noTypeInfo.skipType(start), start);
expect(noType.couldBeExpression, isFalse);
expect(noType.skipType(start), start);
}
void test_noType_ensureTypeNotVoid() {
final Token start = scanString('before ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(noTypeInfo.ensureTypeNotVoid(start, new Parser(listener)),
expect(noType.ensureTypeNotVoid(start, new Parser(listener)),
new isInstanceOf<SyntheticStringToken>());
expect(listener.calls, [
'handleIdentifier typeReference',
@ -44,7 +44,7 @@ class TokenInfoTest {
final Token start = scanString('before ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(noTypeInfo.ensureTypeOrVoid(start, new Parser(listener)),
expect(noType.ensureTypeOrVoid(start, new Parser(listener)),
new isInstanceOf<SyntheticStringToken>());
expect(listener.calls, [
'handleIdentifier typeReference',
@ -58,7 +58,7 @@ class TokenInfoTest {
final Token start = scanString('before ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(noTypeInfo.parseType(start, new Parser(listener)), start);
expect(noType.parseType(start, new Parser(listener)), start);
expect(listener.calls, ['handleNoType before']);
expect(listener.errors, isNull);
}
@ -67,7 +67,7 @@ class TokenInfoTest {
final Token start = scanString('before ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(noTypeInfo.parseTypeNotVoid(start, new Parser(listener)), start);
expect(noType.parseTypeNotVoid(start, new Parser(listener)), start);
expect(listener.calls, ['handleNoType before']);
expect(listener.errors, isNull);
}
@ -75,16 +75,15 @@ class TokenInfoTest {
void test_voidType() {
final Token start = scanString('before void ;').tokens;
expect(voidTypeInfo.skipType(start), start.next);
expect(voidTypeInfo.couldBeExpression, isFalse);
expect(voidType.skipType(start), start.next);
expect(voidType.couldBeExpression, isFalse);
}
void test_voidType_ensureTypeNotVoid() {
final Token start = scanString('before void ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(voidTypeInfo.ensureTypeNotVoid(start, new Parser(listener)),
start.next);
expect(voidType.ensureTypeNotVoid(start, new Parser(listener)), start.next);
expect(listener.calls, [
'handleIdentifier void typeReference',
'handleNoTypeArguments ;',
@ -97,7 +96,7 @@ class TokenInfoTest {
final Token start = scanString('before void ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(voidTypeInfo.parseType(start, new Parser(listener)), start.next);
expect(voidType.parseType(start, new Parser(listener)), start.next);
expect(listener.calls, ['handleVoidKeyword void']);
expect(listener.errors, isNull);
}
@ -106,7 +105,7 @@ class TokenInfoTest {
final Token start = scanString('before void ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(voidTypeInfo.parseType(start, new Parser(listener)), start.next);
expect(voidType.parseType(start, new Parser(listener)), start.next);
expect(listener.calls, ['handleVoidKeyword void']);
expect(listener.errors, isNull);
}
@ -115,8 +114,7 @@ class TokenInfoTest {
final Token start = scanString('before void ;').tokens;
final TypeInfoListener listener = new TypeInfoListener();
expect(
voidTypeInfo.parseTypeNotVoid(start, new Parser(listener)), start.next);
expect(voidType.parseTypeNotVoid(start, new Parser(listener)), start.next);
expect(listener.calls, [
'handleIdentifier void typeReference',
'handleNoTypeArguments ;',
@ -129,8 +127,8 @@ class TokenInfoTest {
final Token start = scanString('before C.a ;').tokens;
final Token expectedEnd = start.next.next.next;
expect(prefixedTypeInfo.skipType(start), expectedEnd);
expect(prefixedTypeInfo.couldBeExpression, isTrue);
expect(prefixedType.skipType(start), expectedEnd);
expect(prefixedType.couldBeExpression, isTrue);
TypeInfoListener listener;
assertResult(Token actualEnd) {
@ -146,27 +144,24 @@ class TokenInfoTest {
}
listener = new TypeInfoListener();
assertResult(
prefixedTypeInfo.ensureTypeNotVoid(start, new Parser(listener)));
assertResult(prefixedType.ensureTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(
prefixedTypeInfo.ensureTypeOrVoid(start, new Parser(listener)));
assertResult(prefixedType.ensureTypeOrVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(
prefixedTypeInfo.parseTypeNotVoid(start, new Parser(listener)));
assertResult(prefixedType.parseTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(prefixedTypeInfo.parseType(start, new Parser(listener)));
assertResult(prefixedType.parseType(start, new Parser(listener)));
}
void test_simpleTypeInfo() {
final Token start = scanString('before C ;').tokens;
final Token expectedEnd = start.next;
expect(simpleTypeInfo.skipType(start), expectedEnd);
expect(simpleTypeInfo.couldBeExpression, isTrue);
expect(simpleType.skipType(start), expectedEnd);
expect(simpleType.couldBeExpression, isTrue);
TypeInfoListener listener;
assertResult(Token actualEnd) {
@ -180,24 +175,24 @@ class TokenInfoTest {
}
listener = new TypeInfoListener();
assertResult(simpleTypeInfo.ensureTypeNotVoid(start, new Parser(listener)));
assertResult(simpleType.ensureTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(simpleTypeInfo.ensureTypeOrVoid(start, new Parser(listener)));
assertResult(simpleType.ensureTypeOrVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(simpleTypeInfo.parseTypeNotVoid(start, new Parser(listener)));
assertResult(simpleType.parseTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(simpleTypeInfo.parseType(start, new Parser(listener)));
assertResult(simpleType.parseType(start, new Parser(listener)));
}
void test_simpleTypeArgumentsInfo() {
final Token start = scanString('before C<T> ;').tokens;
final Token expectedEnd = start.next.next.next.next;
expect(simpleTypeArgumentsInfo.skipType(start), expectedEnd);
expect(simpleTypeArgumentsInfo.couldBeExpression, isFalse);
expect(simpleTypeWith1Argument.skipType(start), expectedEnd);
expect(simpleTypeWith1Argument.couldBeExpression, isFalse);
TypeInfoListener listener;
assertResult(Token actualEnd) {
@ -216,40 +211,40 @@ class TokenInfoTest {
listener = new TypeInfoListener();
assertResult(
simpleTypeArgumentsInfo.ensureTypeNotVoid(start, new Parser(listener)));
simpleTypeWith1Argument.ensureTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(
simpleTypeArgumentsInfo.ensureTypeOrVoid(start, new Parser(listener)));
simpleTypeWith1Argument.ensureTypeOrVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(
simpleTypeArgumentsInfo.parseTypeNotVoid(start, new Parser(listener)));
simpleTypeWith1Argument.parseTypeNotVoid(start, new Parser(listener)));
listener = new TypeInfoListener();
assertResult(
simpleTypeArgumentsInfo.parseType(start, new Parser(listener)));
simpleTypeWith1Argument.parseType(start, new Parser(listener)));
}
void test_computeType_basic() {
expectInfo(noTypeInfo, '');
expectInfo(noTypeInfo, ';');
expectInfo(noTypeInfo, '( foo');
expectInfo(noTypeInfo, '< foo');
expectInfo(noTypeInfo, '= foo');
expectInfo(noTypeInfo, '* foo');
expectInfo(noTypeInfo, 'do foo');
expectInfo(noTypeInfo, 'get foo');
expectInfo(noTypeInfo, 'set foo');
expectInfo(noTypeInfo, 'operator *');
expectInfo(noType, '');
expectInfo(noType, ';');
expectInfo(noType, '( foo');
expectInfo(noType, '< foo');
expectInfo(noType, '= foo');
expectInfo(noType, '* foo');
expectInfo(noType, 'do foo');
expectInfo(noType, 'get foo');
expectInfo(noType, 'set foo');
expectInfo(noType, 'operator *');
expectInfo(noTypeInfo, '.', required: false);
expectInfo(noType, '.', required: false);
expectComplexInfo('.', required: true, expectedErrors: [
error(codeExpectedType, 0, 1),
error(codeExpectedType, 1, 0)
]);
expectInfo(noTypeInfo, '.Foo', required: false);
expectInfo(noType, '.Foo', required: false);
expectComplexInfo('.Foo',
required: true, expectedErrors: [error(codeExpectedType, 0, 1)]);
}
@ -340,8 +335,8 @@ class TokenInfoTest {
'endFunctionType Function m',
]);
expectInfo(noTypeInfo, 'Function(int x)', required: false);
expectInfo(noTypeInfo, 'Function<T>(int x)', required: false);
expectInfo(noType, 'Function(int x)', required: false);
expectInfo(noType, 'Function<T>(int x)', required: false);
expectComplexInfo('Function(int x)', required: true);
expectComplexInfo('Function<T>(int x)', required: true);
@ -356,40 +351,40 @@ class TokenInfoTest {
}
void test_computeType_identifier() {
expectInfo(noTypeInfo, 'C', required: false);
expectInfo(noTypeInfo, 'C;', required: false);
expectInfo(noTypeInfo, 'C(', required: false);
expectInfo(noTypeInfo, 'C<', required: false);
expectInfo(noTypeInfo, 'C.', required: false);
expectInfo(noTypeInfo, 'C=', required: false);
expectInfo(noTypeInfo, 'C*', required: false);
expectInfo(noTypeInfo, 'C do', required: false);
expectInfo(noType, 'C', required: false);
expectInfo(noType, 'C;', required: false);
expectInfo(noType, 'C(', required: false);
expectInfo(noType, 'C<', required: false);
expectInfo(noType, 'C.', required: false);
expectInfo(noType, 'C=', required: false);
expectInfo(noType, 'C*', required: false);
expectInfo(noType, 'C do', required: false);
expectInfo(simpleTypeInfo, 'C', required: true);
expectInfo(simpleTypeInfo, 'C;', required: true);
expectInfo(simpleTypeInfo, 'C(', required: true);
expectInfo(simpleTypeInfo, 'C<', required: true);
expectInfo(simpleType, 'C', required: true);
expectInfo(simpleType, 'C;', required: true);
expectInfo(simpleType, 'C(', required: true);
expectInfo(simpleType, 'C<', required: true);
expectComplexInfo('C.',
required: true, expectedErrors: [error(codeExpectedType, 2, 0)]);
expectInfo(simpleTypeInfo, 'C=', required: true);
expectInfo(simpleTypeInfo, 'C*', required: true);
expectInfo(simpleTypeInfo, 'C do', required: true);
expectInfo(simpleType, 'C=', required: true);
expectInfo(simpleType, 'C*', required: true);
expectInfo(simpleType, 'C do', required: true);
expectInfo(simpleTypeInfo, 'C foo');
expectInfo(simpleTypeInfo, 'C get');
expectInfo(simpleTypeInfo, 'C set');
expectInfo(simpleTypeInfo, 'C operator');
expectInfo(simpleTypeInfo, 'C this');
expectInfo(simpleTypeInfo, 'C Function');
expectInfo(simpleType, 'C foo');
expectInfo(simpleType, 'C get');
expectInfo(simpleType, 'C set');
expectInfo(simpleType, 'C operator');
expectInfo(simpleType, 'C this');
expectInfo(simpleType, 'C Function');
}
void test_computeType_identifierComplex() {
expectInfo(simpleTypeInfo, 'C Function()', required: false);
expectInfo(simpleTypeInfo, 'C Function<T>()', required: false);
expectInfo(simpleTypeInfo, 'C Function(int)', required: false);
expectInfo(simpleTypeInfo, 'C Function<T>(int)', required: false);
expectInfo(simpleTypeInfo, 'C Function(int x)', required: false);
expectInfo(simpleTypeInfo, 'C Function<T>(int x)', required: false);
expectInfo(simpleType, 'C Function()', required: false);
expectInfo(simpleType, 'C Function<T>()', required: false);
expectInfo(simpleType, 'C Function(int)', required: false);
expectInfo(simpleType, 'C Function<T>(int)', required: false);
expectInfo(simpleType, 'C Function(int x)', required: false);
expectInfo(simpleType, 'C Function<T>(int x)', required: false);
expectComplexInfo('C Function()', required: true);
expectComplexInfo('C Function<T>()', required: true);
@ -416,16 +411,16 @@ class TokenInfoTest {
}
void test_computeType_identifierTypeArg() {
expectInfo(noTypeInfo, 'C<T>', required: false);
expectInfo(noTypeInfo, 'C<T>;', required: false);
expectInfo(noTypeInfo, 'C<T>(', required: false);
expectInfo(noTypeInfo, 'C<T> do', required: false);
expectInfo(noTypeInfo, 'C<void>', required: false);
expectInfo(noType, 'C<T>', required: false);
expectInfo(noType, 'C<T>;', required: false);
expectInfo(noType, 'C<T>(', required: false);
expectInfo(noType, 'C<T> do', required: false);
expectInfo(noType, 'C<void>', required: false);
expectInfo(simpleTypeArgumentsInfo, 'C<T>', required: true);
expectInfo(simpleTypeArgumentsInfo, 'C<T>;', required: true);
expectInfo(simpleTypeArgumentsInfo, 'C<T>(', required: true);
expectInfo(simpleTypeArgumentsInfo, 'C<T> do', required: true);
expectInfo(simpleTypeWith1Argument, 'C<T>', required: true);
expectInfo(simpleTypeWith1Argument, 'C<T>;', required: true);
expectInfo(simpleTypeWith1Argument, 'C<T>(', required: true);
expectInfo(simpleTypeWith1Argument, 'C<T> do', required: true);
expectComplexInfo('C<void>', required: true, expectedCalls: [
'handleIdentifier C typeReference',
'beginTypeArguments <',
@ -434,17 +429,17 @@ class TokenInfoTest {
'handleType C ',
]);
expectInfo(simpleTypeArgumentsInfo, 'C<T> foo');
expectInfo(simpleTypeArgumentsInfo, 'C<T> get');
expectInfo(simpleTypeArgumentsInfo, 'C<T> set');
expectInfo(simpleTypeArgumentsInfo, 'C<T> operator');
expectInfo(simpleTypeArgumentsInfo, 'C<T> Function');
expectInfo(simpleTypeWith1Argument, 'C<T> foo');
expectInfo(simpleTypeWith1Argument, 'C<T> get');
expectInfo(simpleTypeWith1Argument, 'C<T> set');
expectInfo(simpleTypeWith1Argument, 'C<T> operator');
expectInfo(simpleTypeWith1Argument, 'C<T> Function');
}
void test_computeType_identifierTypeArgComplex() {
expectInfo(noTypeInfo, 'C<S,T>', required: false);
expectInfo(noTypeInfo, 'C<S<T>>', required: false);
expectInfo(noTypeInfo, 'C.a<T>', required: false);
expectInfo(noType, 'C<S,T>', required: false);
expectInfo(noType, 'C<S<T>>', required: false);
expectInfo(noType, 'C.a<T>', required: false);
expectComplexInfo('C<S,T>', required: true, expectedCalls: [
'handleIdentifier C typeReference',
@ -541,7 +536,7 @@ class TokenInfoTest {
error(codeExpectedToken, 6, 6)
]);
expectInfo(noTypeInfo, 'C<>', required: false);
expectInfo(noType, 'C<>', required: false);
expectComplexInfo('C<>', required: true, expectedCalls: [
'handleIdentifier C typeReference',
'beginTypeArguments <',
@ -566,32 +561,32 @@ class TokenInfoTest {
]);
// Statements that should not have a type
expectInfo(noTypeInfo, 'C<T ; T>U;', required: false);
expectInfo(noTypeInfo, 'C<T && T>U;', required: false);
expectInfo(noType, 'C<T ; T>U;', required: false);
expectInfo(noType, 'C<T && T>U;', required: false);
}
void test_computeType_prefixed() {
expectInfo(noTypeInfo, 'C.a', required: false);
expectInfo(noTypeInfo, 'C.a;', required: false);
expectInfo(noTypeInfo, 'C.a(', required: false);
expectInfo(noTypeInfo, 'C.a<', required: false);
expectInfo(noTypeInfo, 'C.a=', required: false);
expectInfo(noTypeInfo, 'C.a*', required: false);
expectInfo(noTypeInfo, 'C.a do', required: false);
expectInfo(noType, 'C.a', required: false);
expectInfo(noType, 'C.a;', required: false);
expectInfo(noType, 'C.a(', required: false);
expectInfo(noType, 'C.a<', required: false);
expectInfo(noType, 'C.a=', required: false);
expectInfo(noType, 'C.a*', required: false);
expectInfo(noType, 'C.a do', required: false);
expectInfo(prefixedTypeInfo, 'C.a', required: true);
expectInfo(prefixedTypeInfo, 'C.a;', required: true);
expectInfo(prefixedTypeInfo, 'C.a(', required: true);
expectInfo(prefixedTypeInfo, 'C.a<', required: true);
expectInfo(prefixedTypeInfo, 'C.a=', required: true);
expectInfo(prefixedTypeInfo, 'C.a*', required: true);
expectInfo(prefixedTypeInfo, 'C.a do', required: true);
expectInfo(prefixedType, 'C.a', required: true);
expectInfo(prefixedType, 'C.a;', required: true);
expectInfo(prefixedType, 'C.a(', required: true);
expectInfo(prefixedType, 'C.a<', required: true);
expectInfo(prefixedType, 'C.a=', required: true);
expectInfo(prefixedType, 'C.a*', required: true);
expectInfo(prefixedType, 'C.a do', required: true);
expectInfo(prefixedTypeInfo, 'C.a foo');
expectInfo(prefixedTypeInfo, 'C.a get');
expectInfo(prefixedTypeInfo, 'C.a set');
expectInfo(prefixedTypeInfo, 'C.a operator');
expectInfo(prefixedTypeInfo, 'C.a Function');
expectInfo(prefixedType, 'C.a foo');
expectInfo(prefixedType, 'C.a get');
expectInfo(prefixedType, 'C.a set');
expectInfo(prefixedType, 'C.a operator');
expectInfo(prefixedType, 'C.a Function');
}
void test_computeType_prefixedGFT() {
@ -702,19 +697,19 @@ class TokenInfoTest {
}
void test_computeType_void() {
expectInfo(voidTypeInfo, 'void');
expectInfo(voidTypeInfo, 'void;');
expectInfo(voidTypeInfo, 'void(');
expectInfo(voidTypeInfo, 'void<');
expectInfo(voidTypeInfo, 'void=');
expectInfo(voidTypeInfo, 'void*');
expectInfo(voidTypeInfo, 'void<T>');
expectInfo(voidTypeInfo, 'void do');
expectInfo(voidTypeInfo, 'void foo');
expectInfo(voidTypeInfo, 'void get');
expectInfo(voidTypeInfo, 'void set');
expectInfo(voidTypeInfo, 'void operator');
expectInfo(voidTypeInfo, 'void Function');
expectInfo(voidType, 'void');
expectInfo(voidType, 'void;');
expectInfo(voidType, 'void(');
expectInfo(voidType, 'void<');
expectInfo(voidType, 'void=');
expectInfo(voidType, 'void*');
expectInfo(voidType, 'void<T>');
expectInfo(voidType, 'void do');
expectInfo(voidType, 'void foo');
expectInfo(voidType, 'void get');
expectInfo(voidType, 'void set');
expectInfo(voidType, 'void operator');
expectInfo(voidType, 'void Function');
expectComplexInfo('void Function(', // Scanner inserts synthetic ')'.
required: true,
expectedCalls: [
@ -728,7 +723,7 @@ class TokenInfoTest {
}
void test_computeType_voidComplex() {
expectInfo(voidTypeInfo, 'void Function()', required: false);
expectInfo(voidType, 'void Function()', required: false);
expectComplexInfo('void Function()', required: true, expectedCalls: [
'handleNoTypeVariables (',
'beginFunctionType void',
@ -738,11 +733,11 @@ class TokenInfoTest {
'endFunctionType Function ',
]);
expectInfo(voidTypeInfo, 'void Function<T>()', required: false);
expectInfo(voidTypeInfo, 'void Function(int)', required: false);
expectInfo(voidTypeInfo, 'void Function<T>(int)', required: false);
expectInfo(voidTypeInfo, 'void Function(int x)', required: false);
expectInfo(voidTypeInfo, 'void Function<T>(int x)', required: false);
expectInfo(voidType, 'void Function<T>()', required: false);
expectInfo(voidType, 'void Function(int)', required: false);
expectInfo(voidType, 'void Function<T>(int)', required: false);
expectInfo(voidType, 'void Function(int x)', required: false);
expectInfo(voidType, 'void Function<T>(int x)', required: false);
expectComplexInfo('void Function<T>()', required: true);
expectComplexInfo('void Function(int)', required: true);