Skip to content

Commit 6f42e41

Browse files
committed
Apply suggested fixes to arguments PR
1 parent 2b3da9a commit 6f42e41

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13809,7 +13809,7 @@ namespace ts {
1380913809
if (location.locals && !isGlobalSourceFile(location)) {
1381013810
copySymbols(location.locals, meaning);
1381113811
}
13812-
13812+
1381313813
switch (location.kind) {
1381413814
case SyntaxKind.SourceFile:
1381513815
if (!isExternalModule(<SourceFile>location)) {
@@ -13845,9 +13845,11 @@ namespace ts {
1384513845
}
1384613846
break;
1384713847
}
13848-
if (isFunctionLike(location)) {
13848+
13849+
if (introducesArgumentsExoticObject(location)) {
1384913850
copySymbol(argumentsSymbol, meaning);
1385013851
}
13852+
1385113853
memberFlags = location.flags;
1385213854
location = location.parent;
1385313855
}

src/compiler/utilities.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ namespace ts {
420420
}
421421

422422
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
423-
let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode);
423+
let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ?
424+
concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
425+
getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) :
426+
getLeadingCommentRangesOfNode(node, sourceFileOfNode);
424427
return filter(commentRanges, isJsDocComment);
425428

426429
function isJsDocComment(comment: CommentRange) {
@@ -638,6 +641,20 @@ namespace ts {
638641
return false;
639642
}
640643

644+
export function introducesArgumentsExoticObject(node: Node) {
645+
switch (node.kind) {
646+
case SyntaxKind.MethodDeclaration:
647+
case SyntaxKind.MethodSignature:
648+
case SyntaxKind.Constructor:
649+
case SyntaxKind.GetAccessor:
650+
case SyntaxKind.SetAccessor:
651+
case SyntaxKind.FunctionDeclaration:
652+
case SyntaxKind.FunctionExpression:
653+
return true;
654+
}
655+
return false;
656+
}
657+
641658
export function isFunctionBlock(node: Node) {
642659
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
643660
}

tests/cases/fourslash/completionInsideFunctionContainsArguments.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
////function testNestedArguments() {
66
//// function nestedfunction(){/*3*/}
77
////}
8+
////function f() {
9+
//// let g = () => /*4*/
10+
////}
11+
////let g = () => /*5*/
812

913
goTo.marker('1');
1014
verify.completionListContains("arguments");
1115
goTo.marker('2');
1216
verify.not.completionListContains("arguments");
1317
goTo.marker('3');
14-
verify.completionListContains("arguments");
18+
verify.completionListContains("arguments");
19+
goTo.marker('4');
20+
verify.completionListContains("arguments");
21+
goTo.marker('5');
22+
verify.not.completionListContains("arguments");

0 commit comments

Comments
 (0)