Skip to content

Commit 387da2f

Browse files
committed
Merge pull request microsoft#4347 from Schmavery/master
Add `arguments` to completion list microsoft#4249
2 parents e86f207 + 6f42e41 commit 387da2f

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

src/compiler/checker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13845,7 +13845,11 @@ namespace ts {
1384513845
}
1384613846
break;
1384713847
}
13848-
13848+
13849+
if (introducesArgumentsExoticObject(location)) {
13850+
copySymbol(argumentsSymbol, meaning);
13851+
}
13852+
1384913853
memberFlags = location.flags;
1385013854
location = location.parent;
1385113855
}

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
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////function testArguments() {/*1*/}
4+
/////*2*/
5+
////function testNestedArguments() {
6+
//// function nestedfunction(){/*3*/}
7+
////}
8+
////function f() {
9+
//// let g = () => /*4*/
10+
////}
11+
////let g = () => /*5*/
12+
13+
goTo.marker('1');
14+
verify.completionListContains("arguments");
15+
goTo.marker('2');
16+
verify.not.completionListContains("arguments");
17+
goTo.marker('3');
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)