typescript 4.5.0-dev.20211028 → 4.5.0-dev.20211029
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/es/diagnosticMessages.generated.json +1 -0
- package/lib/ja/diagnosticMessages.generated.json +1 -0
- package/lib/ko/diagnosticMessages.generated.json +1 -0
- package/lib/lib.dom.d.ts +186 -92
- package/lib/lib.dom.iterable.d.ts +1 -7
- package/lib/lib.webworker.d.ts +60 -19
- package/lib/lib.webworker.iterable.d.ts +0 -7
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/protocol.d.ts +7 -0
- package/lib/pt-br/diagnosticMessages.generated.json +1 -0
- package/lib/ru/diagnosticMessages.generated.json +1 -0
- package/lib/tr/diagnosticMessages.generated.json +1 -0
- package/lib/tsc.js +125 -36
- package/lib/tsserver.js +431 -83
- package/lib/tsserverlibrary.d.ts +8 -0
- package/lib/tsserverlibrary.js +431 -83
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +431 -83
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +431 -83
- package/lib/typingsInstaller.js +175 -36
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -0
- 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.20211029";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -2551,6 +2551,10 @@ var ts;
|
|
|
2551
2551
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
2552
2552
|
}
|
|
2553
2553
|
Debug.formatSyntaxKind = formatSyntaxKind;
|
|
2554
|
+
function formatSnippetKind(kind) {
|
|
2555
|
+
return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false);
|
|
2556
|
+
}
|
|
2557
|
+
Debug.formatSnippetKind = formatSnippetKind;
|
|
2554
2558
|
function formatNodeFlags(flags) {
|
|
2555
2559
|
return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
|
|
2556
2560
|
}
|
|
@@ -4467,6 +4471,13 @@ var ts;
|
|
|
4467
4471
|
ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
|
|
4468
4472
|
})(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
|
|
4469
4473
|
/* @internal */
|
|
4474
|
+
var MemberOverrideStatus;
|
|
4475
|
+
(function (MemberOverrideStatus) {
|
|
4476
|
+
MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok";
|
|
4477
|
+
MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride";
|
|
4478
|
+
MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride";
|
|
4479
|
+
})(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {}));
|
|
4480
|
+
/* @internal */
|
|
4470
4481
|
var UnionReduction;
|
|
4471
4482
|
(function (UnionReduction) {
|
|
4472
4483
|
UnionReduction[UnionReduction["None"] = 0] = "None";
|
|
@@ -5448,6 +5459,15 @@ var ts;
|
|
|
5448
5459
|
// Masks
|
|
5449
5460
|
// - Additional bitmasks
|
|
5450
5461
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
5462
|
+
// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
|
|
5463
|
+
/* @internal */
|
|
5464
|
+
var SnippetKind;
|
|
5465
|
+
(function (SnippetKind) {
|
|
5466
|
+
SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop";
|
|
5467
|
+
SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder";
|
|
5468
|
+
SnippetKind[SnippetKind["Choice"] = 2] = "Choice";
|
|
5469
|
+
SnippetKind[SnippetKind["Variable"] = 3] = "Variable";
|
|
5470
|
+
})(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {}));
|
|
5451
5471
|
var EmitFlags;
|
|
5452
5472
|
(function (EmitFlags) {
|
|
5453
5473
|
EmitFlags[EmitFlags["None"] = 0] = "None";
|
|
@@ -20753,6 +20773,10 @@ var ts;
|
|
|
20753
20773
|
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20754
20774
|
}
|
|
20755
20775
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20776
|
+
function escapeSnippetText(text) {
|
|
20777
|
+
return text.replace(/\$/gm, "\\$");
|
|
20778
|
+
}
|
|
20779
|
+
ts.escapeSnippetText = escapeSnippetText;
|
|
20756
20780
|
})(ts || (ts = {}));
|
|
20757
20781
|
/* @internal */
|
|
20758
20782
|
var ts;
|
|
@@ -26956,6 +26980,25 @@ var ts;
|
|
|
26956
26980
|
}
|
|
26957
26981
|
}
|
|
26958
26982
|
ts.moveEmitHelpers = moveEmitHelpers;
|
|
26983
|
+
/**
|
|
26984
|
+
* Gets the SnippetElement of a node.
|
|
26985
|
+
*/
|
|
26986
|
+
/* @internal */
|
|
26987
|
+
function getSnippetElement(node) {
|
|
26988
|
+
var _a;
|
|
26989
|
+
return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
|
|
26990
|
+
}
|
|
26991
|
+
ts.getSnippetElement = getSnippetElement;
|
|
26992
|
+
/**
|
|
26993
|
+
* Sets the SnippetElement of a node.
|
|
26994
|
+
*/
|
|
26995
|
+
/* @internal */
|
|
26996
|
+
function setSnippetElement(node, snippet) {
|
|
26997
|
+
var emitNode = getOrCreateEmitNode(node);
|
|
26998
|
+
emitNode.snippetElement = snippet;
|
|
26999
|
+
return node;
|
|
27000
|
+
}
|
|
27001
|
+
ts.setSnippetElement = setSnippetElement;
|
|
26959
27002
|
/* @internal */
|
|
26960
27003
|
function ignoreSourceNewlines(node) {
|
|
26961
27004
|
getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
|
|
@@ -47081,6 +47124,7 @@ var ts;
|
|
|
47081
47124
|
isDeclarationVisible: isDeclarationVisible,
|
|
47082
47125
|
isPropertyAccessible: isPropertyAccessible,
|
|
47083
47126
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47127
|
+
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47084
47128
|
};
|
|
47085
47129
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
47086
47130
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -81656,7 +81700,7 @@ var ts;
|
|
|
81656
81700
|
checkKindsOfPropertyMemberOverrides(type, baseType_1);
|
|
81657
81701
|
}
|
|
81658
81702
|
}
|
|
81659
|
-
|
|
81703
|
+
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
81660
81704
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
81661
81705
|
if (implementedTypeNodes) {
|
|
81662
81706
|
for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
|
|
@@ -81691,8 +81735,7 @@ var ts;
|
|
|
81691
81735
|
checkPropertyInitialization(node);
|
|
81692
81736
|
}
|
|
81693
81737
|
}
|
|
81694
|
-
function
|
|
81695
|
-
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81738
|
+
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
81696
81739
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81697
81740
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81698
81741
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
@@ -81704,46 +81747,71 @@ var ts;
|
|
|
81704
81747
|
if (ts.isConstructorDeclaration(member)) {
|
|
81705
81748
|
ts.forEach(member.parameters, function (param) {
|
|
81706
81749
|
if (ts.isParameterPropertyDeclaration(param, member)) {
|
|
81707
|
-
|
|
81750
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
|
|
81751
|
+
/* memberIsParameterProperty */ true);
|
|
81708
81752
|
}
|
|
81709
81753
|
});
|
|
81710
81754
|
}
|
|
81711
|
-
|
|
81755
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
|
|
81756
|
+
/* memberIsParameterProperty */ false);
|
|
81712
81757
|
};
|
|
81713
81758
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
81714
81759
|
var member = _a[_i];
|
|
81715
81760
|
_loop_29(member);
|
|
81716
81761
|
}
|
|
81717
|
-
|
|
81718
|
-
|
|
81719
|
-
|
|
81720
|
-
|
|
81721
|
-
|
|
81722
|
-
|
|
81723
|
-
|
|
81724
|
-
|
|
81725
|
-
|
|
81726
|
-
|
|
81727
|
-
|
|
81728
|
-
|
|
81729
|
-
|
|
81730
|
-
|
|
81731
|
-
|
|
81732
|
-
|
|
81762
|
+
}
|
|
81763
|
+
/**
|
|
81764
|
+
* @param member Existing member node to be checked.
|
|
81765
|
+
* Note: `member` cannot be a synthetic node.
|
|
81766
|
+
*/
|
|
81767
|
+
function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
|
|
81768
|
+
if (reportErrors === void 0) { reportErrors = true; }
|
|
81769
|
+
var declaredProp = member.name
|
|
81770
|
+
&& getSymbolAtLocation(member.name)
|
|
81771
|
+
|| getSymbolAtLocation(member);
|
|
81772
|
+
if (!declaredProp) {
|
|
81773
|
+
return 0 /* Ok */;
|
|
81774
|
+
}
|
|
81775
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
|
|
81776
|
+
}
|
|
81777
|
+
/**
|
|
81778
|
+
* Checks a class member declaration for either a missing or an invalid `override` modifier.
|
|
81779
|
+
* Note: this function can be used for speculative checking,
|
|
81780
|
+
* i.e. checking a member that does not yet exist in the program.
|
|
81781
|
+
* An example of that would be to call this function in a completions scenario,
|
|
81782
|
+
* when offering a method declaration as completion.
|
|
81783
|
+
* @param errorNode The node where we should report an error, or undefined if we should not report errors.
|
|
81784
|
+
*/
|
|
81785
|
+
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
81786
|
+
var isJs = ts.isInJSFile(node);
|
|
81787
|
+
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81788
|
+
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
81789
|
+
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
81790
|
+
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
81791
|
+
var baseType = memberIsStatic ? baseStaticType : baseWithThis;
|
|
81792
|
+
var prop = getPropertyOfType(thisType, memberEscapedName);
|
|
81793
|
+
var baseProp = getPropertyOfType(baseType, memberEscapedName);
|
|
81794
|
+
var baseClassName = typeToString(baseWithThis);
|
|
81795
|
+
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
81796
|
+
if (errorNode) {
|
|
81797
|
+
var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
|
|
81733
81798
|
suggestion ?
|
|
81734
|
-
error(
|
|
81799
|
+
error(errorNode, isJs ?
|
|
81735
81800
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 :
|
|
81736
81801
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) :
|
|
81737
|
-
error(
|
|
81802
|
+
error(errorNode, isJs ?
|
|
81738
81803
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
|
|
81739
81804
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
|
|
81740
81805
|
}
|
|
81741
|
-
|
|
81742
|
-
|
|
81743
|
-
|
|
81744
|
-
|
|
81745
|
-
|
|
81746
|
-
|
|
81806
|
+
return 2 /* HasInvalidOverride */;
|
|
81807
|
+
}
|
|
81808
|
+
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
|
|
81809
|
+
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
|
|
81810
|
+
if (memberHasOverrideModifier) {
|
|
81811
|
+
return 0 /* Ok */;
|
|
81812
|
+
}
|
|
81813
|
+
if (!baseHasAbstract) {
|
|
81814
|
+
if (errorNode) {
|
|
81747
81815
|
var diag = memberIsParameterProperty ?
|
|
81748
81816
|
isJs ?
|
|
81749
81817
|
ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
@@ -81751,20 +81819,28 @@ var ts;
|
|
|
81751
81819
|
isJs ?
|
|
81752
81820
|
ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
81753
81821
|
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
81754
|
-
error(
|
|
81822
|
+
error(errorNode, diag, baseClassName);
|
|
81755
81823
|
}
|
|
81756
|
-
|
|
81757
|
-
|
|
81824
|
+
return 1 /* NeedsOverride */;
|
|
81825
|
+
}
|
|
81826
|
+
else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
81827
|
+
if (errorNode) {
|
|
81828
|
+
error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
|
|
81758
81829
|
}
|
|
81830
|
+
return 1 /* NeedsOverride */;
|
|
81759
81831
|
}
|
|
81760
81832
|
}
|
|
81761
|
-
|
|
81833
|
+
}
|
|
81834
|
+
else if (memberHasOverrideModifier) {
|
|
81835
|
+
if (errorNode) {
|
|
81762
81836
|
var className = typeToString(type);
|
|
81763
|
-
error(
|
|
81837
|
+
error(errorNode, isJs ?
|
|
81764
81838
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
|
|
81765
81839
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
|
|
81766
81840
|
}
|
|
81841
|
+
return 2 /* HasInvalidOverride */;
|
|
81767
81842
|
}
|
|
81843
|
+
return 0 /* Ok */;
|
|
81768
81844
|
}
|
|
81769
81845
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
81770
81846
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
@@ -81807,6 +81883,31 @@ var ts;
|
|
|
81807
81883
|
}
|
|
81808
81884
|
}
|
|
81809
81885
|
}
|
|
81886
|
+
/**
|
|
81887
|
+
* Checks a member declaration node to see if has a missing or invalid `override` modifier.
|
|
81888
|
+
* @param node Class-like node where the member is declared.
|
|
81889
|
+
* @param member Member declaration node.
|
|
81890
|
+
* Note: `member` can be a synthetic node without a parent.
|
|
81891
|
+
*/
|
|
81892
|
+
function getMemberOverrideModifierStatus(node, member) {
|
|
81893
|
+
if (!member.name) {
|
|
81894
|
+
return 0 /* Ok */;
|
|
81895
|
+
}
|
|
81896
|
+
var symbol = getSymbolOfNode(node);
|
|
81897
|
+
var type = getDeclaredTypeOfSymbol(symbol);
|
|
81898
|
+
var typeWithThis = getTypeWithThisArgument(type);
|
|
81899
|
+
var staticType = getTypeOfSymbol(symbol);
|
|
81900
|
+
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81901
|
+
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81902
|
+
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
81903
|
+
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
81904
|
+
var memberHasOverrideModifier = member.parent
|
|
81905
|
+
? ts.hasOverrideModifier(member)
|
|
81906
|
+
: ts.hasSyntacticModifier(member, 16384 /* Override */);
|
|
81907
|
+
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
|
|
81908
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
|
|
81909
|
+
/* memberIsParameterProperty */ false, memberName);
|
|
81910
|
+
}
|
|
81810
81911
|
function getTargetSymbol(s) {
|
|
81811
81912
|
// if symbol is instantiated its flags are not copied from the 'target'
|
|
81812
81913
|
// so we'll need to get back original 'target' symbol to work with correct set of flags
|
|
@@ -108111,7 +108212,14 @@ var ts;
|
|
|
108111
108212
|
// clear the parenthesizer rule as we ascend
|
|
108112
108213
|
currentParenthesizerRule = undefined;
|
|
108113
108214
|
}
|
|
108114
|
-
function pipelineEmitWithHintWorker(hint, node) {
|
|
108215
|
+
function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
|
|
108216
|
+
if (allowSnippets === void 0) { allowSnippets = true; }
|
|
108217
|
+
if (allowSnippets) {
|
|
108218
|
+
var snippet = ts.getSnippetElement(node);
|
|
108219
|
+
if (snippet) {
|
|
108220
|
+
return emitSnippetNode(hint, node, snippet);
|
|
108221
|
+
}
|
|
108222
|
+
}
|
|
108115
108223
|
if (hint === 0 /* SourceFile */)
|
|
108116
108224
|
return emitSourceFile(ts.cast(node, ts.isSourceFile));
|
|
108117
108225
|
if (hint === 2 /* IdentifierName */)
|
|
@@ -108720,6 +108828,28 @@ var ts;
|
|
|
108720
108828
|
}
|
|
108721
108829
|
}
|
|
108722
108830
|
//
|
|
108831
|
+
// Snippet Elements
|
|
108832
|
+
//
|
|
108833
|
+
function emitSnippetNode(hint, node, snippet) {
|
|
108834
|
+
switch (snippet.kind) {
|
|
108835
|
+
case 1 /* Placeholder */:
|
|
108836
|
+
emitPlaceholder(hint, node, snippet);
|
|
108837
|
+
break;
|
|
108838
|
+
case 0 /* TabStop */:
|
|
108839
|
+
emitTabStop(snippet);
|
|
108840
|
+
break;
|
|
108841
|
+
}
|
|
108842
|
+
}
|
|
108843
|
+
function emitPlaceholder(hint, node, snippet) {
|
|
108844
|
+
nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
|
|
108845
|
+
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
|
|
108846
|
+
nonEscapingWrite("}"); // `}`
|
|
108847
|
+
// `${2:...}`
|
|
108848
|
+
}
|
|
108849
|
+
function emitTabStop(snippet) {
|
|
108850
|
+
nonEscapingWrite("$" + snippet.order);
|
|
108851
|
+
}
|
|
108852
|
+
//
|
|
108723
108853
|
// Identifiers
|
|
108724
108854
|
//
|
|
108725
108855
|
function emitIdentifier(node) {
|
|
@@ -110958,6 +111088,15 @@ var ts;
|
|
|
110958
111088
|
function writeProperty(s) {
|
|
110959
111089
|
writer.writeProperty(s);
|
|
110960
111090
|
}
|
|
111091
|
+
function nonEscapingWrite(s) {
|
|
111092
|
+
// This should be defined in a snippet-escaping text writer.
|
|
111093
|
+
if (writer.nonEscapingWrite) {
|
|
111094
|
+
writer.nonEscapingWrite(s);
|
|
111095
|
+
}
|
|
111096
|
+
else {
|
|
111097
|
+
writer.write(s);
|
|
111098
|
+
}
|
|
111099
|
+
}
|
|
110961
111100
|
function writeLine(count) {
|
|
110962
111101
|
if (count === void 0) { count = 1; }
|
|
110963
111102
|
for (var i = 0; i < count; i++) {
|
|
@@ -125595,6 +125734,10 @@ var ts;
|
|
|
125595
125734
|
return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
|
|
125596
125735
|
}
|
|
125597
125736
|
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
|
|
125737
|
+
function getNewLineKind(newLineCharacter) {
|
|
125738
|
+
return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
|
|
125739
|
+
}
|
|
125740
|
+
ts.getNewLineKind = getNewLineKind;
|
|
125598
125741
|
// #endregion
|
|
125599
125742
|
})(ts || (ts = {}));
|
|
125600
125743
|
/*@internal*/
|
|
@@ -127192,7 +127335,7 @@ var ts;
|
|
|
127192
127335
|
(function (Completions) {
|
|
127193
127336
|
var StringCompletions;
|
|
127194
127337
|
(function (StringCompletions) {
|
|
127195
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken,
|
|
127338
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
127196
127339
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
127197
127340
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
127198
127341
|
return entries && convertPathCompletions(entries);
|
|
@@ -127200,12 +127343,12 @@ var ts;
|
|
|
127200
127343
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
127201
127344
|
if (!contextToken || !ts.isStringLiteralLike(contextToken))
|
|
127202
127345
|
return undefined;
|
|
127203
|
-
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
127204
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile,
|
|
127346
|
+
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
|
127347
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
|
|
127205
127348
|
}
|
|
127206
127349
|
}
|
|
127207
127350
|
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
|
|
127208
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile,
|
|
127351
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
|
|
127209
127352
|
if (completion === undefined) {
|
|
127210
127353
|
return undefined;
|
|
127211
127354
|
}
|
|
@@ -127215,7 +127358,7 @@ var ts;
|
|
|
127215
127358
|
return convertPathCompletions(completion.paths);
|
|
127216
127359
|
case 1 /* Properties */: {
|
|
127217
127360
|
var entries = [];
|
|
127218
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile,
|
|
127361
|
+
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
|
|
127219
127362
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127220
127363
|
}
|
|
127221
127364
|
case 2 /* Types */: {
|
|
@@ -128049,7 +128192,6 @@ var ts;
|
|
|
128049
128192
|
}
|
|
128050
128193
|
// If the request is a continuation of an earlier `isIncomplete` response,
|
|
128051
128194
|
// we can continue it from the cached previous response.
|
|
128052
|
-
var typeChecker = program.getTypeChecker();
|
|
128053
128195
|
var compilerOptions = program.getCompilerOptions();
|
|
128054
128196
|
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
|
|
128055
128197
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
|
|
@@ -128061,7 +128203,7 @@ var ts;
|
|
|
128061
128203
|
else {
|
|
128062
128204
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
|
|
128063
128205
|
}
|
|
128064
|
-
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken,
|
|
128206
|
+
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
|
|
128065
128207
|
if (stringCompletions) {
|
|
128066
128208
|
return stringCompletions;
|
|
128067
128209
|
}
|
|
@@ -128075,7 +128217,7 @@ var ts;
|
|
|
128075
128217
|
}
|
|
128076
128218
|
switch (completionData.kind) {
|
|
128077
128219
|
case 0 /* Data */:
|
|
128078
|
-
var response = completionInfoFromData(sourceFile,
|
|
128220
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128079
128221
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128080
128222
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128081
128223
|
}
|
|
@@ -128172,7 +128314,7 @@ var ts;
|
|
|
128172
128314
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128173
128315
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128174
128316
|
}
|
|
128175
|
-
function completionInfoFromData(sourceFile,
|
|
128317
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128176
128318
|
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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
128177
128319
|
// Verify if the file is JSX language variant
|
|
128178
128320
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128184,7 +128326,7 @@ var ts;
|
|
|
128184
128326
|
var entries = [];
|
|
128185
128327
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128186
128328
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128187
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128329
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128188
128330
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128189
128331
|
}
|
|
128190
128332
|
else {
|
|
@@ -128192,7 +128334,7 @@ var ts;
|
|
|
128192
128334
|
return undefined;
|
|
128193
128335
|
}
|
|
128194
128336
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128195
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128337
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128196
128338
|
}
|
|
128197
128339
|
if (keywordFilters !== 0 /* None */) {
|
|
128198
128340
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128298,14 +128440,15 @@ var ts;
|
|
|
128298
128440
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128299
128441
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128300
128442
|
}
|
|
128301
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128302
|
-
var _a;
|
|
128443
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
128444
|
+
var _a, _b;
|
|
128303
128445
|
var insertText;
|
|
128304
128446
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
128305
128447
|
var data;
|
|
128306
128448
|
var isSnippet;
|
|
128307
128449
|
var sourceDisplay;
|
|
128308
128450
|
var hasAction;
|
|
128451
|
+
var typeChecker = program.getTypeChecker();
|
|
128309
128452
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
128310
128453
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
128311
128454
|
if (origin && originIsThisType(origin)) {
|
|
@@ -128356,12 +128499,11 @@ var ts;
|
|
|
128356
128499
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
128357
128500
|
}
|
|
128358
128501
|
}
|
|
128359
|
-
if (
|
|
128360
|
-
|
|
128361
|
-
|
|
128362
|
-
|
|
128363
|
-
|
|
128364
|
-
hasAction = !importCompletionNode;
|
|
128502
|
+
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
128503
|
+
preferences.includeCompletionsWithInsertText &&
|
|
128504
|
+
completionKind === 3 /* MemberLike */ &&
|
|
128505
|
+
isClassLikeMemberCompletion(symbol, location)) {
|
|
128506
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
|
|
128365
128507
|
}
|
|
128366
128508
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128367
128509
|
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
@@ -128373,7 +128515,7 @@ var ts;
|
|
|
128373
128515
|
&& !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
|
|
128374
128516
|
if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
|
|
128375
128517
|
// If is string like or undefined use quotes
|
|
128376
|
-
insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128518
|
+
insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128377
128519
|
isSnippet = true;
|
|
128378
128520
|
}
|
|
128379
128521
|
else {
|
|
@@ -128382,13 +128524,20 @@ var ts;
|
|
|
128382
128524
|
}
|
|
128383
128525
|
}
|
|
128384
128526
|
if (useBraces_1) {
|
|
128385
|
-
insertText = escapeSnippetText(name) + "={$1}";
|
|
128527
|
+
insertText = ts.escapeSnippetText(name) + "={$1}";
|
|
128386
128528
|
isSnippet = true;
|
|
128387
128529
|
}
|
|
128388
128530
|
if (isSnippet) {
|
|
128389
128531
|
replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
|
|
128390
128532
|
}
|
|
128391
128533
|
}
|
|
128534
|
+
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
|
128535
|
+
return undefined;
|
|
128536
|
+
}
|
|
128537
|
+
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
128538
|
+
data = originToCompletionEntryData(origin);
|
|
128539
|
+
hasAction = !importCompletionNode;
|
|
128540
|
+
}
|
|
128392
128541
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
128393
128542
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
128394
128543
|
// really we should consider passing the meaning for the node so that we don't report
|
|
@@ -128413,8 +128562,203 @@ var ts;
|
|
|
128413
128562
|
data: data,
|
|
128414
128563
|
};
|
|
128415
128564
|
}
|
|
128416
|
-
function
|
|
128417
|
-
|
|
128565
|
+
function isClassLikeMemberCompletion(symbol, location) {
|
|
128566
|
+
// TODO: support JS files.
|
|
128567
|
+
if (ts.isInJSFile(location)) {
|
|
128568
|
+
return false;
|
|
128569
|
+
}
|
|
128570
|
+
// Completion symbol must be for a class member.
|
|
128571
|
+
var memberFlags = 106500 /* ClassMember */
|
|
128572
|
+
& 900095 /* EnumMemberExcludes */;
|
|
128573
|
+
/* In
|
|
128574
|
+
`class C {
|
|
128575
|
+
|
|
|
128576
|
+
}`
|
|
128577
|
+
`location` is a class-like declaration.
|
|
128578
|
+
In
|
|
128579
|
+
`class C {
|
|
128580
|
+
m|
|
|
128581
|
+
}`
|
|
128582
|
+
`location` is an identifier,
|
|
128583
|
+
`location.parent` is a class element declaration,
|
|
128584
|
+
and `location.parent.parent` is a class-like declaration.
|
|
128585
|
+
In
|
|
128586
|
+
`abstract class C {
|
|
128587
|
+
abstract
|
|
128588
|
+
abstract m|
|
|
128589
|
+
}`
|
|
128590
|
+
`location` is a syntax list (with modifiers as children),
|
|
128591
|
+
and `location.parent` is a class-like declaration.
|
|
128592
|
+
*/
|
|
128593
|
+
return !!(symbol.flags & memberFlags) &&
|
|
128594
|
+
(ts.isClassLike(location) ||
|
|
128595
|
+
(location.parent &&
|
|
128596
|
+
location.parent.parent &&
|
|
128597
|
+
ts.isClassElement(location.parent) &&
|
|
128598
|
+
location === location.parent.name &&
|
|
128599
|
+
ts.isClassLike(location.parent.parent)) ||
|
|
128600
|
+
(location.parent &&
|
|
128601
|
+
ts.isSyntaxList(location) &&
|
|
128602
|
+
ts.isClassLike(location.parent)));
|
|
128603
|
+
}
|
|
128604
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
128605
|
+
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
128606
|
+
if (!classLikeDeclaration) {
|
|
128607
|
+
return { insertText: name };
|
|
128608
|
+
}
|
|
128609
|
+
var isSnippet;
|
|
128610
|
+
var insertText = name;
|
|
128611
|
+
var checker = program.getTypeChecker();
|
|
128612
|
+
var sourceFile = location.getSourceFile();
|
|
128613
|
+
var printer = createSnippetPrinter({
|
|
128614
|
+
removeComments: true,
|
|
128615
|
+
module: options.module,
|
|
128616
|
+
target: options.target,
|
|
128617
|
+
omitTrailingSemicolon: true,
|
|
128618
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
128619
|
+
});
|
|
128620
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
128621
|
+
var body;
|
|
128622
|
+
var tabstopStart = 1;
|
|
128623
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
128624
|
+
isSnippet = true;
|
|
128625
|
+
// We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
|
|
128626
|
+
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
128627
|
+
var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
|
|
128628
|
+
ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
|
|
128629
|
+
tabstopStart = 2;
|
|
128630
|
+
body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
|
|
128631
|
+
}
|
|
128632
|
+
else {
|
|
128633
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
128634
|
+
}
|
|
128635
|
+
var modifiers = 0 /* None */;
|
|
128636
|
+
// Whether the suggested member should be abstract.
|
|
128637
|
+
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
|
|
128638
|
+
// Note: We are relying on checking if the context token is `abstract`,
|
|
128639
|
+
// since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
|
|
128640
|
+
// However, that is not true for the e.g. `override` modifier, so this check has its limitations.
|
|
128641
|
+
var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
|
|
128642
|
+
var completionNodes = [];
|
|
128643
|
+
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
|
|
128644
|
+
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
|
|
128645
|
+
// it adds for the given member symbol.
|
|
128646
|
+
// We store these member nodes in the `completionNodes` array.
|
|
128647
|
+
// Note: there might be:
|
|
128648
|
+
// - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
|
|
128649
|
+
// - One node;
|
|
128650
|
+
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
|
|
128651
|
+
function (node) {
|
|
128652
|
+
var requiredModifiers = 0 /* None */;
|
|
128653
|
+
if (isAbstract) {
|
|
128654
|
+
requiredModifiers |= 128 /* Abstract */;
|
|
128655
|
+
}
|
|
128656
|
+
if (ts.isClassElement(node)
|
|
128657
|
+
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
|
|
128658
|
+
requiredModifiers |= 16384 /* Override */;
|
|
128659
|
+
}
|
|
128660
|
+
var presentModifiers = 0 /* None */;
|
|
128661
|
+
if (!completionNodes.length) {
|
|
128662
|
+
// Omit already present modifiers from the first completion node/signature.
|
|
128663
|
+
if (contextToken) {
|
|
128664
|
+
presentModifiers = getPresentModifiers(contextToken);
|
|
128665
|
+
}
|
|
128666
|
+
// Keep track of added missing required modifiers and modifiers already present.
|
|
128667
|
+
// This is needed when we have overloaded signatures,
|
|
128668
|
+
// so this callback will be called for multiple nodes/signatures,
|
|
128669
|
+
// and we need to make sure the modifiers are uniform for all nodes/signatures.
|
|
128670
|
+
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
|
|
128671
|
+
}
|
|
128672
|
+
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
128673
|
+
completionNodes.push(node);
|
|
128674
|
+
}, body, isAbstract);
|
|
128675
|
+
if (completionNodes.length) {
|
|
128676
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
128677
|
+
addSnippets(completionNodes, tabstopStart);
|
|
128678
|
+
}
|
|
128679
|
+
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
128680
|
+
}
|
|
128681
|
+
return { insertText: insertText, isSnippet: isSnippet };
|
|
128682
|
+
}
|
|
128683
|
+
function getPresentModifiers(contextToken) {
|
|
128684
|
+
var modifiers = 0 /* None */;
|
|
128685
|
+
var contextMod;
|
|
128686
|
+
/*
|
|
128687
|
+
Cases supported:
|
|
128688
|
+
In
|
|
128689
|
+
`class C {
|
|
128690
|
+
public abstract |
|
|
128691
|
+
}`
|
|
128692
|
+
`contextToken` is ``abstract`` (as an identifier),
|
|
128693
|
+
`contextToken.parent` is property declaration,
|
|
128694
|
+
`location` is class declaration ``class C { ... }``.
|
|
128695
|
+
In
|
|
128696
|
+
`class C {
|
|
128697
|
+
protected override m|
|
|
128698
|
+
}`
|
|
128699
|
+
`contextToken` is ``override`` (as a keyword),
|
|
128700
|
+
`contextToken.parent` is property declaration,
|
|
128701
|
+
`location` is identifier ``m``,
|
|
128702
|
+
`location.parent` is property declaration ``protected override m``,
|
|
128703
|
+
`location.parent.parent` is class declaration ``class C { ... }``.
|
|
128704
|
+
*/
|
|
128705
|
+
if (contextMod = isModifierLike(contextToken)) {
|
|
128706
|
+
modifiers |= ts.modifierToFlag(contextMod);
|
|
128707
|
+
}
|
|
128708
|
+
if (ts.isPropertyDeclaration(contextToken.parent)) {
|
|
128709
|
+
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
|
|
128710
|
+
}
|
|
128711
|
+
return modifiers;
|
|
128712
|
+
}
|
|
128713
|
+
function isModifierLike(node) {
|
|
128714
|
+
if (ts.isModifier(node)) {
|
|
128715
|
+
return node.kind;
|
|
128716
|
+
}
|
|
128717
|
+
if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
|
|
128718
|
+
return node.originalKeywordKind;
|
|
128719
|
+
}
|
|
128720
|
+
return undefined;
|
|
128721
|
+
}
|
|
128722
|
+
function addSnippets(nodes, orderStart) {
|
|
128723
|
+
var order = orderStart;
|
|
128724
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
128725
|
+
var node = nodes_1[_i];
|
|
128726
|
+
addSnippetsWorker(node, /*parent*/ undefined);
|
|
128727
|
+
}
|
|
128728
|
+
function addSnippetsWorker(node, parent) {
|
|
128729
|
+
if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
|
|
128730
|
+
// Placeholder
|
|
128731
|
+
ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
|
|
128732
|
+
order += 1;
|
|
128733
|
+
if (node.type) {
|
|
128734
|
+
ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
|
|
128735
|
+
order += 1;
|
|
128736
|
+
}
|
|
128737
|
+
}
|
|
128738
|
+
else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
128739
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
128740
|
+
order += 1;
|
|
128741
|
+
}
|
|
128742
|
+
else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
128743
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
128744
|
+
order += 1;
|
|
128745
|
+
}
|
|
128746
|
+
ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
|
|
128747
|
+
}
|
|
128748
|
+
}
|
|
128749
|
+
function createSnippetPrinter(printerOptions) {
|
|
128750
|
+
var printer = ts.createPrinter(printerOptions);
|
|
128751
|
+
var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
|
|
128752
|
+
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)); } });
|
|
128753
|
+
return {
|
|
128754
|
+
printSnippetList: printSnippetList,
|
|
128755
|
+
};
|
|
128756
|
+
/* Snippet-escaping version of `printer.printList`. */
|
|
128757
|
+
function printSnippetList(format, list, sourceFile) {
|
|
128758
|
+
writer.clear();
|
|
128759
|
+
printer.writeList(format, list, sourceFile, writer);
|
|
128760
|
+
return writer.getText();
|
|
128761
|
+
}
|
|
128418
128762
|
}
|
|
128419
128763
|
function originToCompletionEntryData(origin) {
|
|
128420
128764
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -128482,10 +128826,10 @@ var ts;
|
|
|
128482
128826
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
|
|
128483
128827
|
var suffix = useSemicolons ? ";" : "";
|
|
128484
128828
|
switch (importKind) {
|
|
128485
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
128486
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
128487
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
128488
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
128829
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
128830
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
128831
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
128832
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
128489
128833
|
}
|
|
128490
128834
|
}
|
|
128491
128835
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -128509,11 +128853,12 @@ var ts;
|
|
|
128509
128853
|
return CompletionSource.ThisProperty;
|
|
128510
128854
|
}
|
|
128511
128855
|
}
|
|
128512
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile,
|
|
128856
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
128513
128857
|
var _a;
|
|
128514
128858
|
var start = ts.timestamp();
|
|
128515
128859
|
var variableDeclaration = getVariableDeclaration(location);
|
|
128516
128860
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
128861
|
+
var typeChecker = program.getTypeChecker();
|
|
128517
128862
|
// Tracks unique names.
|
|
128518
128863
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
128519
128864
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -128529,7 +128874,7 @@ var ts;
|
|
|
128529
128874
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
128530
128875
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
128531
128876
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
128532
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128877
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
128533
128878
|
if (!entry) {
|
|
128534
128879
|
continue;
|
|
128535
128880
|
}
|
|
@@ -143921,8 +144266,8 @@ var ts;
|
|
|
143921
144266
|
ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
|
|
143922
144267
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
143923
144268
|
// When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
|
|
143924
|
-
for (var _i = 0,
|
|
143925
|
-
var node =
|
|
144269
|
+
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
144270
|
+
var node = nodes_2[_i];
|
|
143926
144271
|
var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
|
|
143927
144272
|
var end = getAdjustedEndPosition(sourceFile, node, options);
|
|
143928
144273
|
this.deleteRange(sourceFile, { pos: pos, end: end });
|
|
@@ -144562,7 +144907,7 @@ var ts;
|
|
|
144562
144907
|
/** Note: output node may be mutated input node. */
|
|
144563
144908
|
function getNonformattedText(node, sourceFile, newLineCharacter) {
|
|
144564
144909
|
var writer = createWriter(newLineCharacter);
|
|
144565
|
-
var newLine = newLineCharacter
|
|
144910
|
+
var newLine = ts.getNewLineKind(newLineCharacter);
|
|
144566
144911
|
ts.createPrinter({
|
|
144567
144912
|
newLine: newLine,
|
|
144568
144913
|
neverAsciiEscape: true,
|
|
@@ -152163,7 +152508,7 @@ var ts;
|
|
|
152163
152508
|
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
|
|
152164
152509
|
var symbol = possiblyMissingSymbols_1[_i];
|
|
152165
152510
|
if (!classMembers.has(symbol.escapedName)) {
|
|
152166
|
-
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
|
|
152511
|
+
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
|
152167
152512
|
}
|
|
152168
152513
|
}
|
|
152169
152514
|
}
|
|
@@ -152176,9 +152521,11 @@ var ts;
|
|
|
152176
152521
|
}
|
|
152177
152522
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152178
152523
|
/**
|
|
152179
|
-
*
|
|
152524
|
+
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
152525
|
+
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152180
152526
|
*/
|
|
152181
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
|
|
152527
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
152528
|
+
if (isAmbient === void 0) { isAmbient = false; }
|
|
152182
152529
|
var declarations = symbol.getDeclarations();
|
|
152183
152530
|
if (!(declarations && declarations.length)) {
|
|
152184
152531
|
return undefined;
|
|
@@ -152191,7 +152538,7 @@ var ts;
|
|
|
152191
152538
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
152192
152539
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
152193
152540
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
152194
|
-
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
|
|
152541
|
+
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
|
|
152195
152542
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
152196
152543
|
switch (declaration.kind) {
|
|
152197
152544
|
case 165 /* PropertySignature */:
|
|
@@ -152227,14 +152574,14 @@ var ts;
|
|
|
152227
152574
|
var accessor = orderedAccessors_1[_i];
|
|
152228
152575
|
if (ts.isGetAccessorDeclaration(accessor)) {
|
|
152229
152576
|
addClassElement(ts.factory.createGetAccessorDeclaration(
|
|
152230
|
-
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
152577
|
+
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152231
152578
|
}
|
|
152232
152579
|
else {
|
|
152233
152580
|
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
|
|
152234
152581
|
var parameter = ts.getSetAccessorValueParameter(accessor);
|
|
152235
152582
|
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
|
|
152236
152583
|
addClassElement(ts.factory.createSetAccessorDeclaration(
|
|
152237
|
-
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
152584
|
+
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152238
152585
|
}
|
|
152239
152586
|
}
|
|
152240
152587
|
break;
|
|
@@ -152255,7 +152602,7 @@ var ts;
|
|
|
152255
152602
|
if (declarations.length === 1) {
|
|
152256
152603
|
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
|
|
152257
152604
|
var signature = signatures[0];
|
|
152258
|
-
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
|
|
152605
|
+
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
|
|
152259
152606
|
break;
|
|
152260
152607
|
}
|
|
152261
152608
|
for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
|
|
@@ -152266,11 +152613,11 @@ var ts;
|
|
|
152266
152613
|
if (!ambient) {
|
|
152267
152614
|
if (declarations.length > signatures.length) {
|
|
152268
152615
|
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
|
|
152269
|
-
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
|
|
152616
|
+
outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
|
|
152270
152617
|
}
|
|
152271
152618
|
else {
|
|
152272
152619
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152273
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
|
|
152620
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152274
152621
|
}
|
|
152275
152622
|
}
|
|
152276
152623
|
break;
|
|
@@ -152281,6 +152628,7 @@ var ts;
|
|
|
152281
152628
|
addClassElement(method);
|
|
152282
152629
|
}
|
|
152283
152630
|
}
|
|
152631
|
+
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
|
|
152284
152632
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
152285
152633
|
var program = context.program;
|
|
152286
152634
|
var checker = program.getTypeChecker();
|
|
@@ -152418,7 +152766,7 @@ var ts;
|
|
|
152418
152766
|
}
|
|
152419
152767
|
return parameters;
|
|
152420
152768
|
}
|
|
152421
|
-
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
|
|
152769
|
+
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
|
|
152422
152770
|
/** This is *a* signature with the maximal number of arguments,
|
|
152423
152771
|
* such that if there is a "maximal" signature without rest arguments,
|
|
152424
152772
|
* this is one of them.
|
|
@@ -152449,7 +152797,7 @@ var ts;
|
|
|
152449
152797
|
parameters.push(restParameter);
|
|
152450
152798
|
}
|
|
152451
152799
|
return createStubbedMethod(modifiers, name, optional,
|
|
152452
|
-
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
|
|
152800
|
+
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
|
|
152453
152801
|
}
|
|
152454
152802
|
function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
|
|
152455
152803
|
if (ts.length(signatures)) {
|
|
@@ -152457,10 +152805,10 @@ var ts;
|
|
|
152457
152805
|
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
|
|
152458
152806
|
}
|
|
152459
152807
|
}
|
|
152460
|
-
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
|
|
152808
|
+
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
|
|
152461
152809
|
return ts.factory.createMethodDeclaration(
|
|
152462
152810
|
/*decorators*/ undefined, modifiers,
|
|
152463
|
-
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
|
|
152811
|
+
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
|
|
152464
152812
|
}
|
|
152465
152813
|
function createStubbedMethodBody(quotePreference) {
|
|
152466
152814
|
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
|
|
@@ -158471,8 +158819,8 @@ var ts;
|
|
|
158471
158819
|
var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
|
|
158472
158820
|
list._children = [];
|
|
158473
158821
|
var pos = nodes.pos;
|
|
158474
|
-
for (var _i = 0,
|
|
158475
|
-
var node =
|
|
158822
|
+
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
158823
|
+
var node = nodes_3[_i];
|
|
158476
158824
|
addSyntheticNodes(list._children, pos, node.pos, parent);
|
|
158477
158825
|
list._children.push(node);
|
|
158478
158826
|
pos = node.end;
|