mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Implemented getOccsAtPos for try-catch-finally.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user