Skip to content

Commit 7b5440b

Browse files
Addressed more CR feedback.
1 parent 837ddda commit 7b5440b

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7113,15 +7113,4 @@ module ts {
71137113

71147114
return checker;
71157115
}
7116-
7117-
export function getContainingFunction(node: Node): SignatureDeclaration {
7118-
while (true) {
7119-
node = node.parent;
7120-
if (!node || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression ||
7121-
node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.Method || node.kind === SyntaxKind.Constructor ||
7122-
node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
7123-
return <SignatureDeclaration>node;
7124-
}
7125-
}
7126-
}
71277116
}

src/compiler/parser.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,32 @@ module ts {
380380
}
381381
}
382382

383+
export function isAnyFunction(node: Node): boolean {
384+
if (node) {
385+
switch (node.kind) {
386+
case SyntaxKind.FunctionExpression:
387+
case SyntaxKind.FunctionDeclaration:
388+
case SyntaxKind.ArrowFunction:
389+
case SyntaxKind.Method:
390+
case SyntaxKind.GetAccessor:
391+
case SyntaxKind.SetAccessor:
392+
case SyntaxKind.Constructor:
393+
return true;
394+
}
395+
}
396+
397+
return false;
398+
}
399+
400+
export function getContainingFunction(node: Node): SignatureDeclaration {
401+
while (true) {
402+
node = node.parent;
403+
if (!node || isAnyFunction(node)) {
404+
return <SignatureDeclaration>node;
405+
}
406+
}
407+
}
408+
383409
export function hasRestParameters(s: SignatureDeclaration): boolean {
384410
return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & NodeFlags.Rest) !== 0;
385411
}

src/services/services.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,24 +1312,6 @@ module ts {
13121312
return node.parent.kind === SyntaxKind.NewExpression && (<CallExpression>node.parent).func === node;
13131313
}
13141314

1315-
function isAnyFunction(node: Node): boolean {
1316-
if (!node) {
1317-
return false;
1318-
}
1319-
1320-
switch (node.kind) {
1321-
case SyntaxKind.FunctionExpression:
1322-
case SyntaxKind.FunctionDeclaration:
1323-
case SyntaxKind.ArrowFunction:
1324-
case SyntaxKind.Method:
1325-
case SyntaxKind.GetAccessor:
1326-
case SyntaxKind.SetAccessor:
1327-
case SyntaxKind.Constructor:
1328-
return true;
1329-
}
1330-
return false;
1331-
}
1332-
13331315
function isNameOfFunctionDeclaration(node: Node): boolean {
13341316
return node.kind === SyntaxKind.Identifier &&
13351317
isAnyFunction(node.parent) && (<FunctionDeclaration>node.parent).name === node;
@@ -2274,7 +2256,7 @@ module ts {
22742256
var func = <FunctionDeclaration>getContainingFunction(returnStatement);
22752257

22762258
// If we didn't find a containing function with a block body, bail out.
2277-
if (!(isAnyFunction(func) && hasKind(func.body, SyntaxKind.FunctionBlock))) {
2259+
if (!(func && hasKind(func.body, SyntaxKind.FunctionBlock))) {
22782260
return undefined;
22792261
}
22802262

0 commit comments

Comments
 (0)