Apply suggested fixes to arguments PR

This commit is contained in:
Schmavery 2015-08-17 18:33:48 -07:00
parent 2b3da9a49e
commit 6f42e4164b
3 changed files with 31 additions and 4 deletions

View File

@ -13809,7 +13809,7 @@ namespace ts {
if (location.locals && !isGlobalSourceFile(location)) {
copySymbols(location.locals, meaning);
}
switch (location.kind) {
case SyntaxKind.SourceFile:
if (!isExternalModule(<SourceFile>location)) {
@ -13845,9 +13845,11 @@ namespace ts {
}
break;
}
if (isFunctionLike(location)) {
if (introducesArgumentsExoticObject(location)) {
copySymbol(argumentsSymbol, meaning);
}
memberFlags = location.flags;
location = location.parent;
}

View File

@ -420,7 +420,10 @@ namespace ts {
}
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode);
let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ?
concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) :
getLeadingCommentRangesOfNode(node, sourceFileOfNode);
return filter(commentRanges, isJsDocComment);
function isJsDocComment(comment: CommentRange) {
@ -638,6 +641,20 @@ namespace ts {
return false;
}
export function introducesArgumentsExoticObject(node: Node) {
switch (node.kind) {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
return true;
}
return false;
}
export function isFunctionBlock(node: Node) {
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
}

View File

@ -5,10 +5,18 @@
////function testNestedArguments() {
//// function nestedfunction(){/*3*/}
////}
////function f() {
//// let g = () => /*4*/
////}
////let g = () => /*5*/
goTo.marker('1');
verify.completionListContains("arguments");
goTo.marker('2');
verify.not.completionListContains("arguments");
goTo.marker('3');
verify.completionListContains("arguments");
verify.completionListContains("arguments");
goTo.marker('4');
verify.completionListContains("arguments");
goTo.marker('5');
verify.not.completionListContains("arguments");