Implemented getOccsAtPos for try-catch-finally.

This commit is contained in:
Daniel Rosenwasser
2014-08-26 11:48:31 -07:00
parent 5d15cd22b1
commit 558be4ea22
4 changed files with 101 additions and 0 deletions

View File

@@ -2169,10 +2169,30 @@ module ts {
}
switch (node.kind) {
case SyntaxKind.TryKeyword:
case SyntaxKind.CatchKeyword:
case SyntaxKind.FinallyKeyword:
return getTryCatchFinallyOccurrences(<TryStatement>node.parent.parent);
}
return undefined;
function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
var keywords: Node[] = [];
keywords.push(tryStatement.getFirstToken())
if (tryStatement.catchBlock) {
keywords.push(tryStatement.catchBlock.getFirstToken());
}
if (tryStatement.finallyBlock) {
keywords.push(tryStatement.finallyBlock.getFirstToken());
}
return keywordsToReferenceEntries(keywords);
}
function keywordsToReferenceEntries(keywords: Node[]): ReferenceEntry[]{
return keywords.map(keyword =>
new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(keyword.getStart(), keyword.end), /* isWriteAccess */ false)