Skip to content

Commit 0ce39a3

Browse files
Addressed CR feedback.
1 parent 04456a2 commit 0ce39a3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/services/services.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,36 +2167,33 @@ module ts {
21672167
return getReferencesForNode(node, [sourceFile]);
21682168
}
21692169

2170-
var result: ReferenceEntry[];
2171-
2172-
// 'parent' and 'hasKind' are falsey-propagating convenience functions.
21732170
switch (node.kind) {
21742171
case SyntaxKind.TryKeyword:
21752172
case SyntaxKind.CatchKeyword:
21762173
case SyntaxKind.FinallyKeyword:
21772174
if (hasKind(parent(parent(node)), SyntaxKind.TryStatement)) {
2178-
result = getTryCatchFinallyOccurrences(<TryStatement>(node.parent.parent));
2175+
return getTryCatchFinallyOccurrences(<TryStatement>node.parent.parent);
21792176
}
21802177
break;
21812178
case SyntaxKind.SwitchKeyword:
21822179
if (hasKind(node.parent, SyntaxKind.SwitchStatement)) {
2183-
result = getSwitchCaseDefaultOccurrences(<SwitchStatement>node.parent);
2180+
return getSwitchCaseDefaultOccurrences(<SwitchStatement>node.parent);
21842181
}
21852182
break;
21862183
case SyntaxKind.CaseKeyword:
21872184
case SyntaxKind.DefaultKeyword:
21882185
if (hasKind(parent(parent(node)), SyntaxKind.SwitchStatement)) {
2189-
result = getSwitchCaseDefaultOccurrences(<SwitchStatement>(node.parent.parent));
2186+
return getSwitchCaseDefaultOccurrences(<SwitchStatement>node.parent.parent);
21902187
}
21912188
break;
21922189
case SyntaxKind.BreakKeyword:
21932190
if (hasKind(node.parent, SyntaxKind.BreakStatement)) {
2194-
result = getBreakStatementOccurences(<BreakOrContinueStatement>node.parent);
2191+
return getBreakStatementOccurences(<BreakOrContinueStatement>node.parent);
21952192
}
21962193
break;
21972194
}
21982195

2199-
return result;
2196+
return undefined;
22002197

22012198
function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
22022199
var keywords: Node[] = [];
@@ -2221,7 +2218,7 @@ module ts {
22212218

22222219
// Go through each clause in the switch statement, collecting the clause keywords.
22232220
forEach(switchStatement.clauses, clause => {
2224-
pushKeyword(keywords, clause.getFirstToken(), [SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword]);
2221+
pushKeyword(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword);
22252222

22262223
// For each clause, also recursively traverse the statements where we can find analogous breaks.
22272224
forEachChild(clause, function aggregateBreakKeywords(node: Node): void {
@@ -2288,18 +2285,16 @@ module ts {
22882285
return node && node.parent;
22892286
}
22902287

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 {
22942289
if (!token) {
22952290
return;
22962291
}
22972292

2298-
if (token.kind === expected || (expected.length && contains(<SyntaxKind[]>expected, token.kind))) {
2293+
if (contains(<SyntaxKind[]>expected, token.kind)) {
22992294
keywordList.push(token);
23002295
}
23012296
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.");
23032298
}
23042299
}
23052300

0 commit comments

Comments
 (0)