Skip to content

Commit 0e6102a

Browse files
committed
Merge pull request #6927 from RyanCavanaugh/mergeSalsaFixes
Merge salsa fixes
2 parents aaea852 + e4a6b67 commit 0e6102a

File tree

7 files changed

+124
-16
lines changed

7 files changed

+124
-16
lines changed

src/compiler/parser.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,7 +3995,7 @@ namespace ts {
39953995
shorthandDeclaration.equalsToken = equalsToken;
39963996
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
39973997
}
3998-
return finishNode(shorthandDeclaration);
3998+
return addJSDocComment(finishNode(shorthandDeclaration));
39993999
}
40004000
else {
40014001
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
@@ -4004,7 +4004,7 @@ namespace ts {
40044004
propertyAssignment.questionToken = questionToken;
40054005
parseExpected(SyntaxKind.ColonToken);
40064006
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
4007-
return finishNode(propertyAssignment);
4007+
return addJSDocComment(finishNode(propertyAssignment));
40084008
}
40094009
}
40104010

@@ -5758,23 +5758,32 @@ namespace ts {
57585758
function parseJSDocParameter(): ParameterDeclaration {
57595759
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
57605760
parameter.type = parseJSDocType();
5761+
if (parseOptional(SyntaxKind.EqualsToken)) {
5762+
parameter.questionToken = createNode(SyntaxKind.EqualsToken);
5763+
}
57615764
return finishNode(parameter);
57625765
}
57635766

57645767
function parseJSDocTypeReference(): JSDocTypeReference {
57655768
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
57665769
result.name = parseSimplePropertyName();
57675770

5768-
while (parseOptional(SyntaxKind.DotToken)) {
5769-
if (token === SyntaxKind.LessThanToken) {
5770-
result.typeArguments = parseTypeArguments();
5771-
break;
5772-
}
5773-
else {
5774-
result.name = parseQualifiedName(result.name);
5771+
if (token === SyntaxKind.LessThanToken) {
5772+
result.typeArguments = parseTypeArguments();
5773+
}
5774+
else {
5775+
while (parseOptional(SyntaxKind.DotToken)) {
5776+
if (token === SyntaxKind.LessThanToken) {
5777+
result.typeArguments = parseTypeArguments();
5778+
break;
5779+
}
5780+
else {
5781+
result.name = parseQualifiedName(result.name);
5782+
}
57755783
}
57765784
}
57775785

5786+
57785787
return finishNode(result);
57795788
}
57805789

src/compiler/utilities.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,19 @@ namespace ts {
12161216
}
12171217

12181218
// Also recognize when the node is the RHS of an assignment expression
1219+
const parent = node.parent;
12191220
const isSourceOfAssignmentExpressionStatement =
1220-
node.parent && node.parent.parent &&
1221-
node.parent.kind === SyntaxKind.BinaryExpression &&
1222-
(node.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
1223-
node.parent.parent.kind === SyntaxKind.ExpressionStatement;
1221+
parent && parent.parent &&
1222+
parent.kind === SyntaxKind.BinaryExpression &&
1223+
(parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
1224+
parent.parent.kind === SyntaxKind.ExpressionStatement;
12241225
if (isSourceOfAssignmentExpressionStatement) {
1225-
return node.parent.parent.jsDocComment;
1226+
return parent.parent.jsDocComment;
1227+
}
1228+
1229+
const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment;
1230+
if (isPropertyAssignmentExpression) {
1231+
return parent.jsDocComment;
12261232
}
12271233
}
12281234

src/services/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3819,7 +3819,7 @@ namespace ts {
38193819
return undefined;
38203820
}
38213821

3822-
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData;
3822+
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData;
38233823

38243824
if (isJsDocTagName) {
38253825
// If the current position is a jsDoc tag name, only tag names should be provided for completion
@@ -3830,7 +3830,7 @@ namespace ts {
38303830

38313831
const entries: CompletionEntry[] = [];
38323832

3833-
if (isRightOfDot && isSourceFileJavaScript(sourceFile)) {
3833+
if (isSourceFileJavaScript(sourceFile)) {
38343834
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
38353835
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
38363836
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: Foo.js
5+
//// function f() {
6+
//// // helloWorld leaks from here into the global space?
7+
//// if (helloWorld) {
8+
//// return 3;
9+
//// }
10+
//// return 5;
11+
//// }
12+
////
13+
//// hello/**/
14+
15+
verify.completionListContains('helloWorld');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: Foo.js
5+
6+
//// /** @type {function(string, boolean=): number} */
7+
//// var f6;
8+
////
9+
//// f6('', /**/false)
10+
11+
goTo.marker();
12+
verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number')
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: Foo.js
5+
6+
//// var someObject = {
7+
//// /**
8+
//// * @param {string} param1 Some string param.
9+
//// * @param {number} parm2 Some number param.
10+
//// */
11+
//// someMethod: function(param1, param2) {
12+
//// console.log(param1/*1*/);
13+
//// return false;
14+
//// },
15+
//// /**
16+
//// * @param {number} p1 Some number param.
17+
//// */
18+
//// otherMethod(p1) {
19+
//// p1/*2*/
20+
//// }
21+
////
22+
//// };
23+
24+
goTo.marker('1');
25+
edit.insert('.');
26+
verify.memberListContains('substr', undefined, undefined, 'method');
27+
edit.backspace();
28+
29+
goTo.marker('2');
30+
edit.insert('.');
31+
verify.memberListContains('toFixed', undefined, undefined, 'method');
32+
edit.backspace();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: ref.d.ts
5+
//// namespace Thing {
6+
//// export interface Thung {
7+
//// a: number;
8+
//// ]
9+
//// ]
10+
11+
12+
// @Filename: Foo.js
13+
////
14+
//// /** @type {Array<number>} */
15+
//// var v;
16+
//// v[0]./*1*/
17+
////
18+
//// /** @type {{x: Array<Array<number>>}} */
19+
//// var w;
20+
//// w.x[0][0]./*2*/
21+
////
22+
//// /** @type {Array<Thing.Thung>} */
23+
//// var x;
24+
//// x[0].a./*3*/
25+
26+
27+
goTo.marker('1');
28+
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
29+
30+
goTo.marker('2');
31+
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
32+
33+
goTo.marker('3');
34+
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");

0 commit comments

Comments
 (0)