@@ -1161,7 +1161,7 @@ module ts {
1161
1161
case ParsingContext . SwitchClauses :
1162
1162
return token === SyntaxKind . CaseKeyword || token === SyntaxKind . DefaultKeyword ;
1163
1163
case ParsingContext . TypeMembers :
1164
- return isTypeMember ( ) ;
1164
+ return isStartOfTypeMember ( ) ;
1165
1165
case ParsingContext . ClassMembers :
1166
1166
return lookAhead ( isClassMemberStart ) ;
1167
1167
case ParsingContext . EnumMembers :
@@ -1173,14 +1173,14 @@ module ts {
1173
1173
case ParsingContext . TypeParameters :
1174
1174
return isIdentifier ( ) ;
1175
1175
case ParsingContext . ArgumentExpressions :
1176
- return token === SyntaxKind . CommaToken || isExpression ( ) ;
1176
+ return token === SyntaxKind . CommaToken || isStartOfExpression ( ) ;
1177
1177
case ParsingContext . ArrayLiteralMembers :
1178
- return token === SyntaxKind . CommaToken || isExpression ( ) ;
1178
+ return token === SyntaxKind . CommaToken || isStartOfExpression ( ) ;
1179
1179
case ParsingContext . Parameters :
1180
- return isParameter ( ) ;
1180
+ return isStartOfParameter ( ) ;
1181
1181
case ParsingContext . TypeArguments :
1182
1182
case ParsingContext . TupleElementTypes :
1183
- return token === SyntaxKind . CommaToken || isType ( ) ;
1183
+ return token === SyntaxKind . CommaToken || isStartOfType ( ) ;
1184
1184
}
1185
1185
1186
1186
Debug . fail ( "Non-exhaustive case in 'isListElement'." ) ;
@@ -1505,7 +1505,7 @@ module ts {
1505
1505
// user writes a constraint that is an expression and not an actual type, then parse
1506
1506
// it out as an expression (so we can recover well), but report that a type is needed
1507
1507
// instead.
1508
- if ( isType ( ) || ! isExpression ( ) ) {
1508
+ if ( isStartOfType ( ) || ! isStartOfExpression ( ) ) {
1509
1509
node . constraint = parseType ( ) ;
1510
1510
}
1511
1511
else {
@@ -1541,7 +1541,7 @@ module ts {
1541
1541
return parseOptional ( SyntaxKind . ColonToken ) ? token === SyntaxKind . StringLiteral ? parseStringLiteral ( ) : parseType ( ) : undefined ;
1542
1542
}
1543
1543
1544
- function isParameter ( ) : boolean {
1544
+ function isStartOfParameter ( ) : boolean {
1545
1545
return token === SyntaxKind . DotDotDotToken || isIdentifier ( ) || isModifier ( token ) ;
1546
1546
}
1547
1547
@@ -1749,7 +1749,7 @@ module ts {
1749
1749
return finishNode ( node ) ;
1750
1750
}
1751
1751
1752
- function isTypeMember ( ) : boolean {
1752
+ function isStartOfTypeMember ( ) : boolean {
1753
1753
switch ( token ) {
1754
1754
case SyntaxKind . OpenParenToken :
1755
1755
case SyntaxKind . LessThanToken :
@@ -1856,7 +1856,7 @@ module ts {
1856
1856
return < TypeNode > createMissingNode ( ) ;
1857
1857
}
1858
1858
1859
- function isType ( ) : boolean {
1859
+ function isStartOfType ( ) : boolean {
1860
1860
switch ( token ) {
1861
1861
case SyntaxKind . AnyKeyword :
1862
1862
case SyntaxKind . StringKeyword :
@@ -1874,7 +1874,7 @@ module ts {
1874
1874
// or something that starts a type. We don't want to consider things like '(1)' a type.
1875
1875
return lookAhead ( ( ) => {
1876
1876
nextToken ( ) ;
1877
- return token === SyntaxKind . CloseParenToken || isParameter ( ) || isType ( ) ;
1877
+ return token === SyntaxKind . CloseParenToken || isStartOfParameter ( ) || isStartOfType ( ) ;
1878
1878
} ) ;
1879
1879
default :
1880
1880
return isIdentifier ( ) ;
@@ -1908,7 +1908,7 @@ module ts {
1908
1908
return type ;
1909
1909
}
1910
1910
1911
- function isFunctionType ( ) : boolean {
1911
+ function isStartOfFunctionType ( ) : boolean {
1912
1912
return token === SyntaxKind . LessThanToken || token === SyntaxKind . OpenParenToken && lookAhead ( ( ) => {
1913
1913
nextToken ( ) ;
1914
1914
if ( token === SyntaxKind . CloseParenToken || token === SyntaxKind . DotDotDotToken ) {
@@ -1941,7 +1941,7 @@ module ts {
1941
1941
}
1942
1942
1943
1943
function parseType ( ) : TypeNode {
1944
- if ( isFunctionType ( ) ) {
1944
+ if ( isStartOfFunctionType ( ) ) {
1945
1945
return parseFunctionType ( SyntaxKind . CallSignature ) ;
1946
1946
}
1947
1947
if ( token === SyntaxKind . NewKeyword ) {
@@ -1956,7 +1956,7 @@ module ts {
1956
1956
1957
1957
// EXPRESSIONS
1958
1958
1959
- function isExpression ( ) : boolean {
1959
+ function isStartOfExpression ( ) : boolean {
1960
1960
switch ( token ) {
1961
1961
case SyntaxKind . ThisKeyword :
1962
1962
case SyntaxKind . SuperKeyword :
@@ -1991,9 +1991,9 @@ module ts {
1991
1991
}
1992
1992
}
1993
1993
1994
- function isExpressionStatement ( ) : boolean {
1994
+ function isStartOfExpressionStatement ( ) : boolean {
1995
1995
// As per the grammar, neither '{' nor 'function' can start an expression statement.
1996
- return token !== SyntaxKind . OpenBraceToken && token !== SyntaxKind . FunctionKeyword && isExpression ( ) ;
1996
+ return token !== SyntaxKind . OpenBraceToken && token !== SyntaxKind . FunctionKeyword && isStartOfExpression ( ) ;
1997
1997
}
1998
1998
1999
1999
function parseExpression ( noIn ?: boolean ) : Expression {
@@ -2014,7 +2014,7 @@ module ts {
2014
2014
// it's more likely that a { would be a allowed (as an object literal). While this
2015
2015
// is also allowed for parameters, the risk is that we consume the { as an object
2016
2016
// literal when it really will be for the block following the parameter.
2017
- if ( scanner . hasPrecedingLineBreak ( ) || ( inParameter && token === SyntaxKind . OpenBraceToken ) || ! isExpression ( ) ) {
2017
+ if ( scanner . hasPrecedingLineBreak ( ) || ( inParameter && token === SyntaxKind . OpenBraceToken ) || ! isStartOfExpression ( ) ) {
2018
2018
// preceding line break, open brace in a parameter (likely a function body) or current token is not an expression -
2019
2019
// do not try to parse initializer
2020
2020
return undefined ;
@@ -2262,7 +2262,7 @@ module ts {
2262
2262
if ( token === SyntaxKind . OpenBraceToken ) {
2263
2263
body = parseBody ( /* ignoreMissingOpenBrace */ false ) ;
2264
2264
}
2265
- else if ( isStatement ( /* inErrorRecovery */ true ) && ! isExpressionStatement ( ) && token !== SyntaxKind . FunctionKeyword ) {
2265
+ else if ( isStatement ( /* inErrorRecovery */ true ) && ! isStartOfExpressionStatement ( ) && token !== SyntaxKind . FunctionKeyword ) {
2266
2266
// Check if we got a plain statement (i.e. no expression-statements, no functions expressions/declarations)
2267
2267
//
2268
2268
// Here we try to recover from a potential error situation in the case where the
@@ -3267,7 +3267,7 @@ module ts {
3267
3267
case SyntaxKind . EnumKeyword :
3268
3268
// When followed by an identifier, these do not start a statement but might
3269
3269
// instead be following declarations
3270
- if ( isDeclaration ( ) ) {
3270
+ if ( isDeclarationStart ( ) ) {
3271
3271
return false ;
3272
3272
}
3273
3273
case SyntaxKind . PublicKeyword :
@@ -3280,7 +3280,7 @@ module ts {
3280
3280
return false ;
3281
3281
}
3282
3282
default :
3283
- return isExpression ( ) ;
3283
+ return isStartOfExpression ( ) ;
3284
3284
}
3285
3285
}
3286
3286
@@ -3993,7 +3993,7 @@ module ts {
3993
3993
return finishNode ( node ) ;
3994
3994
}
3995
3995
3996
- function isDeclaration ( ) : boolean {
3996
+ function isDeclarationStart ( ) : boolean {
3997
3997
switch ( token ) {
3998
3998
case SyntaxKind . VarKeyword :
3999
3999
case SyntaxKind . LetKeyword :
@@ -4011,14 +4011,14 @@ module ts {
4011
4011
return lookAhead ( ( ) => nextToken ( ) >= SyntaxKind . Identifier || token === SyntaxKind . StringLiteral ) ;
4012
4012
case SyntaxKind . ExportKeyword :
4013
4013
// Check for export assignment or modifier on source element
4014
- return lookAhead ( ( ) => nextToken ( ) === SyntaxKind . EqualsToken || isDeclaration ( ) ) ;
4014
+ return lookAhead ( ( ) => nextToken ( ) === SyntaxKind . EqualsToken || isDeclarationStart ( ) ) ;
4015
4015
case SyntaxKind . DeclareKeyword :
4016
4016
case SyntaxKind . PublicKeyword :
4017
4017
case SyntaxKind . PrivateKeyword :
4018
4018
case SyntaxKind . ProtectedKeyword :
4019
4019
case SyntaxKind . StaticKeyword :
4020
4020
// Check for modifier on source element
4021
- return lookAhead ( ( ) => { nextToken ( ) ; return isDeclaration ( ) ; } ) ;
4021
+ return lookAhead ( ( ) => { nextToken ( ) ; return isDeclarationStart ( ) ; } ) ;
4022
4022
}
4023
4023
}
4024
4024
@@ -4079,7 +4079,7 @@ module ts {
4079
4079
}
4080
4080
4081
4081
function isSourceElement ( inErrorRecovery : boolean ) : boolean {
4082
- return isDeclaration ( ) || isStatement ( inErrorRecovery ) ;
4082
+ return isDeclarationStart ( ) || isStatement ( inErrorRecovery ) ;
4083
4083
}
4084
4084
4085
4085
function parseSourceElement ( ) {
@@ -4091,7 +4091,7 @@ module ts {
4091
4091
}
4092
4092
4093
4093
function parseSourceElementOrModuleElement ( modifierContext : ModifierContext ) : Statement {
4094
- if ( isDeclaration ( ) ) {
4094
+ if ( isDeclarationStart ( ) ) {
4095
4095
return parseDeclaration ( modifierContext ) ;
4096
4096
}
4097
4097
0 commit comments