@@ -2167,36 +2167,33 @@ module ts {
2167
2167
return getReferencesForNode ( node , [ sourceFile ] ) ;
2168
2168
}
2169
2169
2170
- var result : ReferenceEntry [ ] ;
2171
-
2172
- // 'parent' and 'hasKind' are falsey-propagating convenience functions.
2173
2170
switch ( node . kind ) {
2174
2171
case SyntaxKind . TryKeyword :
2175
2172
case SyntaxKind . CatchKeyword :
2176
2173
case SyntaxKind . FinallyKeyword :
2177
2174
if ( hasKind ( parent ( parent ( node ) ) , SyntaxKind . TryStatement ) ) {
2178
- result = getTryCatchFinallyOccurrences ( < TryStatement > ( node . parent . parent ) ) ;
2175
+ return getTryCatchFinallyOccurrences ( < TryStatement > node . parent . parent ) ;
2179
2176
}
2180
2177
break ;
2181
2178
case SyntaxKind . SwitchKeyword :
2182
2179
if ( hasKind ( node . parent , SyntaxKind . SwitchStatement ) ) {
2183
- result = getSwitchCaseDefaultOccurrences ( < SwitchStatement > node . parent ) ;
2180
+ return getSwitchCaseDefaultOccurrences ( < SwitchStatement > node . parent ) ;
2184
2181
}
2185
2182
break ;
2186
2183
case SyntaxKind . CaseKeyword :
2187
2184
case SyntaxKind . DefaultKeyword :
2188
2185
if ( hasKind ( parent ( parent ( node ) ) , SyntaxKind . SwitchStatement ) ) {
2189
- result = getSwitchCaseDefaultOccurrences ( < SwitchStatement > ( node . parent . parent ) ) ;
2186
+ return getSwitchCaseDefaultOccurrences ( < SwitchStatement > node . parent . parent ) ;
2190
2187
}
2191
2188
break ;
2192
2189
case SyntaxKind . BreakKeyword :
2193
2190
if ( hasKind ( node . parent , SyntaxKind . BreakStatement ) ) {
2194
- result = getBreakStatementOccurences ( < BreakOrContinueStatement > node . parent ) ;
2191
+ return getBreakStatementOccurences ( < BreakOrContinueStatement > node . parent ) ;
2195
2192
}
2196
2193
break ;
2197
2194
}
2198
2195
2199
- return result ;
2196
+ return undefined ;
2200
2197
2201
2198
function getTryCatchFinallyOccurrences ( tryStatement : TryStatement ) : ReferenceEntry [ ] {
2202
2199
var keywords : Node [ ] = [ ] ;
@@ -2221,7 +2218,7 @@ module ts {
2221
2218
2222
2219
// Go through each clause in the switch statement, collecting the clause keywords.
2223
2220
forEach ( switchStatement . clauses , clause => {
2224
- pushKeyword ( keywords , clause . getFirstToken ( ) , [ SyntaxKind . CaseKeyword , SyntaxKind . DefaultKeyword ] ) ;
2221
+ pushKeyword ( keywords , clause . getFirstToken ( ) , SyntaxKind . CaseKeyword , SyntaxKind . DefaultKeyword ) ;
2225
2222
2226
2223
// For each clause, also recursively traverse the statements where we can find analogous breaks.
2227
2224
forEachChild ( clause , function aggregateBreakKeywords ( node : Node ) : void {
@@ -2288,18 +2285,16 @@ module ts {
2288
2285
return node && node . parent ;
2289
2286
}
2290
2287
2291
- function pushKeyword ( keywordList : Node [ ] , token : Node , expected : SyntaxKind ) : void ;
2292
- function pushKeyword ( keywordList : Node [ ] , token : Node , expected : SyntaxKind [ ] ) : void ;
2293
- function pushKeyword ( keywordList : Node [ ] , token : Node , expected : any ) : void {
2288
+ function pushKeyword ( keywordList : Node [ ] , token : Node , ...expected : SyntaxKind [ ] ) : void {
2294
2289
if ( ! token ) {
2295
2290
return ;
2296
2291
}
2297
2292
2298
- if ( token . kind === expected || ( expected . length && contains ( < SyntaxKind [ ] > expected , token . kind ) ) ) {
2293
+ if ( contains ( < SyntaxKind [ ] > expected , token . kind ) ) {
2299
2294
keywordList . push ( token ) ;
2300
2295
}
2301
2296
else {
2302
- Debug . assert ( "Expected keyword, got " + token . getFullText ( ) . substring ( token . getLeadingTriviaWidth ( ) ) ) ;
2297
+ Debug . assert ( "Got ' " + token . getFullText ( ) . substring ( token . getLeadingTriviaWidth ( ) ) + "' instead of expected keyword." ) ;
2303
2298
}
2304
2299
}
2305
2300
0 commit comments