mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
getOccurrences for 'get' and 'set' keywords.
'get'/'set' keywords are highlighted for analogous accessors.
This commit is contained in:
committed by
Daniel Rosenwasser
parent
debc6539a0
commit
c61be112d9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user