getOccurrences for 'get' and 'set' keywords.

'get'/'set' keywords are highlighted for analogous accessors.
This commit is contained in:
Daniel Rosenwasser
2014-09-29 14:38:03 -07:00
committed by Daniel Rosenwasser
parent debc6539a0
commit c61be112d9
4 changed files with 126 additions and 0 deletions

View File

@@ -2418,6 +2418,11 @@ module ts {
return getConstructorOccurrences(<ConstructorDeclaration>node.parent);
}
break;
case SyntaxKind.GetKeyword:
case SyntaxKind.SetKeyword:
if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) {
return getGetAndSetOccurrences(<AccessorDeclaration>node.parent);
}
}
return undefined;
@@ -2648,6 +2653,25 @@ module ts {
return map(keywords, getReferenceEntryFromNode);
}
function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): ReferenceEntry[] {
var keywords: Node[] = [];
tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor);
tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor);
return map(keywords, getReferenceEntryFromNode);
function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void {
var accessor = getDeclarationOfKind(accessorSymbol, accessorKind);
if (!accessor) {
return;
}
forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword));
}
}
// returns true if 'node' is defined and has a matching 'kind'.
function hasKind(node: Node, kind: SyntaxKind) {
return node !== undefined && node.kind === kind;