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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220330";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -47600,7 +47600,8 @@ var ts;
|
|
|
47600
47600
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47601
47601
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47602
47602
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47603
|
-
CheckMode[CheckMode["
|
|
47603
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47604
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47604
47605
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47605
47606
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47606
47607
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47938,26 +47939,10 @@ var ts;
|
|
|
47938
47939
|
if (!node) {
|
|
47939
47940
|
return undefined;
|
|
47940
47941
|
}
|
|
47941
|
-
|
|
47942
|
-
|
|
47943
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47944
|
-
var toMarkSkip = node;
|
|
47945
|
-
do {
|
|
47946
|
-
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47947
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47948
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47949
|
-
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47950
|
-
}
|
|
47951
|
-
var result = getContextualType(node, contextFlags);
|
|
47952
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47953
|
-
var toMarkSkip = node;
|
|
47954
|
-
do {
|
|
47955
|
-
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47956
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47957
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47958
|
-
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47942
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47943
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47959
47944
|
}
|
|
47960
|
-
return
|
|
47945
|
+
return getContextualType(node, contextFlags);
|
|
47961
47946
|
},
|
|
47962
47947
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47963
47948
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47977,6 +47962,9 @@ var ts;
|
|
|
47977
47962
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47978
47963
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47979
47964
|
},
|
|
47965
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47966
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47967
|
+
},
|
|
47980
47968
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47981
47969
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47982
47970
|
},
|
|
@@ -48129,10 +48117,34 @@ var ts;
|
|
|
48129
48117
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
48130
48118
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
48131
48119
|
};
|
|
48132
|
-
function
|
|
48120
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
48121
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
48122
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
48123
|
+
if (containingCall) {
|
|
48124
|
+
var toMarkSkip = node;
|
|
48125
|
+
do {
|
|
48126
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
48127
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48128
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48129
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
48130
|
+
}
|
|
48131
|
+
var result = fn();
|
|
48132
|
+
if (containingCall) {
|
|
48133
|
+
var toMarkSkip = node;
|
|
48134
|
+
do {
|
|
48135
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
48136
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48137
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48138
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
48139
|
+
}
|
|
48140
|
+
return result;
|
|
48141
|
+
}
|
|
48142
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
48133
48143
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
48134
48144
|
apparentArgumentCount = argumentCount;
|
|
48135
|
-
var res = node ?
|
|
48145
|
+
var res = !node ? undefined :
|
|
48146
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
48147
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
48136
48148
|
apparentArgumentCount = undefined;
|
|
48137
48149
|
return res;
|
|
48138
48150
|
}
|
|
@@ -55266,7 +55278,7 @@ var ts;
|
|
|
55266
55278
|
}
|
|
55267
55279
|
/** Return the inferred type for a binding element */
|
|
55268
55280
|
function getTypeForBindingElement(declaration) {
|
|
55269
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55281
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55270
55282
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55271
55283
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55272
55284
|
}
|
|
@@ -68394,7 +68406,7 @@ var ts;
|
|
|
68394
68406
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68395
68407
|
var targetProp = properties_3[_i];
|
|
68396
68408
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68397
|
-
if (sourceProp) {
|
|
68409
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68398
68410
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68399
68411
|
}
|
|
68400
68412
|
}
|
|
@@ -70868,7 +70880,7 @@ var ts;
|
|
|
70868
70880
|
// as we want the type of a rest element to be generic when possible.
|
|
70869
70881
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70870
70882
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70871
|
-
(checkMode && checkMode &
|
|
70883
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70872
70884
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70873
70885
|
: getContextualType(node));
|
|
70874
70886
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -71807,7 +71819,7 @@ var ts;
|
|
|
71807
71819
|
var parent = declaration.parent.parent;
|
|
71808
71820
|
var name = declaration.propertyName || declaration.name;
|
|
71809
71821
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71810
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71822
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71811
71823
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71812
71824
|
return undefined;
|
|
71813
71825
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -74861,7 +74873,7 @@ var ts;
|
|
|
74861
74873
|
}
|
|
74862
74874
|
for (var i = 0; i < argCount; i++) {
|
|
74863
74875
|
var arg = args[i];
|
|
74864
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74876
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74865
74877
|
var paramType = getTypeAtPosition(signature, i);
|
|
74866
74878
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74867
74879
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75546,7 +75558,7 @@ var ts;
|
|
|
75546
75558
|
}
|
|
75547
75559
|
}
|
|
75548
75560
|
}
|
|
75549
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75561
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75550
75562
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75551
75563
|
var _a, _b;
|
|
75552
75564
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75647,14 +75659,14 @@ var ts;
|
|
|
75647
75659
|
}
|
|
75648
75660
|
}
|
|
75649
75661
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75650
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75662
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75651
75663
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75652
75664
|
checkNodeDeferred(node);
|
|
75653
75665
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75654
75666
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75655
75667
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75656
75668
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75657
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75669
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75658
75670
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75659
75671
|
}
|
|
75660
75672
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75702,7 +75714,7 @@ var ts;
|
|
|
75702
75714
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75703
75715
|
return createSymbolWithType(ts.first(sources), type);
|
|
75704
75716
|
}
|
|
75705
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75717
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75706
75718
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75707
75719
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75708
75720
|
// f({ |
|
|
@@ -75718,7 +75730,7 @@ var ts;
|
|
|
75718
75730
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75719
75731
|
var instantiated = typeArgumentNodes
|
|
75720
75732
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75721
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75733
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75722
75734
|
candidates[bestIndex] = instantiated;
|
|
75723
75735
|
return instantiated;
|
|
75724
75736
|
}
|
|
@@ -75732,9 +75744,9 @@ var ts;
|
|
|
75732
75744
|
}
|
|
75733
75745
|
return typeArguments;
|
|
75734
75746
|
}
|
|
75735
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75747
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75736
75748
|
var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
|
|
75737
|
-
var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75749
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75738
75750
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75739
75751
|
}
|
|
75740
75752
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81800,7 +81812,7 @@ var ts;
|
|
|
81800
81812
|
}
|
|
81801
81813
|
// check private/protected variable access
|
|
81802
81814
|
var parent = node.parent.parent;
|
|
81803
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81815
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81804
81816
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81805
81817
|
var name = node.propertyName || node.name;
|
|
81806
81818
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -116898,6 +116910,13 @@ var ts;
|
|
|
116898
116910
|
return "skip";
|
|
116899
116911
|
}
|
|
116900
116912
|
break;
|
|
116913
|
+
case 270 /* ImportSpecifier */:
|
|
116914
|
+
case 275 /* ExportSpecifier */:
|
|
116915
|
+
if (node.isTypeOnly) {
|
|
116916
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116917
|
+
return "skip";
|
|
116918
|
+
}
|
|
116919
|
+
break;
|
|
116901
116920
|
case 265 /* ImportEqualsDeclaration */:
|
|
116902
116921
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116903
116922
|
return "skip";
|
|
@@ -127759,6 +127778,14 @@ var ts;
|
|
|
127759
127778
|
});
|
|
127760
127779
|
}
|
|
127761
127780
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127781
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127782
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127783
|
+
return mapToDisplayParts(function (writer) {
|
|
127784
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127785
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127786
|
+
});
|
|
127787
|
+
}
|
|
127788
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127762
127789
|
function isImportOrExportSpecifierName(location) {
|
|
127763
127790
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127764
127791
|
}
|
|
@@ -130455,12 +130482,13 @@ var ts;
|
|
|
130455
130482
|
}
|
|
130456
130483
|
case 208 /* CallExpression */:
|
|
130457
130484
|
case 209 /* NewExpression */:
|
|
130485
|
+
case 285 /* JsxAttribute */:
|
|
130458
130486
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
130459
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
130487
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
130460
130488
|
// Get string literal completions from specialized signatures of the target
|
|
130461
130489
|
// i.e. declare function f(a: 'A');
|
|
130462
130490
|
// f("/*completion position*/")
|
|
130463
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
130491
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
130464
130492
|
}
|
|
130465
130493
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
130466
130494
|
case 266 /* ImportDeclaration */:
|
|
@@ -130497,15 +130525,22 @@ var ts;
|
|
|
130497
130525
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
130498
130526
|
});
|
|
130499
130527
|
}
|
|
130500
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
130528
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
130501
130529
|
var isNewIdentifier = false;
|
|
130502
130530
|
var uniques = new ts.Map();
|
|
130503
130531
|
var candidates = [];
|
|
130504
|
-
|
|
130532
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
130533
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
130505
130534
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
130506
130535
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
130507
130536
|
return;
|
|
130508
130537
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
130538
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
130539
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
130540
|
+
if (propType) {
|
|
130541
|
+
type = propType;
|
|
130542
|
+
}
|
|
130543
|
+
}
|
|
130509
130544
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
130510
130545
|
return getStringLiteralTypes(type, uniques);
|
|
130511
130546
|
});
|
|
@@ -131048,43 +131083,28 @@ var ts;
|
|
|
131048
131083
|
// Exported only for tests
|
|
131049
131084
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
131050
131085
|
Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000;
|
|
131051
|
-
|
|
131052
|
-
|
|
131053
|
-
|
|
131054
|
-
|
|
131055
|
-
|
|
131056
|
-
|
|
131057
|
-
|
|
131058
|
-
|
|
131059
|
-
|
|
131060
|
-
|
|
131061
|
-
|
|
131062
|
-
|
|
131063
|
-
|
|
131064
|
-
|
|
131065
|
-
|
|
131066
|
-
|
|
131067
|
-
|
|
131068
|
-
|
|
131069
|
-
|
|
131070
|
-
|
|
131071
|
-
|
|
131072
|
-
}
|
|
131073
|
-
var SortTextId;
|
|
131074
|
-
(function (SortTextId) {
|
|
131075
|
-
SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority";
|
|
131076
|
-
SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority";
|
|
131077
|
-
SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember";
|
|
131078
|
-
SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment";
|
|
131079
|
-
SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers";
|
|
131080
|
-
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
131081
|
-
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
131082
|
-
// Don't use these directly.
|
|
131083
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
131084
|
-
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
131085
|
-
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
131086
|
-
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
131087
|
-
})(SortTextId || (SortTextId = {}));
|
|
131086
|
+
Completions.SortText = {
|
|
131087
|
+
// Presets
|
|
131088
|
+
LocalDeclarationPriority: "10",
|
|
131089
|
+
LocationPriority: "11",
|
|
131090
|
+
OptionalMember: "12",
|
|
131091
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
131092
|
+
SuggestedClassMembers: "14",
|
|
131093
|
+
GlobalsOrKeywords: "15",
|
|
131094
|
+
AutoImportSuggestions: "16",
|
|
131095
|
+
ClassMemberSnippets: "17",
|
|
131096
|
+
JavascriptIdentifiers: "18",
|
|
131097
|
+
// Transformations
|
|
131098
|
+
Deprecated: function (sortText) {
|
|
131099
|
+
return "z" + sortText;
|
|
131100
|
+
},
|
|
131101
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
131102
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
131103
|
+
},
|
|
131104
|
+
SortBelow: function (sortText) {
|
|
131105
|
+
return sortText + "1";
|
|
131106
|
+
},
|
|
131107
|
+
};
|
|
131088
131108
|
/**
|
|
131089
131109
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
131090
131110
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -131104,6 +131124,8 @@ var ts;
|
|
|
131104
131124
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
131105
131125
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
131106
131126
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
131127
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
131128
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
131107
131129
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
131108
131130
|
var SymbolOriginInfoKind;
|
|
131109
131131
|
(function (SymbolOriginInfoKind) {
|
|
@@ -131114,6 +131136,7 @@ var ts;
|
|
|
131114
131136
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
131115
131137
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
131116
131138
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
131139
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
131117
131140
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
131118
131141
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
131119
131142
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -131144,6 +131167,9 @@ var ts;
|
|
|
131144
131167
|
function originIsTypeOnlyAlias(origin) {
|
|
131145
131168
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
131146
131169
|
}
|
|
131170
|
+
function originIsObjectLiteralMethod(origin) {
|
|
131171
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
131172
|
+
}
|
|
131147
131173
|
var KeywordCompletionFilters;
|
|
131148
131174
|
(function (KeywordCompletionFilters) {
|
|
131149
131175
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -131236,7 +131262,7 @@ var ts;
|
|
|
131236
131262
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
131237
131263
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
131238
131264
|
}
|
|
131239
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131265
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
131240
131266
|
if (!completionData) {
|
|
131241
131267
|
return undefined;
|
|
131242
131268
|
}
|
|
@@ -131334,7 +131360,7 @@ var ts;
|
|
|
131334
131360
|
name: ts.tokenToString(keyword),
|
|
131335
131361
|
kind: "keyword" /* keyword */,
|
|
131336
131362
|
kindModifiers: "" /* none */,
|
|
131337
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
131363
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
131338
131364
|
};
|
|
131339
131365
|
}
|
|
131340
131366
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -131363,7 +131389,7 @@ var ts;
|
|
|
131363
131389
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
131364
131390
|
}
|
|
131365
131391
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
131366
|
-
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,
|
|
131392
|
+
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;
|
|
131367
131393
|
// Verify if the file is JSX language variant
|
|
131368
131394
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
131369
131395
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -131374,7 +131400,7 @@ var ts;
|
|
|
131374
131400
|
var entries = ts.createSortedArray();
|
|
131375
131401
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
131376
131402
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
131377
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131403
|
+
/*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);
|
|
131378
131404
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
131379
131405
|
}
|
|
131380
131406
|
else {
|
|
@@ -131382,7 +131408,7 @@ var ts;
|
|
|
131382
131408
|
return undefined;
|
|
131383
131409
|
}
|
|
131384
131410
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
131385
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131411
|
+
/*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);
|
|
131386
131412
|
}
|
|
131387
131413
|
if (keywordFilters !== 0 /* None */) {
|
|
131388
131414
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -131463,7 +131489,7 @@ var ts;
|
|
|
131463
131489
|
name: fullClosingTag,
|
|
131464
131490
|
kind: "class" /* classElement */,
|
|
131465
131491
|
kindModifiers: undefined,
|
|
131466
|
-
sortText: SortText.LocationPriority,
|
|
131492
|
+
sortText: Completions.SortText.LocationPriority,
|
|
131467
131493
|
};
|
|
131468
131494
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
131469
131495
|
}
|
|
@@ -131482,7 +131508,7 @@ var ts;
|
|
|
131482
131508
|
name: realName,
|
|
131483
131509
|
kind: "warning" /* warning */,
|
|
131484
131510
|
kindModifiers: "",
|
|
131485
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
131511
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
131486
131512
|
isFromUncheckedFile: true
|
|
131487
131513
|
}, compareCompletionEntries);
|
|
131488
131514
|
}
|
|
@@ -131493,7 +131519,7 @@ var ts;
|
|
|
131493
131519
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
131494
131520
|
}
|
|
131495
131521
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
131496
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
131522
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
131497
131523
|
}
|
|
131498
131524
|
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
131499
131525
|
var _a, _b;
|
|
@@ -131564,12 +131590,21 @@ var ts;
|
|
|
131564
131590
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131565
131591
|
var importAdder = void 0;
|
|
131566
131592
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
131567
|
-
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131593
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131568
131594
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131569
131595
|
hasAction = true;
|
|
131570
131596
|
source = CompletionSource.ClassMemberSnippet;
|
|
131571
131597
|
}
|
|
131572
131598
|
}
|
|
131599
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131600
|
+
var importAdder = void 0;
|
|
131601
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, sourceDisplay = origin.sourceDisplay);
|
|
131602
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131603
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
131604
|
+
if (importAdder.hasFixes()) {
|
|
131605
|
+
hasAction = true;
|
|
131606
|
+
}
|
|
131607
|
+
}
|
|
131573
131608
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131574
131609
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
131575
131610
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131728,27 +131763,15 @@ var ts;
|
|
|
131728
131763
|
completionNodes.push(node);
|
|
131729
131764
|
}, body, 2 /* Property */, isAbstract);
|
|
131730
131765
|
if (completionNodes.length) {
|
|
131766
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131731
131767
|
replacementSpan = modifiersSpan;
|
|
131732
131768
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131733
131769
|
// and then format the printed text.
|
|
131734
131770
|
if (formatContext) {
|
|
131735
|
-
|
|
131736
|
-
text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
|
|
131737
|
-
getLineAndCharacterOfPosition: function (pos) {
|
|
131738
|
-
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131739
|
-
},
|
|
131740
|
-
};
|
|
131741
|
-
var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131742
|
-
var changes = ts.flatMap(completionNodes, function (node) {
|
|
131743
|
-
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131744
|
-
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
|
|
131745
|
-
/* indentation */ 0,
|
|
131746
|
-
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
|
|
131747
|
-
});
|
|
131748
|
-
insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
|
|
131771
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131749
131772
|
}
|
|
131750
131773
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131751
|
-
insertText = printer.printSnippetList(
|
|
131774
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131752
131775
|
}
|
|
131753
131776
|
}
|
|
131754
131777
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131798,12 +131821,103 @@ var ts;
|
|
|
131798
131821
|
}
|
|
131799
131822
|
return undefined;
|
|
131800
131823
|
}
|
|
131824
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131825
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131826
|
+
var insertText = name;
|
|
131827
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131828
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131829
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131830
|
+
if (!method) {
|
|
131831
|
+
return undefined;
|
|
131832
|
+
}
|
|
131833
|
+
var printer = createSnippetPrinter({
|
|
131834
|
+
removeComments: true,
|
|
131835
|
+
module: options.module,
|
|
131836
|
+
target: options.target,
|
|
131837
|
+
omitTrailingSemicolon: false,
|
|
131838
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131839
|
+
});
|
|
131840
|
+
if (formatContext) {
|
|
131841
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131842
|
+
}
|
|
131843
|
+
else {
|
|
131844
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131845
|
+
}
|
|
131846
|
+
var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131847
|
+
var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
|
|
131848
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
|
|
131849
|
+
}
|
|
131850
|
+
;
|
|
131851
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131852
|
+
var declarations = symbol.getDeclarations();
|
|
131853
|
+
if (!(declarations && declarations.length)) {
|
|
131854
|
+
return undefined;
|
|
131855
|
+
}
|
|
131856
|
+
var checker = program.getTypeChecker();
|
|
131857
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131858
|
+
var declaration = declarations[0];
|
|
131859
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131860
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131861
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131862
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131863
|
+
switch (declaration.kind) {
|
|
131864
|
+
case 166 /* PropertySignature */:
|
|
131865
|
+
case 167 /* PropertyDeclaration */:
|
|
131866
|
+
case 168 /* MethodSignature */:
|
|
131867
|
+
case 169 /* MethodDeclaration */: {
|
|
131868
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131869
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131870
|
+
: type;
|
|
131871
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131872
|
+
// Only offer the completion if there's a single function type component.
|
|
131873
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131874
|
+
if (functionTypes.length === 1) {
|
|
131875
|
+
effectiveType = functionTypes[0];
|
|
131876
|
+
}
|
|
131877
|
+
else {
|
|
131878
|
+
return undefined;
|
|
131879
|
+
}
|
|
131880
|
+
}
|
|
131881
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131882
|
+
if (signatures.length !== 1) {
|
|
131883
|
+
// We don't support overloads in object literals.
|
|
131884
|
+
return undefined;
|
|
131885
|
+
}
|
|
131886
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131887
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131888
|
+
return undefined;
|
|
131889
|
+
}
|
|
131890
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131891
|
+
if (importableReference) {
|
|
131892
|
+
typeNode = importableReference.typeNode;
|
|
131893
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131894
|
+
}
|
|
131895
|
+
var body = void 0;
|
|
131896
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131897
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131898
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131899
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131900
|
+
}
|
|
131901
|
+
else {
|
|
131902
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131903
|
+
}
|
|
131904
|
+
return ts.factory.createMethodDeclaration(
|
|
131905
|
+
/*decorators*/ undefined,
|
|
131906
|
+
/*modifiers*/ undefined,
|
|
131907
|
+
/*asteriskToken*/ undefined, name,
|
|
131908
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131909
|
+
}
|
|
131910
|
+
default:
|
|
131911
|
+
return undefined;
|
|
131912
|
+
}
|
|
131913
|
+
}
|
|
131801
131914
|
function createSnippetPrinter(printerOptions) {
|
|
131802
131915
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131803
131916
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131804
131917
|
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)); } });
|
|
131805
131918
|
return {
|
|
131806
131919
|
printSnippetList: printSnippetList,
|
|
131920
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131807
131921
|
};
|
|
131808
131922
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131809
131923
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131811,6 +131925,22 @@ var ts;
|
|
|
131811
131925
|
printer.writeList(format, list, sourceFile, writer);
|
|
131812
131926
|
return writer.getText();
|
|
131813
131927
|
}
|
|
131928
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131929
|
+
var syntheticFile = {
|
|
131930
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131931
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131932
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131933
|
+
},
|
|
131934
|
+
};
|
|
131935
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131936
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131937
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131938
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131939
|
+
/* indentation */ 0,
|
|
131940
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131941
|
+
});
|
|
131942
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131943
|
+
}
|
|
131814
131944
|
}
|
|
131815
131945
|
function originToCompletionEntryData(origin) {
|
|
131816
131946
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131908,7 +132038,7 @@ var ts;
|
|
|
131908
132038
|
return CompletionSource.TypeOnlyAlias;
|
|
131909
132039
|
}
|
|
131910
132040
|
}
|
|
131911
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
132041
|
+
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) {
|
|
131912
132042
|
var _a;
|
|
131913
132043
|
var start = ts.timestamp();
|
|
131914
132044
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131923,12 +132053,12 @@ var ts;
|
|
|
131923
132053
|
var symbol = symbols[i];
|
|
131924
132054
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131925
132055
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131926
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
132056
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131927
132057
|
continue;
|
|
131928
132058
|
}
|
|
131929
132059
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131930
|
-
var
|
|
131931
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
132060
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
132061
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131932
132062
|
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);
|
|
131933
132063
|
if (!entry) {
|
|
131934
132064
|
continue;
|
|
@@ -131946,7 +132076,7 @@ var ts;
|
|
|
131946
132076
|
has: function (name) { return uniques.has(name); },
|
|
131947
132077
|
add: function (name) { return uniques.set(name, true); },
|
|
131948
132078
|
};
|
|
131949
|
-
function shouldIncludeSymbol(symbol,
|
|
132079
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131950
132080
|
var allFlags = symbol.flags;
|
|
131951
132081
|
if (!ts.isSourceFile(location)) {
|
|
131952
132082
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131968,9 +132098,9 @@ var ts;
|
|
|
131968
132098
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131969
132099
|
if (!!sourceFile.externalModuleIndicator
|
|
131970
132100
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
131971
|
-
&&
|
|
131972
|
-
&& (
|
|
131973
|
-
||
|
|
132101
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
132102
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
132103
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
131974
132104
|
return false;
|
|
131975
132105
|
}
|
|
131976
132106
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -132010,7 +132140,7 @@ var ts;
|
|
|
132010
132140
|
name: name,
|
|
132011
132141
|
kindModifiers: "" /* none */,
|
|
132012
132142
|
kind: "label" /* label */,
|
|
132013
|
-
sortText: SortText.LocationPriority
|
|
132143
|
+
sortText: Completions.SortText.LocationPriority
|
|
132014
132144
|
});
|
|
132015
132145
|
}
|
|
132016
132146
|
}
|
|
@@ -132036,7 +132166,7 @@ var ts;
|
|
|
132036
132166
|
}
|
|
132037
132167
|
}
|
|
132038
132168
|
var compilerOptions = program.getCompilerOptions();
|
|
132039
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
132169
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
132040
132170
|
if (!completionData) {
|
|
132041
132171
|
return { type: "none" };
|
|
132042
132172
|
}
|
|
@@ -132054,7 +132184,9 @@ var ts;
|
|
|
132054
132184
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
132055
132185
|
var origin = symbolToOriginInfoMap[index];
|
|
132056
132186
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
132057
|
-
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
132187
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
132188
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
132189
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
132058
132190
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
132059
132191
|
: undefined;
|
|
132060
132192
|
}) || { type: "none" };
|
|
@@ -132136,6 +132268,20 @@ var ts;
|
|
|
132136
132268
|
};
|
|
132137
132269
|
}
|
|
132138
132270
|
}
|
|
132271
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132272
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132273
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132274
|
+
if (importAdder.hasFixes()) {
|
|
132275
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132276
|
+
return {
|
|
132277
|
+
sourceDisplay: undefined,
|
|
132278
|
+
codeActions: [{
|
|
132279
|
+
changes: changes,
|
|
132280
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132281
|
+
}],
|
|
132282
|
+
};
|
|
132283
|
+
}
|
|
132284
|
+
}
|
|
132139
132285
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132140
132286
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132141
132287
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -132228,8 +132374,9 @@ var ts;
|
|
|
132228
132374
|
var _a;
|
|
132229
132375
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
132230
132376
|
}
|
|
132231
|
-
function getCompletionData(program, log, sourceFile,
|
|
132377
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
132232
132378
|
var typeChecker = program.getTypeChecker();
|
|
132379
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
132233
132380
|
var start = ts.timestamp();
|
|
132234
132381
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
132235
132382
|
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
|
|
@@ -132472,7 +132619,7 @@ var ts;
|
|
|
132472
132619
|
// This also gets mutated in nested-functions after the return
|
|
132473
132620
|
var symbols = [];
|
|
132474
132621
|
var symbolToOriginInfoMap = [];
|
|
132475
|
-
var
|
|
132622
|
+
var symbolToSortTextMap = [];
|
|
132476
132623
|
var seenPropertySymbols = new ts.Map();
|
|
132477
132624
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
132478
132625
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -132527,7 +132674,7 @@ var ts;
|
|
|
132527
132674
|
contextToken: contextToken,
|
|
132528
132675
|
isJsxInitializer: isJsxInitializer,
|
|
132529
132676
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
132530
|
-
|
|
132677
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
132531
132678
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
132532
132679
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
132533
132680
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132641,7 +132788,7 @@ var ts;
|
|
|
132641
132788
|
isNewIdentifierLocation = true;
|
|
132642
132789
|
}
|
|
132643
132790
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132644
|
-
if (
|
|
132791
|
+
if (inUncheckedFile) {
|
|
132645
132792
|
// In javascript files, for union types, we don't just get the members that
|
|
132646
132793
|
// the individual types have in common, we also include all the members that
|
|
132647
132794
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132726,7 +132873,7 @@ var ts;
|
|
|
132726
132873
|
}
|
|
132727
132874
|
function addSymbolSortInfo(symbol) {
|
|
132728
132875
|
if (isStaticProperty(symbol)) {
|
|
132729
|
-
|
|
132876
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132730
132877
|
}
|
|
132731
132878
|
}
|
|
132732
132879
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132836,7 +132983,7 @@ var ts;
|
|
|
132836
132983
|
var symbol = symbols[i];
|
|
132837
132984
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132838
132985
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132839
|
-
|
|
132986
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132840
132987
|
}
|
|
132841
132988
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132842
132989
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132854,7 +133001,7 @@ var ts;
|
|
|
132854
133001
|
var symbol = _a[_i];
|
|
132855
133002
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132856
133003
|
symbols.push(symbol);
|
|
132857
|
-
|
|
133004
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132858
133005
|
}
|
|
132859
133006
|
}
|
|
132860
133007
|
}
|
|
@@ -132932,7 +133079,7 @@ var ts;
|
|
|
132932
133079
|
}
|
|
132933
133080
|
return false;
|
|
132934
133081
|
}
|
|
132935
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
133082
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132936
133083
|
function collectAutoImports() {
|
|
132937
133084
|
var _a, _b;
|
|
132938
133085
|
if (!shouldOfferImportCompletions())
|
|
@@ -133014,14 +133161,55 @@ var ts;
|
|
|
133014
133161
|
}
|
|
133015
133162
|
function pushAutoImportSymbol(symbol, origin) {
|
|
133016
133163
|
var symbolId = ts.getSymbolId(symbol);
|
|
133017
|
-
if (
|
|
133164
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
133018
133165
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
133019
133166
|
return;
|
|
133020
133167
|
}
|
|
133021
133168
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133022
|
-
|
|
133169
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
133023
133170
|
symbols.push(symbol);
|
|
133024
133171
|
}
|
|
133172
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
133173
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
133174
|
+
// TODO: support JS files.
|
|
133175
|
+
if (ts.isInJSFile(location)) {
|
|
133176
|
+
return;
|
|
133177
|
+
}
|
|
133178
|
+
members.forEach(function (member) {
|
|
133179
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
133180
|
+
return;
|
|
133181
|
+
}
|
|
133182
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
133183
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
133184
|
+
/*jsxIdentifierExpected*/ false);
|
|
133185
|
+
if (!displayName) {
|
|
133186
|
+
return;
|
|
133187
|
+
}
|
|
133188
|
+
var name = displayName.name;
|
|
133189
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
133190
|
+
if (!entryProps) {
|
|
133191
|
+
return;
|
|
133192
|
+
}
|
|
133193
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
133194
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133195
|
+
symbols.push(member);
|
|
133196
|
+
});
|
|
133197
|
+
}
|
|
133198
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
133199
|
+
/*
|
|
133200
|
+
For an object type
|
|
133201
|
+
`type Foo = {
|
|
133202
|
+
bar(x: number): void;
|
|
133203
|
+
foo: (x: string) => string;
|
|
133204
|
+
}`,
|
|
133205
|
+
`bar` will have symbol flag `Method`,
|
|
133206
|
+
`foo` will have symbol flag `Property`.
|
|
133207
|
+
*/
|
|
133208
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
133209
|
+
return false;
|
|
133210
|
+
}
|
|
133211
|
+
return true;
|
|
133212
|
+
}
|
|
133025
133213
|
/**
|
|
133026
133214
|
* Finds the first node that "embraces" the position, so that one may
|
|
133027
133215
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -133155,6 +133343,7 @@ var ts;
|
|
|
133155
133343
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
133156
133344
|
*/
|
|
133157
133345
|
function tryGetObjectLikeCompletionSymbols() {
|
|
133346
|
+
var symbolsStartIndex = symbols.length;
|
|
133158
133347
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
133159
133348
|
if (!objectLikeContainer)
|
|
133160
133349
|
return 0 /* Continue */;
|
|
@@ -133219,9 +133408,16 @@ var ts;
|
|
|
133219
133408
|
}
|
|
133220
133409
|
if (typeMembers && typeMembers.length > 0) {
|
|
133221
133410
|
// Add filtered items to the completion list
|
|
133222
|
-
|
|
133411
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
133412
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
133413
|
+
setSortTextToOptionalMember();
|
|
133414
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
133415
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
133416
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
133417
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
133418
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
133419
|
+
}
|
|
133223
133420
|
}
|
|
133224
|
-
setSortTextToOptionalMember();
|
|
133225
133421
|
return 1 /* Success */;
|
|
133226
133422
|
}
|
|
133227
133423
|
/**
|
|
@@ -133296,7 +133492,7 @@ var ts;
|
|
|
133296
133492
|
var _a, _b;
|
|
133297
133493
|
symbols.push(symbol);
|
|
133298
133494
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
133299
|
-
|
|
133495
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
133300
133496
|
}
|
|
133301
133497
|
});
|
|
133302
133498
|
return 1 /* Success */;
|
|
@@ -133351,29 +133547,6 @@ var ts;
|
|
|
133351
133547
|
}
|
|
133352
133548
|
return 1 /* Success */;
|
|
133353
133549
|
}
|
|
133354
|
-
/**
|
|
133355
|
-
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133356
|
-
* on the condition that one exists and that the context implies completion should be given.
|
|
133357
|
-
*/
|
|
133358
|
-
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133359
|
-
if (contextToken) {
|
|
133360
|
-
var parent = contextToken.parent;
|
|
133361
|
-
switch (contextToken.kind) {
|
|
133362
|
-
case 18 /* OpenBraceToken */: // const x = { |
|
|
133363
|
-
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133364
|
-
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133365
|
-
return parent;
|
|
133366
|
-
}
|
|
133367
|
-
break;
|
|
133368
|
-
case 41 /* AsteriskToken */:
|
|
133369
|
-
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
133370
|
-
case 79 /* Identifier */:
|
|
133371
|
-
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
133372
|
-
? contextToken.parent.parent : undefined;
|
|
133373
|
-
}
|
|
133374
|
-
}
|
|
133375
|
-
return undefined;
|
|
133376
|
-
}
|
|
133377
133550
|
function isConstructorParameterCompletion(node) {
|
|
133378
133551
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
133379
133552
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133710,7 +133883,7 @@ var ts;
|
|
|
133710
133883
|
var _a;
|
|
133711
133884
|
if (m.flags & 16777216 /* Optional */) {
|
|
133712
133885
|
var symbolId = ts.getSymbolId(m);
|
|
133713
|
-
|
|
133886
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133714
133887
|
}
|
|
133715
133888
|
});
|
|
133716
133889
|
}
|
|
@@ -133722,7 +133895,23 @@ var ts;
|
|
|
133722
133895
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133723
133896
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133724
133897
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133725
|
-
|
|
133898
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133899
|
+
}
|
|
133900
|
+
}
|
|
133901
|
+
}
|
|
133902
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133903
|
+
var _a;
|
|
133904
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133905
|
+
var symbol = symbols[i];
|
|
133906
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133907
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133908
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133909
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133910
|
+
/*jsxIdentifierExpected*/ false);
|
|
133911
|
+
if (displayName) {
|
|
133912
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133913
|
+
var name = displayName.name;
|
|
133914
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133726
133915
|
}
|
|
133727
133916
|
}
|
|
133728
133917
|
}
|
|
@@ -133796,6 +133985,29 @@ var ts;
|
|
|
133796
133985
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133797
133986
|
}
|
|
133798
133987
|
}
|
|
133988
|
+
/**
|
|
133989
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133990
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
133991
|
+
*/
|
|
133992
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133993
|
+
if (contextToken) {
|
|
133994
|
+
var parent = contextToken.parent;
|
|
133995
|
+
switch (contextToken.kind) {
|
|
133996
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
133997
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133998
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133999
|
+
return parent;
|
|
134000
|
+
}
|
|
134001
|
+
break;
|
|
134002
|
+
case 41 /* AsteriskToken */:
|
|
134003
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
134004
|
+
case 79 /* Identifier */:
|
|
134005
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
134006
|
+
? contextToken.parent.parent : undefined;
|
|
134007
|
+
}
|
|
134008
|
+
}
|
|
134009
|
+
return undefined;
|
|
134010
|
+
}
|
|
133799
134011
|
function getRelevantTokens(position, sourceFile) {
|
|
133800
134012
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133801
134013
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133861,7 +134073,7 @@ var ts;
|
|
|
133861
134073
|
name: ts.tokenToString(i),
|
|
133862
134074
|
kind: "keyword" /* keyword */,
|
|
133863
134075
|
kindModifiers: "" /* none */,
|
|
133864
|
-
sortText: SortText.GlobalsOrKeywords
|
|
134076
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133865
134077
|
});
|
|
133866
134078
|
}
|
|
133867
134079
|
return res;
|
|
@@ -133989,7 +134201,7 @@ var ts;
|
|
|
133989
134201
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
133990
134202
|
kind: "keyword" /* keyword */,
|
|
133991
134203
|
kindModifiers: "" /* none */,
|
|
133992
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
134204
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
133993
134205
|
});
|
|
133994
134206
|
}
|
|
133995
134207
|
}
|