typescript 4.7.0-dev.20220329 → 4.7.0-dev.20220330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/protocol.d.ts +7 -0
- package/lib/tsc.js +53 -35
- package/lib/tsserver.js +364 -152
- package/lib/tsserverlibrary.d.ts +8 -0
- package/lib/tsserverlibrary.js +364 -152
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +364 -152
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +364 -152
- package/lib/typingsInstaller.js +55 -36
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220330";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -47406,7 +47406,8 @@ var ts;
|
|
|
47406
47406
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47407
47407
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47408
47408
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47409
|
-
CheckMode[CheckMode["
|
|
47409
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47410
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47410
47411
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47411
47412
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47412
47413
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47744,26 +47745,10 @@ var ts;
|
|
|
47744
47745
|
if (!node) {
|
|
47745
47746
|
return undefined;
|
|
47746
47747
|
}
|
|
47747
|
-
|
|
47748
|
-
|
|
47749
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47750
|
-
var toMarkSkip = node;
|
|
47751
|
-
do {
|
|
47752
|
-
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47753
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47754
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47755
|
-
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47756
|
-
}
|
|
47757
|
-
var result = getContextualType(node, contextFlags);
|
|
47758
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47759
|
-
var toMarkSkip = node;
|
|
47760
|
-
do {
|
|
47761
|
-
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47762
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47763
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47764
|
-
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47748
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47749
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47765
47750
|
}
|
|
47766
|
-
return
|
|
47751
|
+
return getContextualType(node, contextFlags);
|
|
47767
47752
|
},
|
|
47768
47753
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47769
47754
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47783,6 +47768,9 @@ var ts;
|
|
|
47783
47768
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47784
47769
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47785
47770
|
},
|
|
47771
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47772
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47773
|
+
},
|
|
47786
47774
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47787
47775
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47788
47776
|
},
|
|
@@ -47935,10 +47923,34 @@ var ts;
|
|
|
47935
47923
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47936
47924
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47937
47925
|
};
|
|
47938
|
-
function
|
|
47926
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
47927
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
47928
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
47929
|
+
if (containingCall) {
|
|
47930
|
+
var toMarkSkip = node;
|
|
47931
|
+
do {
|
|
47932
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47933
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47934
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47935
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47936
|
+
}
|
|
47937
|
+
var result = fn();
|
|
47938
|
+
if (containingCall) {
|
|
47939
|
+
var toMarkSkip = node;
|
|
47940
|
+
do {
|
|
47941
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47942
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47943
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47944
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47945
|
+
}
|
|
47946
|
+
return result;
|
|
47947
|
+
}
|
|
47948
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
47939
47949
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
47940
47950
|
apparentArgumentCount = argumentCount;
|
|
47941
|
-
var res = node ?
|
|
47951
|
+
var res = !node ? undefined :
|
|
47952
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
47953
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
47942
47954
|
apparentArgumentCount = undefined;
|
|
47943
47955
|
return res;
|
|
47944
47956
|
}
|
|
@@ -55072,7 +55084,7 @@ var ts;
|
|
|
55072
55084
|
}
|
|
55073
55085
|
/** Return the inferred type for a binding element */
|
|
55074
55086
|
function getTypeForBindingElement(declaration) {
|
|
55075
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55087
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55076
55088
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55077
55089
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55078
55090
|
}
|
|
@@ -68200,7 +68212,7 @@ var ts;
|
|
|
68200
68212
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68201
68213
|
var targetProp = properties_3[_i];
|
|
68202
68214
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68203
|
-
if (sourceProp) {
|
|
68215
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68204
68216
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68205
68217
|
}
|
|
68206
68218
|
}
|
|
@@ -70674,7 +70686,7 @@ var ts;
|
|
|
70674
70686
|
// as we want the type of a rest element to be generic when possible.
|
|
70675
70687
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70676
70688
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70677
|
-
(checkMode && checkMode &
|
|
70689
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70678
70690
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70679
70691
|
: getContextualType(node));
|
|
70680
70692
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -71613,7 +71625,7 @@ var ts;
|
|
|
71613
71625
|
var parent = declaration.parent.parent;
|
|
71614
71626
|
var name = declaration.propertyName || declaration.name;
|
|
71615
71627
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71616
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71628
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71617
71629
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71618
71630
|
return undefined;
|
|
71619
71631
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -74667,7 +74679,7 @@ var ts;
|
|
|
74667
74679
|
}
|
|
74668
74680
|
for (var i = 0; i < argCount; i++) {
|
|
74669
74681
|
var arg = args[i];
|
|
74670
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74682
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74671
74683
|
var paramType = getTypeAtPosition(signature, i);
|
|
74672
74684
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74673
74685
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75352,7 +75364,7 @@ var ts;
|
|
|
75352
75364
|
}
|
|
75353
75365
|
}
|
|
75354
75366
|
}
|
|
75355
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75367
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75356
75368
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75357
75369
|
var _a, _b;
|
|
75358
75370
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75453,14 +75465,14 @@ var ts;
|
|
|
75453
75465
|
}
|
|
75454
75466
|
}
|
|
75455
75467
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75456
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75468
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75457
75469
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75458
75470
|
checkNodeDeferred(node);
|
|
75459
75471
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75460
75472
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75461
75473
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75462
75474
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75463
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75475
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75464
75476
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75465
75477
|
}
|
|
75466
75478
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75508,7 +75520,7 @@ var ts;
|
|
|
75508
75520
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75509
75521
|
return createSymbolWithType(ts.first(sources), type);
|
|
75510
75522
|
}
|
|
75511
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75523
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75512
75524
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75513
75525
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75514
75526
|
// f({ |
|
|
@@ -75524,7 +75536,7 @@ var ts;
|
|
|
75524
75536
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75525
75537
|
var instantiated = typeArgumentNodes
|
|
75526
75538
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75527
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75539
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75528
75540
|
candidates[bestIndex] = instantiated;
|
|
75529
75541
|
return instantiated;
|
|
75530
75542
|
}
|
|
@@ -75538,9 +75550,9 @@ var ts;
|
|
|
75538
75550
|
}
|
|
75539
75551
|
return typeArguments;
|
|
75540
75552
|
}
|
|
75541
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75553
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75542
75554
|
var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
|
|
75543
|
-
var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75555
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75544
75556
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75545
75557
|
}
|
|
75546
75558
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81606,7 +81618,7 @@ var ts;
|
|
|
81606
81618
|
}
|
|
81607
81619
|
// check private/protected variable access
|
|
81608
81620
|
var parent = node.parent.parent;
|
|
81609
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81621
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81610
81622
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81611
81623
|
var name = node.propertyName || node.name;
|
|
81612
81624
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -116704,6 +116716,13 @@ var ts;
|
|
|
116704
116716
|
return "skip";
|
|
116705
116717
|
}
|
|
116706
116718
|
break;
|
|
116719
|
+
case 270 /* ImportSpecifier */:
|
|
116720
|
+
case 275 /* ExportSpecifier */:
|
|
116721
|
+
if (node.isTypeOnly) {
|
|
116722
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116723
|
+
return "skip";
|
|
116724
|
+
}
|
|
116725
|
+
break;
|
|
116707
116726
|
case 265 /* ImportEqualsDeclaration */:
|
|
116708
116727
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116709
116728
|
return "skip";
|
|
@@ -127148,6 +127167,14 @@ var ts;
|
|
|
127148
127167
|
});
|
|
127149
127168
|
}
|
|
127150
127169
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127170
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127171
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127172
|
+
return mapToDisplayParts(function (writer) {
|
|
127173
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127174
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127175
|
+
});
|
|
127176
|
+
}
|
|
127177
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127151
127178
|
function isImportOrExportSpecifierName(location) {
|
|
127152
127179
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127153
127180
|
}
|
|
@@ -129844,12 +129871,13 @@ var ts;
|
|
|
129844
129871
|
}
|
|
129845
129872
|
case 208 /* CallExpression */:
|
|
129846
129873
|
case 209 /* NewExpression */:
|
|
129874
|
+
case 285 /* JsxAttribute */:
|
|
129847
129875
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
129848
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
129876
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
129849
129877
|
// Get string literal completions from specialized signatures of the target
|
|
129850
129878
|
// i.e. declare function f(a: 'A');
|
|
129851
129879
|
// f("/*completion position*/")
|
|
129852
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
129880
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
129853
129881
|
}
|
|
129854
129882
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
129855
129883
|
case 266 /* ImportDeclaration */:
|
|
@@ -129886,15 +129914,22 @@ var ts;
|
|
|
129886
129914
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
129887
129915
|
});
|
|
129888
129916
|
}
|
|
129889
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
129917
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
129890
129918
|
var isNewIdentifier = false;
|
|
129891
129919
|
var uniques = new ts.Map();
|
|
129892
129920
|
var candidates = [];
|
|
129893
|
-
|
|
129921
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
129922
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
129894
129923
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
129895
129924
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
129896
129925
|
return;
|
|
129897
129926
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
129927
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
129928
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
129929
|
+
if (propType) {
|
|
129930
|
+
type = propType;
|
|
129931
|
+
}
|
|
129932
|
+
}
|
|
129898
129933
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
129899
129934
|
return getStringLiteralTypes(type, uniques);
|
|
129900
129935
|
});
|
|
@@ -130437,43 +130472,28 @@ var ts;
|
|
|
130437
130472
|
// Exported only for tests
|
|
130438
130473
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
130439
130474
|
Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000;
|
|
130440
|
-
|
|
130441
|
-
|
|
130442
|
-
|
|
130443
|
-
|
|
130444
|
-
|
|
130445
|
-
|
|
130446
|
-
|
|
130447
|
-
|
|
130448
|
-
|
|
130449
|
-
|
|
130450
|
-
|
|
130451
|
-
|
|
130452
|
-
|
|
130453
|
-
|
|
130454
|
-
|
|
130455
|
-
|
|
130456
|
-
|
|
130457
|
-
|
|
130458
|
-
|
|
130459
|
-
|
|
130460
|
-
|
|
130461
|
-
}
|
|
130462
|
-
var SortTextId;
|
|
130463
|
-
(function (SortTextId) {
|
|
130464
|
-
SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority";
|
|
130465
|
-
SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority";
|
|
130466
|
-
SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember";
|
|
130467
|
-
SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment";
|
|
130468
|
-
SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers";
|
|
130469
|
-
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130470
|
-
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130471
|
-
// Don't use these directly.
|
|
130472
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
130473
|
-
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130474
|
-
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130475
|
-
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130476
|
-
})(SortTextId || (SortTextId = {}));
|
|
130475
|
+
Completions.SortText = {
|
|
130476
|
+
// Presets
|
|
130477
|
+
LocalDeclarationPriority: "10",
|
|
130478
|
+
LocationPriority: "11",
|
|
130479
|
+
OptionalMember: "12",
|
|
130480
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
130481
|
+
SuggestedClassMembers: "14",
|
|
130482
|
+
GlobalsOrKeywords: "15",
|
|
130483
|
+
AutoImportSuggestions: "16",
|
|
130484
|
+
ClassMemberSnippets: "17",
|
|
130485
|
+
JavascriptIdentifiers: "18",
|
|
130486
|
+
// Transformations
|
|
130487
|
+
Deprecated: function (sortText) {
|
|
130488
|
+
return "z" + sortText;
|
|
130489
|
+
},
|
|
130490
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
130491
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
130492
|
+
},
|
|
130493
|
+
SortBelow: function (sortText) {
|
|
130494
|
+
return sortText + "1";
|
|
130495
|
+
},
|
|
130496
|
+
};
|
|
130477
130497
|
/**
|
|
130478
130498
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
130479
130499
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -130493,6 +130513,8 @@ var ts;
|
|
|
130493
130513
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
130494
130514
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
130495
130515
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
130516
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
130517
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
130496
130518
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
130497
130519
|
var SymbolOriginInfoKind;
|
|
130498
130520
|
(function (SymbolOriginInfoKind) {
|
|
@@ -130503,6 +130525,7 @@ var ts;
|
|
|
130503
130525
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
130504
130526
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
130505
130527
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
130528
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
130506
130529
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
130507
130530
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
130508
130531
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -130533,6 +130556,9 @@ var ts;
|
|
|
130533
130556
|
function originIsTypeOnlyAlias(origin) {
|
|
130534
130557
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
130535
130558
|
}
|
|
130559
|
+
function originIsObjectLiteralMethod(origin) {
|
|
130560
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
130561
|
+
}
|
|
130536
130562
|
var KeywordCompletionFilters;
|
|
130537
130563
|
(function (KeywordCompletionFilters) {
|
|
130538
130564
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -130625,7 +130651,7 @@ var ts;
|
|
|
130625
130651
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
130626
130652
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
130627
130653
|
}
|
|
130628
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
130654
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
130629
130655
|
if (!completionData) {
|
|
130630
130656
|
return undefined;
|
|
130631
130657
|
}
|
|
@@ -130723,7 +130749,7 @@ var ts;
|
|
|
130723
130749
|
name: ts.tokenToString(keyword),
|
|
130724
130750
|
kind: "keyword" /* keyword */,
|
|
130725
130751
|
kindModifiers: "" /* none */,
|
|
130726
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
130752
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
130727
130753
|
};
|
|
130728
130754
|
}
|
|
130729
130755
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -130752,7 +130778,7 @@ var ts;
|
|
|
130752
130778
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
130753
130779
|
}
|
|
130754
130780
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
130755
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression,
|
|
130781
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
130756
130782
|
// Verify if the file is JSX language variant
|
|
130757
130783
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
130758
130784
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -130763,7 +130789,7 @@ var ts;
|
|
|
130763
130789
|
var entries = ts.createSortedArray();
|
|
130764
130790
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
130765
130791
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
130766
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
130792
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
130767
130793
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
130768
130794
|
}
|
|
130769
130795
|
else {
|
|
@@ -130771,7 +130797,7 @@ var ts;
|
|
|
130771
130797
|
return undefined;
|
|
130772
130798
|
}
|
|
130773
130799
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
130774
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
130800
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
130775
130801
|
}
|
|
130776
130802
|
if (keywordFilters !== 0 /* None */) {
|
|
130777
130803
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -130852,7 +130878,7 @@ var ts;
|
|
|
130852
130878
|
name: fullClosingTag,
|
|
130853
130879
|
kind: "class" /* classElement */,
|
|
130854
130880
|
kindModifiers: undefined,
|
|
130855
|
-
sortText: SortText.LocationPriority,
|
|
130881
|
+
sortText: Completions.SortText.LocationPriority,
|
|
130856
130882
|
};
|
|
130857
130883
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
130858
130884
|
}
|
|
@@ -130871,7 +130897,7 @@ var ts;
|
|
|
130871
130897
|
name: realName,
|
|
130872
130898
|
kind: "warning" /* warning */,
|
|
130873
130899
|
kindModifiers: "",
|
|
130874
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
130900
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
130875
130901
|
isFromUncheckedFile: true
|
|
130876
130902
|
}, compareCompletionEntries);
|
|
130877
130903
|
}
|
|
@@ -130882,7 +130908,7 @@ var ts;
|
|
|
130882
130908
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
130883
130909
|
}
|
|
130884
130910
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
130885
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
130911
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
130886
130912
|
}
|
|
130887
130913
|
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
130888
130914
|
var _a, _b;
|
|
@@ -130953,12 +130979,21 @@ var ts;
|
|
|
130953
130979
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
130954
130980
|
var importAdder = void 0;
|
|
130955
130981
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
130956
|
-
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
130982
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
130957
130983
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
130958
130984
|
hasAction = true;
|
|
130959
130985
|
source = CompletionSource.ClassMemberSnippet;
|
|
130960
130986
|
}
|
|
130961
130987
|
}
|
|
130988
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
130989
|
+
var importAdder = void 0;
|
|
130990
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, sourceDisplay = origin.sourceDisplay);
|
|
130991
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
130992
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
130993
|
+
if (importAdder.hasFixes()) {
|
|
130994
|
+
hasAction = true;
|
|
130995
|
+
}
|
|
130996
|
+
}
|
|
130962
130997
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
130963
130998
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
130964
130999
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131117,27 +131152,15 @@ var ts;
|
|
|
131117
131152
|
completionNodes.push(node);
|
|
131118
131153
|
}, body, 2 /* Property */, isAbstract);
|
|
131119
131154
|
if (completionNodes.length) {
|
|
131155
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131120
131156
|
replacementSpan = modifiersSpan;
|
|
131121
131157
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131122
131158
|
// and then format the printed text.
|
|
131123
131159
|
if (formatContext) {
|
|
131124
|
-
|
|
131125
|
-
text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
|
|
131126
|
-
getLineAndCharacterOfPosition: function (pos) {
|
|
131127
|
-
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131128
|
-
},
|
|
131129
|
-
};
|
|
131130
|
-
var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131131
|
-
var changes = ts.flatMap(completionNodes, function (node) {
|
|
131132
|
-
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131133
|
-
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
|
|
131134
|
-
/* indentation */ 0,
|
|
131135
|
-
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
|
|
131136
|
-
});
|
|
131137
|
-
insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
|
|
131160
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131138
131161
|
}
|
|
131139
131162
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131140
|
-
insertText = printer.printSnippetList(
|
|
131163
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131141
131164
|
}
|
|
131142
131165
|
}
|
|
131143
131166
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131187,12 +131210,103 @@ var ts;
|
|
|
131187
131210
|
}
|
|
131188
131211
|
return undefined;
|
|
131189
131212
|
}
|
|
131213
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131214
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131215
|
+
var insertText = name;
|
|
131216
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131217
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131218
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131219
|
+
if (!method) {
|
|
131220
|
+
return undefined;
|
|
131221
|
+
}
|
|
131222
|
+
var printer = createSnippetPrinter({
|
|
131223
|
+
removeComments: true,
|
|
131224
|
+
module: options.module,
|
|
131225
|
+
target: options.target,
|
|
131226
|
+
omitTrailingSemicolon: false,
|
|
131227
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131228
|
+
});
|
|
131229
|
+
if (formatContext) {
|
|
131230
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131231
|
+
}
|
|
131232
|
+
else {
|
|
131233
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131234
|
+
}
|
|
131235
|
+
var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131236
|
+
var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
|
|
131237
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
|
|
131238
|
+
}
|
|
131239
|
+
;
|
|
131240
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131241
|
+
var declarations = symbol.getDeclarations();
|
|
131242
|
+
if (!(declarations && declarations.length)) {
|
|
131243
|
+
return undefined;
|
|
131244
|
+
}
|
|
131245
|
+
var checker = program.getTypeChecker();
|
|
131246
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131247
|
+
var declaration = declarations[0];
|
|
131248
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131249
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131250
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131251
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131252
|
+
switch (declaration.kind) {
|
|
131253
|
+
case 166 /* PropertySignature */:
|
|
131254
|
+
case 167 /* PropertyDeclaration */:
|
|
131255
|
+
case 168 /* MethodSignature */:
|
|
131256
|
+
case 169 /* MethodDeclaration */: {
|
|
131257
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131258
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131259
|
+
: type;
|
|
131260
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131261
|
+
// Only offer the completion if there's a single function type component.
|
|
131262
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131263
|
+
if (functionTypes.length === 1) {
|
|
131264
|
+
effectiveType = functionTypes[0];
|
|
131265
|
+
}
|
|
131266
|
+
else {
|
|
131267
|
+
return undefined;
|
|
131268
|
+
}
|
|
131269
|
+
}
|
|
131270
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131271
|
+
if (signatures.length !== 1) {
|
|
131272
|
+
// We don't support overloads in object literals.
|
|
131273
|
+
return undefined;
|
|
131274
|
+
}
|
|
131275
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131276
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131277
|
+
return undefined;
|
|
131278
|
+
}
|
|
131279
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131280
|
+
if (importableReference) {
|
|
131281
|
+
typeNode = importableReference.typeNode;
|
|
131282
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131283
|
+
}
|
|
131284
|
+
var body = void 0;
|
|
131285
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131286
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131287
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131288
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131289
|
+
}
|
|
131290
|
+
else {
|
|
131291
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131292
|
+
}
|
|
131293
|
+
return ts.factory.createMethodDeclaration(
|
|
131294
|
+
/*decorators*/ undefined,
|
|
131295
|
+
/*modifiers*/ undefined,
|
|
131296
|
+
/*asteriskToken*/ undefined, name,
|
|
131297
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131298
|
+
}
|
|
131299
|
+
default:
|
|
131300
|
+
return undefined;
|
|
131301
|
+
}
|
|
131302
|
+
}
|
|
131190
131303
|
function createSnippetPrinter(printerOptions) {
|
|
131191
131304
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131192
131305
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131193
131306
|
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
|
|
131194
131307
|
return {
|
|
131195
131308
|
printSnippetList: printSnippetList,
|
|
131309
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131196
131310
|
};
|
|
131197
131311
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131198
131312
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131200,6 +131314,22 @@ var ts;
|
|
|
131200
131314
|
printer.writeList(format, list, sourceFile, writer);
|
|
131201
131315
|
return writer.getText();
|
|
131202
131316
|
}
|
|
131317
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131318
|
+
var syntheticFile = {
|
|
131319
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131320
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131321
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131322
|
+
},
|
|
131323
|
+
};
|
|
131324
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131325
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131326
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131327
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131328
|
+
/* indentation */ 0,
|
|
131329
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131330
|
+
});
|
|
131331
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131332
|
+
}
|
|
131203
131333
|
}
|
|
131204
131334
|
function originToCompletionEntryData(origin) {
|
|
131205
131335
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131297,7 +131427,7 @@ var ts;
|
|
|
131297
131427
|
return CompletionSource.TypeOnlyAlias;
|
|
131298
131428
|
}
|
|
131299
131429
|
}
|
|
131300
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131430
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
131301
131431
|
var _a;
|
|
131302
131432
|
var start = ts.timestamp();
|
|
131303
131433
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131312,12 +131442,12 @@ var ts;
|
|
|
131312
131442
|
var symbol = symbols[i];
|
|
131313
131443
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131314
131444
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131315
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
131445
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131316
131446
|
continue;
|
|
131317
131447
|
}
|
|
131318
131448
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131319
|
-
var
|
|
131320
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131449
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
131450
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131321
131451
|
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
131322
131452
|
if (!entry) {
|
|
131323
131453
|
continue;
|
|
@@ -131335,7 +131465,7 @@ var ts;
|
|
|
131335
131465
|
has: function (name) { return uniques.has(name); },
|
|
131336
131466
|
add: function (name) { return uniques.set(name, true); },
|
|
131337
131467
|
};
|
|
131338
|
-
function shouldIncludeSymbol(symbol,
|
|
131468
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131339
131469
|
var allFlags = symbol.flags;
|
|
131340
131470
|
if (!ts.isSourceFile(location)) {
|
|
131341
131471
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131357,9 +131487,9 @@ var ts;
|
|
|
131357
131487
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131358
131488
|
if (!!sourceFile.externalModuleIndicator
|
|
131359
131489
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
131360
|
-
&&
|
|
131361
|
-
&& (
|
|
131362
|
-
||
|
|
131490
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
131491
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
131492
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
131363
131493
|
return false;
|
|
131364
131494
|
}
|
|
131365
131495
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -131399,7 +131529,7 @@ var ts;
|
|
|
131399
131529
|
name: name,
|
|
131400
131530
|
kindModifiers: "" /* none */,
|
|
131401
131531
|
kind: "label" /* label */,
|
|
131402
|
-
sortText: SortText.LocationPriority
|
|
131532
|
+
sortText: Completions.SortText.LocationPriority
|
|
131403
131533
|
});
|
|
131404
131534
|
}
|
|
131405
131535
|
}
|
|
@@ -131425,7 +131555,7 @@ var ts;
|
|
|
131425
131555
|
}
|
|
131426
131556
|
}
|
|
131427
131557
|
var compilerOptions = program.getCompilerOptions();
|
|
131428
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131558
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
131429
131559
|
if (!completionData) {
|
|
131430
131560
|
return { type: "none" };
|
|
131431
131561
|
}
|
|
@@ -131443,7 +131573,9 @@ var ts;
|
|
|
131443
131573
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
131444
131574
|
var origin = symbolToOriginInfoMap[index];
|
|
131445
131575
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
131446
|
-
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
131576
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
131577
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
131578
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
131447
131579
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
131448
131580
|
: undefined;
|
|
131449
131581
|
}) || { type: "none" };
|
|
@@ -131525,6 +131657,20 @@ var ts;
|
|
|
131525
131657
|
};
|
|
131526
131658
|
}
|
|
131527
131659
|
}
|
|
131660
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
131661
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
131662
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
131663
|
+
if (importAdder.hasFixes()) {
|
|
131664
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
131665
|
+
return {
|
|
131666
|
+
sourceDisplay: undefined,
|
|
131667
|
+
codeActions: [{
|
|
131668
|
+
changes: changes,
|
|
131669
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
131670
|
+
}],
|
|
131671
|
+
};
|
|
131672
|
+
}
|
|
131673
|
+
}
|
|
131528
131674
|
if (originIsTypeOnlyAlias(origin)) {
|
|
131529
131675
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
131530
131676
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -131617,8 +131763,9 @@ var ts;
|
|
|
131617
131763
|
var _a;
|
|
131618
131764
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
131619
131765
|
}
|
|
131620
|
-
function getCompletionData(program, log, sourceFile,
|
|
131766
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
131621
131767
|
var typeChecker = program.getTypeChecker();
|
|
131768
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
131622
131769
|
var start = ts.timestamp();
|
|
131623
131770
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
131624
131771
|
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
|
|
@@ -131861,7 +132008,7 @@ var ts;
|
|
|
131861
132008
|
// This also gets mutated in nested-functions after the return
|
|
131862
132009
|
var symbols = [];
|
|
131863
132010
|
var symbolToOriginInfoMap = [];
|
|
131864
|
-
var
|
|
132011
|
+
var symbolToSortTextMap = [];
|
|
131865
132012
|
var seenPropertySymbols = new ts.Map();
|
|
131866
132013
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
131867
132014
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -131916,7 +132063,7 @@ var ts;
|
|
|
131916
132063
|
contextToken: contextToken,
|
|
131917
132064
|
isJsxInitializer: isJsxInitializer,
|
|
131918
132065
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
131919
|
-
|
|
132066
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
131920
132067
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
131921
132068
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
131922
132069
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132030,7 +132177,7 @@ var ts;
|
|
|
132030
132177
|
isNewIdentifierLocation = true;
|
|
132031
132178
|
}
|
|
132032
132179
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132033
|
-
if (
|
|
132180
|
+
if (inUncheckedFile) {
|
|
132034
132181
|
// In javascript files, for union types, we don't just get the members that
|
|
132035
132182
|
// the individual types have in common, we also include all the members that
|
|
132036
132183
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132115,7 +132262,7 @@ var ts;
|
|
|
132115
132262
|
}
|
|
132116
132263
|
function addSymbolSortInfo(symbol) {
|
|
132117
132264
|
if (isStaticProperty(symbol)) {
|
|
132118
|
-
|
|
132265
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132119
132266
|
}
|
|
132120
132267
|
}
|
|
132121
132268
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132225,7 +132372,7 @@ var ts;
|
|
|
132225
132372
|
var symbol = symbols[i];
|
|
132226
132373
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132227
132374
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132228
|
-
|
|
132375
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132229
132376
|
}
|
|
132230
132377
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132231
132378
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132243,7 +132390,7 @@ var ts;
|
|
|
132243
132390
|
var symbol = _a[_i];
|
|
132244
132391
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132245
132392
|
symbols.push(symbol);
|
|
132246
|
-
|
|
132393
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132247
132394
|
}
|
|
132248
132395
|
}
|
|
132249
132396
|
}
|
|
@@ -132321,7 +132468,7 @@ var ts;
|
|
|
132321
132468
|
}
|
|
132322
132469
|
return false;
|
|
132323
132470
|
}
|
|
132324
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
132471
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132325
132472
|
function collectAutoImports() {
|
|
132326
132473
|
var _a, _b;
|
|
132327
132474
|
if (!shouldOfferImportCompletions())
|
|
@@ -132403,14 +132550,55 @@ var ts;
|
|
|
132403
132550
|
}
|
|
132404
132551
|
function pushAutoImportSymbol(symbol, origin) {
|
|
132405
132552
|
var symbolId = ts.getSymbolId(symbol);
|
|
132406
|
-
if (
|
|
132553
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
132407
132554
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
132408
132555
|
return;
|
|
132409
132556
|
}
|
|
132410
132557
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132411
|
-
|
|
132558
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
132412
132559
|
symbols.push(symbol);
|
|
132413
132560
|
}
|
|
132561
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
132562
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
132563
|
+
// TODO: support JS files.
|
|
132564
|
+
if (ts.isInJSFile(location)) {
|
|
132565
|
+
return;
|
|
132566
|
+
}
|
|
132567
|
+
members.forEach(function (member) {
|
|
132568
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
132569
|
+
return;
|
|
132570
|
+
}
|
|
132571
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
132572
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
132573
|
+
/*jsxIdentifierExpected*/ false);
|
|
132574
|
+
if (!displayName) {
|
|
132575
|
+
return;
|
|
132576
|
+
}
|
|
132577
|
+
var name = displayName.name;
|
|
132578
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
132579
|
+
if (!entryProps) {
|
|
132580
|
+
return;
|
|
132581
|
+
}
|
|
132582
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
132583
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132584
|
+
symbols.push(member);
|
|
132585
|
+
});
|
|
132586
|
+
}
|
|
132587
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
132588
|
+
/*
|
|
132589
|
+
For an object type
|
|
132590
|
+
`type Foo = {
|
|
132591
|
+
bar(x: number): void;
|
|
132592
|
+
foo: (x: string) => string;
|
|
132593
|
+
}`,
|
|
132594
|
+
`bar` will have symbol flag `Method`,
|
|
132595
|
+
`foo` will have symbol flag `Property`.
|
|
132596
|
+
*/
|
|
132597
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
132598
|
+
return false;
|
|
132599
|
+
}
|
|
132600
|
+
return true;
|
|
132601
|
+
}
|
|
132414
132602
|
/**
|
|
132415
132603
|
* Finds the first node that "embraces" the position, so that one may
|
|
132416
132604
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -132544,6 +132732,7 @@ var ts;
|
|
|
132544
132732
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
132545
132733
|
*/
|
|
132546
132734
|
function tryGetObjectLikeCompletionSymbols() {
|
|
132735
|
+
var symbolsStartIndex = symbols.length;
|
|
132547
132736
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132548
132737
|
if (!objectLikeContainer)
|
|
132549
132738
|
return 0 /* Continue */;
|
|
@@ -132608,9 +132797,16 @@ var ts;
|
|
|
132608
132797
|
}
|
|
132609
132798
|
if (typeMembers && typeMembers.length > 0) {
|
|
132610
132799
|
// Add filtered items to the completion list
|
|
132611
|
-
|
|
132800
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
132801
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
132802
|
+
setSortTextToOptionalMember();
|
|
132803
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
132804
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
132805
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
132806
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
132807
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
132808
|
+
}
|
|
132612
132809
|
}
|
|
132613
|
-
setSortTextToOptionalMember();
|
|
132614
132810
|
return 1 /* Success */;
|
|
132615
132811
|
}
|
|
132616
132812
|
/**
|
|
@@ -132685,7 +132881,7 @@ var ts;
|
|
|
132685
132881
|
var _a, _b;
|
|
132686
132882
|
symbols.push(symbol);
|
|
132687
132883
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
132688
|
-
|
|
132884
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
132689
132885
|
}
|
|
132690
132886
|
});
|
|
132691
132887
|
return 1 /* Success */;
|
|
@@ -132740,29 +132936,6 @@ var ts;
|
|
|
132740
132936
|
}
|
|
132741
132937
|
return 1 /* Success */;
|
|
132742
132938
|
}
|
|
132743
|
-
/**
|
|
132744
|
-
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
132745
|
-
* on the condition that one exists and that the context implies completion should be given.
|
|
132746
|
-
*/
|
|
132747
|
-
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
132748
|
-
if (contextToken) {
|
|
132749
|
-
var parent = contextToken.parent;
|
|
132750
|
-
switch (contextToken.kind) {
|
|
132751
|
-
case 18 /* OpenBraceToken */: // const x = { |
|
|
132752
|
-
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
132753
|
-
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
132754
|
-
return parent;
|
|
132755
|
-
}
|
|
132756
|
-
break;
|
|
132757
|
-
case 41 /* AsteriskToken */:
|
|
132758
|
-
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
132759
|
-
case 79 /* Identifier */:
|
|
132760
|
-
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
132761
|
-
? contextToken.parent.parent : undefined;
|
|
132762
|
-
}
|
|
132763
|
-
}
|
|
132764
|
-
return undefined;
|
|
132765
|
-
}
|
|
132766
132939
|
function isConstructorParameterCompletion(node) {
|
|
132767
132940
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
132768
132941
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133099,7 +133272,7 @@ var ts;
|
|
|
133099
133272
|
var _a;
|
|
133100
133273
|
if (m.flags & 16777216 /* Optional */) {
|
|
133101
133274
|
var symbolId = ts.getSymbolId(m);
|
|
133102
|
-
|
|
133275
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133103
133276
|
}
|
|
133104
133277
|
});
|
|
133105
133278
|
}
|
|
@@ -133111,7 +133284,23 @@ var ts;
|
|
|
133111
133284
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133112
133285
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133113
133286
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133114
|
-
|
|
133287
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133288
|
+
}
|
|
133289
|
+
}
|
|
133290
|
+
}
|
|
133291
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133292
|
+
var _a;
|
|
133293
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133294
|
+
var symbol = symbols[i];
|
|
133295
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133296
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133297
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133298
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133299
|
+
/*jsxIdentifierExpected*/ false);
|
|
133300
|
+
if (displayName) {
|
|
133301
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133302
|
+
var name = displayName.name;
|
|
133303
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133115
133304
|
}
|
|
133116
133305
|
}
|
|
133117
133306
|
}
|
|
@@ -133185,6 +133374,29 @@ var ts;
|
|
|
133185
133374
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133186
133375
|
}
|
|
133187
133376
|
}
|
|
133377
|
+
/**
|
|
133378
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133379
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
133380
|
+
*/
|
|
133381
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133382
|
+
if (contextToken) {
|
|
133383
|
+
var parent = contextToken.parent;
|
|
133384
|
+
switch (contextToken.kind) {
|
|
133385
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
133386
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133387
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133388
|
+
return parent;
|
|
133389
|
+
}
|
|
133390
|
+
break;
|
|
133391
|
+
case 41 /* AsteriskToken */:
|
|
133392
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
133393
|
+
case 79 /* Identifier */:
|
|
133394
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
133395
|
+
? contextToken.parent.parent : undefined;
|
|
133396
|
+
}
|
|
133397
|
+
}
|
|
133398
|
+
return undefined;
|
|
133399
|
+
}
|
|
133188
133400
|
function getRelevantTokens(position, sourceFile) {
|
|
133189
133401
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133190
133402
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133250,7 +133462,7 @@ var ts;
|
|
|
133250
133462
|
name: ts.tokenToString(i),
|
|
133251
133463
|
kind: "keyword" /* keyword */,
|
|
133252
133464
|
kindModifiers: "" /* none */,
|
|
133253
|
-
sortText: SortText.GlobalsOrKeywords
|
|
133465
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133254
133466
|
});
|
|
133255
133467
|
}
|
|
133256
133468
|
return res;
|
|
@@ -133378,7 +133590,7 @@ var ts;
|
|
|
133378
133590
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
133379
133591
|
kind: "keyword" /* keyword */,
|
|
133380
133592
|
kindModifiers: "" /* none */,
|
|
133381
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
133593
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
133382
133594
|
});
|
|
133383
133595
|
}
|
|
133384
133596
|
}
|