Address code review

This commit is contained in:
Yui T
2015-05-08 17:51:20 -07:00
parent 0bd0b2798c
commit 853edde521
3 changed files with 10 additions and 9 deletions

View File

@@ -441,6 +441,9 @@ module ts {
bindBlockScopedVariableDeclaration(<Declaration>node);
}
else if (isParameterDeclaration(<VariableLikeDeclaration>node)) {
// It is safe to walk up parent chain to find whether the node is a destructing parameter declaration
// because its parent chain has already been set up, since parents are set before descending into children.
//
// If node is a binding element in parameter declaration, we need to use ParameterExcludes.
// Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration
// For example:

View File

@@ -2048,13 +2048,6 @@ module ts {
return resolutionResults.pop();
}
function getRootDeclaration(node: Node): Node {
while (node.kind === SyntaxKind.BindingElement) {
node = node.parent.parent;
}
return node;
}
function getDeclarationContainer(node: Node): Node {
node = getRootDeclaration(node);

View File

@@ -1151,10 +1151,15 @@ module ts {
}
export function isParameterDeclaration(node: VariableLikeDeclaration) {
let root = getRootDeclaration(node);
return root.kind === SyntaxKind.Parameter;
}
export function getRootDeclaration(node: Node): Node {
while (node.kind === SyntaxKind.BindingElement) {
node = <VariableLikeDeclaration>node.parent.parent;
node = node.parent.parent;
}
return node.kind === SyntaxKind.Parameter;
return node;
}
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {