mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added getOccs support for return keywords.
This commit is contained in:
@@ -2174,6 +2174,11 @@ module ts {
|
||||
return getIfElseOccurrences(<IfStatement>node.parent);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ReturnKeyword:
|
||||
if (hasKind(node.parent, SyntaxKind.ReturnStatement)) {
|
||||
return getReturnOccurrences(<ReturnStatement>node.parent);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.TryKeyword:
|
||||
case SyntaxKind.CatchKeyword:
|
||||
case SyntaxKind.FinallyKeyword:
|
||||
@@ -2261,6 +2266,25 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[]{
|
||||
var node: Node = returnStatement;
|
||||
while (!isAnyFunction(node) && node.parent) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
// If we didn't find a containing function with a block body, bail out.
|
||||
if (!(isAnyFunction(node) && hasKind((<FunctionDeclaration>node).body, SyntaxKind.FunctionBlock))) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var keywords: Node[] = []
|
||||
forEachReturnStatement(<Block>(<FunctionDeclaration>node).body, returnStmt => {
|
||||
pushKeywordIf(keywords, returnStmt.getFirstToken(), SyntaxKind.ReturnKeyword);
|
||||
});
|
||||
|
||||
return map(keywords, keywordToReferenceEntry);
|
||||
}
|
||||
|
||||
function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
|
||||
var keywords: Node[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user