mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Merge pull request #6927 from RyanCavanaugh/mergeSalsaFixes
Merge salsa fixes
This commit is contained in:
commit
0e6102a6d2
@ -3995,7 +3995,7 @@ namespace ts {
|
||||
shorthandDeclaration.equalsToken = equalsToken;
|
||||
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
||||
}
|
||||
return finishNode(shorthandDeclaration);
|
||||
return addJSDocComment(finishNode(shorthandDeclaration));
|
||||
}
|
||||
else {
|
||||
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
|
||||
@ -4004,7 +4004,7 @@ namespace ts {
|
||||
propertyAssignment.questionToken = questionToken;
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
||||
return finishNode(propertyAssignment);
|
||||
return addJSDocComment(finishNode(propertyAssignment));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5758,6 +5758,9 @@ namespace ts {
|
||||
function parseJSDocParameter(): ParameterDeclaration {
|
||||
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
|
||||
parameter.type = parseJSDocType();
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
parameter.questionToken = createNode(SyntaxKind.EqualsToken);
|
||||
}
|
||||
return finishNode(parameter);
|
||||
}
|
||||
|
||||
@ -5765,16 +5768,22 @@ namespace ts {
|
||||
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
||||
result.name = parseSimplePropertyName();
|
||||
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
if (token === SyntaxKind.LessThanToken) {
|
||||
result.typeArguments = parseTypeArguments();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
result.name = parseQualifiedName(result.name);
|
||||
if (token === SyntaxKind.LessThanToken) {
|
||||
result.typeArguments = parseTypeArguments();
|
||||
}
|
||||
else {
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
if (token === SyntaxKind.LessThanToken) {
|
||||
result.typeArguments = parseTypeArguments();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
result.name = parseQualifiedName(result.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
|
||||
@ -1216,13 +1216,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Also recognize when the node is the RHS of an assignment expression
|
||||
const parent = node.parent;
|
||||
const isSourceOfAssignmentExpressionStatement =
|
||||
node.parent && node.parent.parent &&
|
||||
node.parent.kind === SyntaxKind.BinaryExpression &&
|
||||
(node.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
|
||||
node.parent.parent.kind === SyntaxKind.ExpressionStatement;
|
||||
parent && parent.parent &&
|
||||
parent.kind === SyntaxKind.BinaryExpression &&
|
||||
(parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
|
||||
parent.parent.kind === SyntaxKind.ExpressionStatement;
|
||||
if (isSourceOfAssignmentExpressionStatement) {
|
||||
return node.parent.parent.jsDocComment;
|
||||
return parent.parent.jsDocComment;
|
||||
}
|
||||
|
||||
const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment;
|
||||
if (isPropertyAssignmentExpression) {
|
||||
return parent.jsDocComment;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3819,7 +3819,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData;
|
||||
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData;
|
||||
|
||||
if (isJsDocTagName) {
|
||||
// If the current position is a jsDoc tag name, only tag names should be provided for completion
|
||||
@ -3830,7 +3830,7 @@ namespace ts {
|
||||
|
||||
const entries: CompletionEntry[] = [];
|
||||
|
||||
if (isRightOfDot && isSourceFileJavaScript(sourceFile)) {
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
|
||||
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
|
||||
}
|
||||
|
||||
15
tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts
Normal file
15
tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: Foo.js
|
||||
//// function f() {
|
||||
//// // helloWorld leaks from here into the global space?
|
||||
//// if (helloWorld) {
|
||||
//// return 3;
|
||||
//// }
|
||||
//// return 5;
|
||||
//// }
|
||||
////
|
||||
//// hello/**/
|
||||
|
||||
verify.completionListContains('helloWorld');
|
||||
12
tests/cases/fourslash/jsDocFunctionSignatures2.ts
Normal file
12
tests/cases/fourslash/jsDocFunctionSignatures2.ts
Normal file
@ -0,0 +1,12 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: Foo.js
|
||||
|
||||
//// /** @type {function(string, boolean=): number} */
|
||||
//// var f6;
|
||||
////
|
||||
//// f6('', /**/false)
|
||||
|
||||
goTo.marker();
|
||||
verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number')
|
||||
32
tests/cases/fourslash/jsDocFunctionSignatures3.ts
Normal file
32
tests/cases/fourslash/jsDocFunctionSignatures3.ts
Normal file
@ -0,0 +1,32 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: Foo.js
|
||||
|
||||
//// var someObject = {
|
||||
//// /**
|
||||
//// * @param {string} param1 Some string param.
|
||||
//// * @param {number} parm2 Some number param.
|
||||
//// */
|
||||
//// someMethod: function(param1, param2) {
|
||||
//// console.log(param1/*1*/);
|
||||
//// return false;
|
||||
//// },
|
||||
//// /**
|
||||
//// * @param {number} p1 Some number param.
|
||||
//// */
|
||||
//// otherMethod(p1) {
|
||||
//// p1/*2*/
|
||||
//// }
|
||||
////
|
||||
//// };
|
||||
|
||||
goTo.marker('1');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('substr', undefined, undefined, 'method');
|
||||
edit.backspace();
|
||||
|
||||
goTo.marker('2');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('toFixed', undefined, undefined, 'method');
|
||||
edit.backspace();
|
||||
34
tests/cases/fourslash/jsDocGenerics1.ts
Normal file
34
tests/cases/fourslash/jsDocGenerics1.ts
Normal file
@ -0,0 +1,34 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: ref.d.ts
|
||||
//// namespace Thing {
|
||||
//// export interface Thung {
|
||||
//// a: number;
|
||||
//// ]
|
||||
//// ]
|
||||
|
||||
|
||||
// @Filename: Foo.js
|
||||
////
|
||||
//// /** @type {Array<number>} */
|
||||
//// var v;
|
||||
//// v[0]./*1*/
|
||||
////
|
||||
//// /** @type {{x: Array<Array<number>>}} */
|
||||
//// var w;
|
||||
//// w.x[0][0]./*2*/
|
||||
////
|
||||
//// /** @type {Array<Thing.Thung>} */
|
||||
//// var x;
|
||||
//// x[0].a./*3*/
|
||||
|
||||
|
||||
goTo.marker('1');
|
||||
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
|
||||
|
||||
goTo.marker('3');
|
||||
verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method");
|
||||
Loading…
x
Reference in New Issue
Block a user