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/typescript.js
CHANGED
|
@@ -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.20211029";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -2745,6 +2745,10 @@ var ts;
|
|
|
2745
2745
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
2746
2746
|
}
|
|
2747
2747
|
Debug.formatSyntaxKind = formatSyntaxKind;
|
|
2748
|
+
function formatSnippetKind(kind) {
|
|
2749
|
+
return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false);
|
|
2750
|
+
}
|
|
2751
|
+
Debug.formatSnippetKind = formatSnippetKind;
|
|
2748
2752
|
function formatNodeFlags(flags) {
|
|
2749
2753
|
return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
|
|
2750
2754
|
}
|
|
@@ -4661,6 +4665,13 @@ var ts;
|
|
|
4661
4665
|
ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
|
|
4662
4666
|
})(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
|
|
4663
4667
|
/* @internal */
|
|
4668
|
+
var MemberOverrideStatus;
|
|
4669
|
+
(function (MemberOverrideStatus) {
|
|
4670
|
+
MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok";
|
|
4671
|
+
MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride";
|
|
4672
|
+
MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride";
|
|
4673
|
+
})(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {}));
|
|
4674
|
+
/* @internal */
|
|
4664
4675
|
var UnionReduction;
|
|
4665
4676
|
(function (UnionReduction) {
|
|
4666
4677
|
UnionReduction[UnionReduction["None"] = 0] = "None";
|
|
@@ -5642,6 +5653,15 @@ var ts;
|
|
|
5642
5653
|
// Masks
|
|
5643
5654
|
// - Additional bitmasks
|
|
5644
5655
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
5656
|
+
// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
|
|
5657
|
+
/* @internal */
|
|
5658
|
+
var SnippetKind;
|
|
5659
|
+
(function (SnippetKind) {
|
|
5660
|
+
SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop";
|
|
5661
|
+
SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder";
|
|
5662
|
+
SnippetKind[SnippetKind["Choice"] = 2] = "Choice";
|
|
5663
|
+
SnippetKind[SnippetKind["Variable"] = 3] = "Variable";
|
|
5664
|
+
})(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {}));
|
|
5645
5665
|
var EmitFlags;
|
|
5646
5666
|
(function (EmitFlags) {
|
|
5647
5667
|
EmitFlags[EmitFlags["None"] = 0] = "None";
|
|
@@ -20947,6 +20967,10 @@ var ts;
|
|
|
20947
20967
|
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20948
20968
|
}
|
|
20949
20969
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20970
|
+
function escapeSnippetText(text) {
|
|
20971
|
+
return text.replace(/\$/gm, "\\$");
|
|
20972
|
+
}
|
|
20973
|
+
ts.escapeSnippetText = escapeSnippetText;
|
|
20950
20974
|
})(ts || (ts = {}));
|
|
20951
20975
|
/* @internal */
|
|
20952
20976
|
var ts;
|
|
@@ -27150,6 +27174,25 @@ var ts;
|
|
|
27150
27174
|
}
|
|
27151
27175
|
}
|
|
27152
27176
|
ts.moveEmitHelpers = moveEmitHelpers;
|
|
27177
|
+
/**
|
|
27178
|
+
* Gets the SnippetElement of a node.
|
|
27179
|
+
*/
|
|
27180
|
+
/* @internal */
|
|
27181
|
+
function getSnippetElement(node) {
|
|
27182
|
+
var _a;
|
|
27183
|
+
return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
|
|
27184
|
+
}
|
|
27185
|
+
ts.getSnippetElement = getSnippetElement;
|
|
27186
|
+
/**
|
|
27187
|
+
* Sets the SnippetElement of a node.
|
|
27188
|
+
*/
|
|
27189
|
+
/* @internal */
|
|
27190
|
+
function setSnippetElement(node, snippet) {
|
|
27191
|
+
var emitNode = getOrCreateEmitNode(node);
|
|
27192
|
+
emitNode.snippetElement = snippet;
|
|
27193
|
+
return node;
|
|
27194
|
+
}
|
|
27195
|
+
ts.setSnippetElement = setSnippetElement;
|
|
27153
27196
|
/* @internal */
|
|
27154
27197
|
function ignoreSourceNewlines(node) {
|
|
27155
27198
|
getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
|
|
@@ -47275,6 +47318,7 @@ var ts;
|
|
|
47275
47318
|
isDeclarationVisible: isDeclarationVisible,
|
|
47276
47319
|
isPropertyAccessible: isPropertyAccessible,
|
|
47277
47320
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47321
|
+
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47278
47322
|
};
|
|
47279
47323
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
47280
47324
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -81850,7 +81894,7 @@ var ts;
|
|
|
81850
81894
|
checkKindsOfPropertyMemberOverrides(type, baseType_1);
|
|
81851
81895
|
}
|
|
81852
81896
|
}
|
|
81853
|
-
|
|
81897
|
+
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
81854
81898
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
81855
81899
|
if (implementedTypeNodes) {
|
|
81856
81900
|
for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
|
|
@@ -81885,8 +81929,7 @@ var ts;
|
|
|
81885
81929
|
checkPropertyInitialization(node);
|
|
81886
81930
|
}
|
|
81887
81931
|
}
|
|
81888
|
-
function
|
|
81889
|
-
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81932
|
+
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
81890
81933
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81891
81934
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81892
81935
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
@@ -81898,46 +81941,71 @@ var ts;
|
|
|
81898
81941
|
if (ts.isConstructorDeclaration(member)) {
|
|
81899
81942
|
ts.forEach(member.parameters, function (param) {
|
|
81900
81943
|
if (ts.isParameterPropertyDeclaration(param, member)) {
|
|
81901
|
-
|
|
81944
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
|
|
81945
|
+
/* memberIsParameterProperty */ true);
|
|
81902
81946
|
}
|
|
81903
81947
|
});
|
|
81904
81948
|
}
|
|
81905
|
-
|
|
81949
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
|
|
81950
|
+
/* memberIsParameterProperty */ false);
|
|
81906
81951
|
};
|
|
81907
81952
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
81908
81953
|
var member = _a[_i];
|
|
81909
81954
|
_loop_29(member);
|
|
81910
81955
|
}
|
|
81911
|
-
|
|
81912
|
-
|
|
81913
|
-
|
|
81914
|
-
|
|
81915
|
-
|
|
81916
|
-
|
|
81917
|
-
|
|
81918
|
-
|
|
81919
|
-
|
|
81920
|
-
|
|
81921
|
-
|
|
81922
|
-
|
|
81923
|
-
|
|
81924
|
-
|
|
81925
|
-
|
|
81926
|
-
|
|
81956
|
+
}
|
|
81957
|
+
/**
|
|
81958
|
+
* @param member Existing member node to be checked.
|
|
81959
|
+
* Note: `member` cannot be a synthetic node.
|
|
81960
|
+
*/
|
|
81961
|
+
function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
|
|
81962
|
+
if (reportErrors === void 0) { reportErrors = true; }
|
|
81963
|
+
var declaredProp = member.name
|
|
81964
|
+
&& getSymbolAtLocation(member.name)
|
|
81965
|
+
|| getSymbolAtLocation(member);
|
|
81966
|
+
if (!declaredProp) {
|
|
81967
|
+
return 0 /* Ok */;
|
|
81968
|
+
}
|
|
81969
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
|
|
81970
|
+
}
|
|
81971
|
+
/**
|
|
81972
|
+
* Checks a class member declaration for either a missing or an invalid `override` modifier.
|
|
81973
|
+
* Note: this function can be used for speculative checking,
|
|
81974
|
+
* i.e. checking a member that does not yet exist in the program.
|
|
81975
|
+
* An example of that would be to call this function in a completions scenario,
|
|
81976
|
+
* when offering a method declaration as completion.
|
|
81977
|
+
* @param errorNode The node where we should report an error, or undefined if we should not report errors.
|
|
81978
|
+
*/
|
|
81979
|
+
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
81980
|
+
var isJs = ts.isInJSFile(node);
|
|
81981
|
+
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81982
|
+
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
81983
|
+
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
81984
|
+
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
81985
|
+
var baseType = memberIsStatic ? baseStaticType : baseWithThis;
|
|
81986
|
+
var prop = getPropertyOfType(thisType, memberEscapedName);
|
|
81987
|
+
var baseProp = getPropertyOfType(baseType, memberEscapedName);
|
|
81988
|
+
var baseClassName = typeToString(baseWithThis);
|
|
81989
|
+
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
81990
|
+
if (errorNode) {
|
|
81991
|
+
var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
|
|
81927
81992
|
suggestion ?
|
|
81928
|
-
error(
|
|
81993
|
+
error(errorNode, isJs ?
|
|
81929
81994
|
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 :
|
|
81930
81995
|
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)) :
|
|
81931
|
-
error(
|
|
81996
|
+
error(errorNode, isJs ?
|
|
81932
81997
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
|
|
81933
81998
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
|
|
81934
81999
|
}
|
|
81935
|
-
|
|
81936
|
-
|
|
81937
|
-
|
|
81938
|
-
|
|
81939
|
-
|
|
81940
|
-
|
|
82000
|
+
return 2 /* HasInvalidOverride */;
|
|
82001
|
+
}
|
|
82002
|
+
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
|
|
82003
|
+
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
|
|
82004
|
+
if (memberHasOverrideModifier) {
|
|
82005
|
+
return 0 /* Ok */;
|
|
82006
|
+
}
|
|
82007
|
+
if (!baseHasAbstract) {
|
|
82008
|
+
if (errorNode) {
|
|
81941
82009
|
var diag = memberIsParameterProperty ?
|
|
81942
82010
|
isJs ?
|
|
81943
82011
|
ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
@@ -81945,20 +82013,28 @@ var ts;
|
|
|
81945
82013
|
isJs ?
|
|
81946
82014
|
ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
81947
82015
|
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
81948
|
-
error(
|
|
82016
|
+
error(errorNode, diag, baseClassName);
|
|
81949
82017
|
}
|
|
81950
|
-
|
|
81951
|
-
|
|
82018
|
+
return 1 /* NeedsOverride */;
|
|
82019
|
+
}
|
|
82020
|
+
else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
82021
|
+
if (errorNode) {
|
|
82022
|
+
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);
|
|
81952
82023
|
}
|
|
82024
|
+
return 1 /* NeedsOverride */;
|
|
81953
82025
|
}
|
|
81954
82026
|
}
|
|
81955
|
-
|
|
82027
|
+
}
|
|
82028
|
+
else if (memberHasOverrideModifier) {
|
|
82029
|
+
if (errorNode) {
|
|
81956
82030
|
var className = typeToString(type);
|
|
81957
|
-
error(
|
|
82031
|
+
error(errorNode, isJs ?
|
|
81958
82032
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
|
|
81959
82033
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
|
|
81960
82034
|
}
|
|
82035
|
+
return 2 /* HasInvalidOverride */;
|
|
81961
82036
|
}
|
|
82037
|
+
return 0 /* Ok */;
|
|
81962
82038
|
}
|
|
81963
82039
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
81964
82040
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
@@ -82001,6 +82077,31 @@ var ts;
|
|
|
82001
82077
|
}
|
|
82002
82078
|
}
|
|
82003
82079
|
}
|
|
82080
|
+
/**
|
|
82081
|
+
* Checks a member declaration node to see if has a missing or invalid `override` modifier.
|
|
82082
|
+
* @param node Class-like node where the member is declared.
|
|
82083
|
+
* @param member Member declaration node.
|
|
82084
|
+
* Note: `member` can be a synthetic node without a parent.
|
|
82085
|
+
*/
|
|
82086
|
+
function getMemberOverrideModifierStatus(node, member) {
|
|
82087
|
+
if (!member.name) {
|
|
82088
|
+
return 0 /* Ok */;
|
|
82089
|
+
}
|
|
82090
|
+
var symbol = getSymbolOfNode(node);
|
|
82091
|
+
var type = getDeclaredTypeOfSymbol(symbol);
|
|
82092
|
+
var typeWithThis = getTypeWithThisArgument(type);
|
|
82093
|
+
var staticType = getTypeOfSymbol(symbol);
|
|
82094
|
+
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
82095
|
+
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
82096
|
+
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
82097
|
+
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
82098
|
+
var memberHasOverrideModifier = member.parent
|
|
82099
|
+
? ts.hasOverrideModifier(member)
|
|
82100
|
+
: ts.hasSyntacticModifier(member, 16384 /* Override */);
|
|
82101
|
+
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
|
|
82102
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
|
|
82103
|
+
/* memberIsParameterProperty */ false, memberName);
|
|
82104
|
+
}
|
|
82004
82105
|
function getTargetSymbol(s) {
|
|
82005
82106
|
// if symbol is instantiated its flags are not copied from the 'target'
|
|
82006
82107
|
// so we'll need to get back original 'target' symbol to work with correct set of flags
|
|
@@ -108305,7 +108406,14 @@ var ts;
|
|
|
108305
108406
|
// clear the parenthesizer rule as we ascend
|
|
108306
108407
|
currentParenthesizerRule = undefined;
|
|
108307
108408
|
}
|
|
108308
|
-
function pipelineEmitWithHintWorker(hint, node) {
|
|
108409
|
+
function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
|
|
108410
|
+
if (allowSnippets === void 0) { allowSnippets = true; }
|
|
108411
|
+
if (allowSnippets) {
|
|
108412
|
+
var snippet = ts.getSnippetElement(node);
|
|
108413
|
+
if (snippet) {
|
|
108414
|
+
return emitSnippetNode(hint, node, snippet);
|
|
108415
|
+
}
|
|
108416
|
+
}
|
|
108309
108417
|
if (hint === 0 /* SourceFile */)
|
|
108310
108418
|
return emitSourceFile(ts.cast(node, ts.isSourceFile));
|
|
108311
108419
|
if (hint === 2 /* IdentifierName */)
|
|
@@ -108914,6 +109022,28 @@ var ts;
|
|
|
108914
109022
|
}
|
|
108915
109023
|
}
|
|
108916
109024
|
//
|
|
109025
|
+
// Snippet Elements
|
|
109026
|
+
//
|
|
109027
|
+
function emitSnippetNode(hint, node, snippet) {
|
|
109028
|
+
switch (snippet.kind) {
|
|
109029
|
+
case 1 /* Placeholder */:
|
|
109030
|
+
emitPlaceholder(hint, node, snippet);
|
|
109031
|
+
break;
|
|
109032
|
+
case 0 /* TabStop */:
|
|
109033
|
+
emitTabStop(snippet);
|
|
109034
|
+
break;
|
|
109035
|
+
}
|
|
109036
|
+
}
|
|
109037
|
+
function emitPlaceholder(hint, node, snippet) {
|
|
109038
|
+
nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
|
|
109039
|
+
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
|
|
109040
|
+
nonEscapingWrite("}"); // `}`
|
|
109041
|
+
// `${2:...}`
|
|
109042
|
+
}
|
|
109043
|
+
function emitTabStop(snippet) {
|
|
109044
|
+
nonEscapingWrite("$" + snippet.order);
|
|
109045
|
+
}
|
|
109046
|
+
//
|
|
108917
109047
|
// Identifiers
|
|
108918
109048
|
//
|
|
108919
109049
|
function emitIdentifier(node) {
|
|
@@ -111152,6 +111282,15 @@ var ts;
|
|
|
111152
111282
|
function writeProperty(s) {
|
|
111153
111283
|
writer.writeProperty(s);
|
|
111154
111284
|
}
|
|
111285
|
+
function nonEscapingWrite(s) {
|
|
111286
|
+
// This should be defined in a snippet-escaping text writer.
|
|
111287
|
+
if (writer.nonEscapingWrite) {
|
|
111288
|
+
writer.nonEscapingWrite(s);
|
|
111289
|
+
}
|
|
111290
|
+
else {
|
|
111291
|
+
writer.write(s);
|
|
111292
|
+
}
|
|
111293
|
+
}
|
|
111155
111294
|
function writeLine(count) {
|
|
111156
111295
|
if (count === void 0) { count = 1; }
|
|
111157
111296
|
for (var i = 0; i < count; i++) {
|
|
@@ -126177,6 +126316,10 @@ var ts;
|
|
|
126177
126316
|
return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
|
|
126178
126317
|
}
|
|
126179
126318
|
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
|
|
126319
|
+
function getNewLineKind(newLineCharacter) {
|
|
126320
|
+
return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
|
|
126321
|
+
}
|
|
126322
|
+
ts.getNewLineKind = getNewLineKind;
|
|
126180
126323
|
// #endregion
|
|
126181
126324
|
})(ts || (ts = {}));
|
|
126182
126325
|
/*@internal*/
|
|
@@ -127774,7 +127917,7 @@ var ts;
|
|
|
127774
127917
|
(function (Completions) {
|
|
127775
127918
|
var StringCompletions;
|
|
127776
127919
|
(function (StringCompletions) {
|
|
127777
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken,
|
|
127920
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
127778
127921
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
127779
127922
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
127780
127923
|
return entries && convertPathCompletions(entries);
|
|
@@ -127782,12 +127925,12 @@ var ts;
|
|
|
127782
127925
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
127783
127926
|
if (!contextToken || !ts.isStringLiteralLike(contextToken))
|
|
127784
127927
|
return undefined;
|
|
127785
|
-
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
127786
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile,
|
|
127928
|
+
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
|
127929
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
|
|
127787
127930
|
}
|
|
127788
127931
|
}
|
|
127789
127932
|
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
|
|
127790
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile,
|
|
127933
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
|
|
127791
127934
|
if (completion === undefined) {
|
|
127792
127935
|
return undefined;
|
|
127793
127936
|
}
|
|
@@ -127797,7 +127940,7 @@ var ts;
|
|
|
127797
127940
|
return convertPathCompletions(completion.paths);
|
|
127798
127941
|
case 1 /* Properties */: {
|
|
127799
127942
|
var entries = [];
|
|
127800
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile,
|
|
127943
|
+
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
|
|
127801
127944
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127802
127945
|
}
|
|
127803
127946
|
case 2 /* Types */: {
|
|
@@ -128631,7 +128774,6 @@ var ts;
|
|
|
128631
128774
|
}
|
|
128632
128775
|
// If the request is a continuation of an earlier `isIncomplete` response,
|
|
128633
128776
|
// we can continue it from the cached previous response.
|
|
128634
|
-
var typeChecker = program.getTypeChecker();
|
|
128635
128777
|
var compilerOptions = program.getCompilerOptions();
|
|
128636
128778
|
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
|
|
128637
128779
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
|
|
@@ -128643,7 +128785,7 @@ var ts;
|
|
|
128643
128785
|
else {
|
|
128644
128786
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
|
|
128645
128787
|
}
|
|
128646
|
-
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken,
|
|
128788
|
+
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
|
|
128647
128789
|
if (stringCompletions) {
|
|
128648
128790
|
return stringCompletions;
|
|
128649
128791
|
}
|
|
@@ -128657,7 +128799,7 @@ var ts;
|
|
|
128657
128799
|
}
|
|
128658
128800
|
switch (completionData.kind) {
|
|
128659
128801
|
case 0 /* Data */:
|
|
128660
|
-
var response = completionInfoFromData(sourceFile,
|
|
128802
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128661
128803
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128662
128804
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128663
128805
|
}
|
|
@@ -128754,7 +128896,7 @@ var ts;
|
|
|
128754
128896
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128755
128897
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128756
128898
|
}
|
|
128757
|
-
function completionInfoFromData(sourceFile,
|
|
128899
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128758
128900
|
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;
|
|
128759
128901
|
// Verify if the file is JSX language variant
|
|
128760
128902
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128766,7 +128908,7 @@ var ts;
|
|
|
128766
128908
|
var entries = [];
|
|
128767
128909
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128768
128910
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128769
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128911
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128770
128912
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128771
128913
|
}
|
|
128772
128914
|
else {
|
|
@@ -128774,7 +128916,7 @@ var ts;
|
|
|
128774
128916
|
return undefined;
|
|
128775
128917
|
}
|
|
128776
128918
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128777
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128919
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128778
128920
|
}
|
|
128779
128921
|
if (keywordFilters !== 0 /* None */) {
|
|
128780
128922
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128880,14 +129022,15 @@ var ts;
|
|
|
128880
129022
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128881
129023
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128882
129024
|
}
|
|
128883
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128884
|
-
var _a;
|
|
129025
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
129026
|
+
var _a, _b;
|
|
128885
129027
|
var insertText;
|
|
128886
129028
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
128887
129029
|
var data;
|
|
128888
129030
|
var isSnippet;
|
|
128889
129031
|
var sourceDisplay;
|
|
128890
129032
|
var hasAction;
|
|
129033
|
+
var typeChecker = program.getTypeChecker();
|
|
128891
129034
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
128892
129035
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
128893
129036
|
if (origin && originIsThisType(origin)) {
|
|
@@ -128938,12 +129081,11 @@ var ts;
|
|
|
128938
129081
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
128939
129082
|
}
|
|
128940
129083
|
}
|
|
128941
|
-
if (
|
|
128942
|
-
|
|
128943
|
-
|
|
128944
|
-
|
|
128945
|
-
|
|
128946
|
-
hasAction = !importCompletionNode;
|
|
129084
|
+
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
129085
|
+
preferences.includeCompletionsWithInsertText &&
|
|
129086
|
+
completionKind === 3 /* MemberLike */ &&
|
|
129087
|
+
isClassLikeMemberCompletion(symbol, location)) {
|
|
129088
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
|
|
128947
129089
|
}
|
|
128948
129090
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128949
129091
|
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
@@ -128955,7 +129097,7 @@ var ts;
|
|
|
128955
129097
|
&& !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
|
|
128956
129098
|
if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
|
|
128957
129099
|
// If is string like or undefined use quotes
|
|
128958
|
-
insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
129100
|
+
insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128959
129101
|
isSnippet = true;
|
|
128960
129102
|
}
|
|
128961
129103
|
else {
|
|
@@ -128964,13 +129106,20 @@ var ts;
|
|
|
128964
129106
|
}
|
|
128965
129107
|
}
|
|
128966
129108
|
if (useBraces_1) {
|
|
128967
|
-
insertText = escapeSnippetText(name) + "={$1}";
|
|
129109
|
+
insertText = ts.escapeSnippetText(name) + "={$1}";
|
|
128968
129110
|
isSnippet = true;
|
|
128969
129111
|
}
|
|
128970
129112
|
if (isSnippet) {
|
|
128971
129113
|
replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
|
|
128972
129114
|
}
|
|
128973
129115
|
}
|
|
129116
|
+
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
|
129117
|
+
return undefined;
|
|
129118
|
+
}
|
|
129119
|
+
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
129120
|
+
data = originToCompletionEntryData(origin);
|
|
129121
|
+
hasAction = !importCompletionNode;
|
|
129122
|
+
}
|
|
128974
129123
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
128975
129124
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
128976
129125
|
// really we should consider passing the meaning for the node so that we don't report
|
|
@@ -128995,8 +129144,203 @@ var ts;
|
|
|
128995
129144
|
data: data,
|
|
128996
129145
|
};
|
|
128997
129146
|
}
|
|
128998
|
-
function
|
|
128999
|
-
|
|
129147
|
+
function isClassLikeMemberCompletion(symbol, location) {
|
|
129148
|
+
// TODO: support JS files.
|
|
129149
|
+
if (ts.isInJSFile(location)) {
|
|
129150
|
+
return false;
|
|
129151
|
+
}
|
|
129152
|
+
// Completion symbol must be for a class member.
|
|
129153
|
+
var memberFlags = 106500 /* ClassMember */
|
|
129154
|
+
& 900095 /* EnumMemberExcludes */;
|
|
129155
|
+
/* In
|
|
129156
|
+
`class C {
|
|
129157
|
+
|
|
|
129158
|
+
}`
|
|
129159
|
+
`location` is a class-like declaration.
|
|
129160
|
+
In
|
|
129161
|
+
`class C {
|
|
129162
|
+
m|
|
|
129163
|
+
}`
|
|
129164
|
+
`location` is an identifier,
|
|
129165
|
+
`location.parent` is a class element declaration,
|
|
129166
|
+
and `location.parent.parent` is a class-like declaration.
|
|
129167
|
+
In
|
|
129168
|
+
`abstract class C {
|
|
129169
|
+
abstract
|
|
129170
|
+
abstract m|
|
|
129171
|
+
}`
|
|
129172
|
+
`location` is a syntax list (with modifiers as children),
|
|
129173
|
+
and `location.parent` is a class-like declaration.
|
|
129174
|
+
*/
|
|
129175
|
+
return !!(symbol.flags & memberFlags) &&
|
|
129176
|
+
(ts.isClassLike(location) ||
|
|
129177
|
+
(location.parent &&
|
|
129178
|
+
location.parent.parent &&
|
|
129179
|
+
ts.isClassElement(location.parent) &&
|
|
129180
|
+
location === location.parent.name &&
|
|
129181
|
+
ts.isClassLike(location.parent.parent)) ||
|
|
129182
|
+
(location.parent &&
|
|
129183
|
+
ts.isSyntaxList(location) &&
|
|
129184
|
+
ts.isClassLike(location.parent)));
|
|
129185
|
+
}
|
|
129186
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
129187
|
+
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
129188
|
+
if (!classLikeDeclaration) {
|
|
129189
|
+
return { insertText: name };
|
|
129190
|
+
}
|
|
129191
|
+
var isSnippet;
|
|
129192
|
+
var insertText = name;
|
|
129193
|
+
var checker = program.getTypeChecker();
|
|
129194
|
+
var sourceFile = location.getSourceFile();
|
|
129195
|
+
var printer = createSnippetPrinter({
|
|
129196
|
+
removeComments: true,
|
|
129197
|
+
module: options.module,
|
|
129198
|
+
target: options.target,
|
|
129199
|
+
omitTrailingSemicolon: true,
|
|
129200
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
129201
|
+
});
|
|
129202
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
129203
|
+
var body;
|
|
129204
|
+
var tabstopStart = 1;
|
|
129205
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129206
|
+
isSnippet = true;
|
|
129207
|
+
// We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
|
|
129208
|
+
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
129209
|
+
var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
|
|
129210
|
+
ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
|
|
129211
|
+
tabstopStart = 2;
|
|
129212
|
+
body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
|
|
129213
|
+
}
|
|
129214
|
+
else {
|
|
129215
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
129216
|
+
}
|
|
129217
|
+
var modifiers = 0 /* None */;
|
|
129218
|
+
// Whether the suggested member should be abstract.
|
|
129219
|
+
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
|
|
129220
|
+
// Note: We are relying on checking if the context token is `abstract`,
|
|
129221
|
+
// since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
|
|
129222
|
+
// However, that is not true for the e.g. `override` modifier, so this check has its limitations.
|
|
129223
|
+
var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
|
|
129224
|
+
var completionNodes = [];
|
|
129225
|
+
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
|
|
129226
|
+
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
|
|
129227
|
+
// it adds for the given member symbol.
|
|
129228
|
+
// We store these member nodes in the `completionNodes` array.
|
|
129229
|
+
// Note: there might be:
|
|
129230
|
+
// - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
|
|
129231
|
+
// - One node;
|
|
129232
|
+
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
|
|
129233
|
+
function (node) {
|
|
129234
|
+
var requiredModifiers = 0 /* None */;
|
|
129235
|
+
if (isAbstract) {
|
|
129236
|
+
requiredModifiers |= 128 /* Abstract */;
|
|
129237
|
+
}
|
|
129238
|
+
if (ts.isClassElement(node)
|
|
129239
|
+
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
|
|
129240
|
+
requiredModifiers |= 16384 /* Override */;
|
|
129241
|
+
}
|
|
129242
|
+
var presentModifiers = 0 /* None */;
|
|
129243
|
+
if (!completionNodes.length) {
|
|
129244
|
+
// Omit already present modifiers from the first completion node/signature.
|
|
129245
|
+
if (contextToken) {
|
|
129246
|
+
presentModifiers = getPresentModifiers(contextToken);
|
|
129247
|
+
}
|
|
129248
|
+
// Keep track of added missing required modifiers and modifiers already present.
|
|
129249
|
+
// This is needed when we have overloaded signatures,
|
|
129250
|
+
// so this callback will be called for multiple nodes/signatures,
|
|
129251
|
+
// and we need to make sure the modifiers are uniform for all nodes/signatures.
|
|
129252
|
+
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
|
|
129253
|
+
}
|
|
129254
|
+
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
129255
|
+
completionNodes.push(node);
|
|
129256
|
+
}, body, isAbstract);
|
|
129257
|
+
if (completionNodes.length) {
|
|
129258
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129259
|
+
addSnippets(completionNodes, tabstopStart);
|
|
129260
|
+
}
|
|
129261
|
+
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
129262
|
+
}
|
|
129263
|
+
return { insertText: insertText, isSnippet: isSnippet };
|
|
129264
|
+
}
|
|
129265
|
+
function getPresentModifiers(contextToken) {
|
|
129266
|
+
var modifiers = 0 /* None */;
|
|
129267
|
+
var contextMod;
|
|
129268
|
+
/*
|
|
129269
|
+
Cases supported:
|
|
129270
|
+
In
|
|
129271
|
+
`class C {
|
|
129272
|
+
public abstract |
|
|
129273
|
+
}`
|
|
129274
|
+
`contextToken` is ``abstract`` (as an identifier),
|
|
129275
|
+
`contextToken.parent` is property declaration,
|
|
129276
|
+
`location` is class declaration ``class C { ... }``.
|
|
129277
|
+
In
|
|
129278
|
+
`class C {
|
|
129279
|
+
protected override m|
|
|
129280
|
+
}`
|
|
129281
|
+
`contextToken` is ``override`` (as a keyword),
|
|
129282
|
+
`contextToken.parent` is property declaration,
|
|
129283
|
+
`location` is identifier ``m``,
|
|
129284
|
+
`location.parent` is property declaration ``protected override m``,
|
|
129285
|
+
`location.parent.parent` is class declaration ``class C { ... }``.
|
|
129286
|
+
*/
|
|
129287
|
+
if (contextMod = isModifierLike(contextToken)) {
|
|
129288
|
+
modifiers |= ts.modifierToFlag(contextMod);
|
|
129289
|
+
}
|
|
129290
|
+
if (ts.isPropertyDeclaration(contextToken.parent)) {
|
|
129291
|
+
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
|
|
129292
|
+
}
|
|
129293
|
+
return modifiers;
|
|
129294
|
+
}
|
|
129295
|
+
function isModifierLike(node) {
|
|
129296
|
+
if (ts.isModifier(node)) {
|
|
129297
|
+
return node.kind;
|
|
129298
|
+
}
|
|
129299
|
+
if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
|
|
129300
|
+
return node.originalKeywordKind;
|
|
129301
|
+
}
|
|
129302
|
+
return undefined;
|
|
129303
|
+
}
|
|
129304
|
+
function addSnippets(nodes, orderStart) {
|
|
129305
|
+
var order = orderStart;
|
|
129306
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
129307
|
+
var node = nodes_1[_i];
|
|
129308
|
+
addSnippetsWorker(node, /*parent*/ undefined);
|
|
129309
|
+
}
|
|
129310
|
+
function addSnippetsWorker(node, parent) {
|
|
129311
|
+
if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
|
|
129312
|
+
// Placeholder
|
|
129313
|
+
ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
|
|
129314
|
+
order += 1;
|
|
129315
|
+
if (node.type) {
|
|
129316
|
+
ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
|
|
129317
|
+
order += 1;
|
|
129318
|
+
}
|
|
129319
|
+
}
|
|
129320
|
+
else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
129321
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
129322
|
+
order += 1;
|
|
129323
|
+
}
|
|
129324
|
+
else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
129325
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
129326
|
+
order += 1;
|
|
129327
|
+
}
|
|
129328
|
+
ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
|
|
129329
|
+
}
|
|
129330
|
+
}
|
|
129331
|
+
function createSnippetPrinter(printerOptions) {
|
|
129332
|
+
var printer = ts.createPrinter(printerOptions);
|
|
129333
|
+
var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
|
|
129334
|
+
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)); } });
|
|
129335
|
+
return {
|
|
129336
|
+
printSnippetList: printSnippetList,
|
|
129337
|
+
};
|
|
129338
|
+
/* Snippet-escaping version of `printer.printList`. */
|
|
129339
|
+
function printSnippetList(format, list, sourceFile) {
|
|
129340
|
+
writer.clear();
|
|
129341
|
+
printer.writeList(format, list, sourceFile, writer);
|
|
129342
|
+
return writer.getText();
|
|
129343
|
+
}
|
|
129000
129344
|
}
|
|
129001
129345
|
function originToCompletionEntryData(origin) {
|
|
129002
129346
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -129064,10 +129408,10 @@ var ts;
|
|
|
129064
129408
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
|
|
129065
129409
|
var suffix = useSemicolons ? ";" : "";
|
|
129066
129410
|
switch (importKind) {
|
|
129067
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129068
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129069
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129070
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129411
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129412
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129413
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129414
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129071
129415
|
}
|
|
129072
129416
|
}
|
|
129073
129417
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -129091,11 +129435,12 @@ var ts;
|
|
|
129091
129435
|
return CompletionSource.ThisProperty;
|
|
129092
129436
|
}
|
|
129093
129437
|
}
|
|
129094
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile,
|
|
129438
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129095
129439
|
var _a;
|
|
129096
129440
|
var start = ts.timestamp();
|
|
129097
129441
|
var variableDeclaration = getVariableDeclaration(location);
|
|
129098
129442
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
129443
|
+
var typeChecker = program.getTypeChecker();
|
|
129099
129444
|
// Tracks unique names.
|
|
129100
129445
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
129101
129446
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -129111,7 +129456,7 @@ var ts;
|
|
|
129111
129456
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129112
129457
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129113
129458
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129114
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
129459
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
129115
129460
|
if (!entry) {
|
|
129116
129461
|
continue;
|
|
129117
129462
|
}
|
|
@@ -144503,8 +144848,8 @@ var ts;
|
|
|
144503
144848
|
ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
|
|
144504
144849
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
144505
144850
|
// When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
|
|
144506
|
-
for (var _i = 0,
|
|
144507
|
-
var node =
|
|
144851
|
+
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
144852
|
+
var node = nodes_2[_i];
|
|
144508
144853
|
var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
|
|
144509
144854
|
var end = getAdjustedEndPosition(sourceFile, node, options);
|
|
144510
144855
|
this.deleteRange(sourceFile, { pos: pos, end: end });
|
|
@@ -145144,7 +145489,7 @@ var ts;
|
|
|
145144
145489
|
/** Note: output node may be mutated input node. */
|
|
145145
145490
|
function getNonformattedText(node, sourceFile, newLineCharacter) {
|
|
145146
145491
|
var writer = createWriter(newLineCharacter);
|
|
145147
|
-
var newLine = newLineCharacter
|
|
145492
|
+
var newLine = ts.getNewLineKind(newLineCharacter);
|
|
145148
145493
|
ts.createPrinter({
|
|
145149
145494
|
newLine: newLine,
|
|
145150
145495
|
neverAsciiEscape: true,
|
|
@@ -152745,7 +153090,7 @@ var ts;
|
|
|
152745
153090
|
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
|
|
152746
153091
|
var symbol = possiblyMissingSymbols_1[_i];
|
|
152747
153092
|
if (!classMembers.has(symbol.escapedName)) {
|
|
152748
|
-
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
|
|
153093
|
+
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
|
152749
153094
|
}
|
|
152750
153095
|
}
|
|
152751
153096
|
}
|
|
@@ -152758,9 +153103,11 @@ var ts;
|
|
|
152758
153103
|
}
|
|
152759
153104
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152760
153105
|
/**
|
|
152761
|
-
*
|
|
153106
|
+
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
153107
|
+
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152762
153108
|
*/
|
|
152763
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
|
|
153109
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
153110
|
+
if (isAmbient === void 0) { isAmbient = false; }
|
|
152764
153111
|
var declarations = symbol.getDeclarations();
|
|
152765
153112
|
if (!(declarations && declarations.length)) {
|
|
152766
153113
|
return undefined;
|
|
@@ -152773,7 +153120,7 @@ var ts;
|
|
|
152773
153120
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
152774
153121
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
152775
153122
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
152776
|
-
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
|
|
153123
|
+
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
|
|
152777
153124
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
152778
153125
|
switch (declaration.kind) {
|
|
152779
153126
|
case 165 /* PropertySignature */:
|
|
@@ -152809,14 +153156,14 @@ var ts;
|
|
|
152809
153156
|
var accessor = orderedAccessors_1[_i];
|
|
152810
153157
|
if (ts.isGetAccessorDeclaration(accessor)) {
|
|
152811
153158
|
addClassElement(ts.factory.createGetAccessorDeclaration(
|
|
152812
|
-
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153159
|
+
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152813
153160
|
}
|
|
152814
153161
|
else {
|
|
152815
153162
|
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
|
|
152816
153163
|
var parameter = ts.getSetAccessorValueParameter(accessor);
|
|
152817
153164
|
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
|
|
152818
153165
|
addClassElement(ts.factory.createSetAccessorDeclaration(
|
|
152819
|
-
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153166
|
+
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152820
153167
|
}
|
|
152821
153168
|
}
|
|
152822
153169
|
break;
|
|
@@ -152837,7 +153184,7 @@ var ts;
|
|
|
152837
153184
|
if (declarations.length === 1) {
|
|
152838
153185
|
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
|
|
152839
153186
|
var signature = signatures[0];
|
|
152840
|
-
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
|
|
153187
|
+
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
|
|
152841
153188
|
break;
|
|
152842
153189
|
}
|
|
152843
153190
|
for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
|
|
@@ -152848,11 +153195,11 @@ var ts;
|
|
|
152848
153195
|
if (!ambient) {
|
|
152849
153196
|
if (declarations.length > signatures.length) {
|
|
152850
153197
|
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
|
|
152851
|
-
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
|
|
153198
|
+
outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
|
|
152852
153199
|
}
|
|
152853
153200
|
else {
|
|
152854
153201
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152855
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
|
|
153202
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152856
153203
|
}
|
|
152857
153204
|
}
|
|
152858
153205
|
break;
|
|
@@ -152863,6 +153210,7 @@ var ts;
|
|
|
152863
153210
|
addClassElement(method);
|
|
152864
153211
|
}
|
|
152865
153212
|
}
|
|
153213
|
+
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
|
|
152866
153214
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
152867
153215
|
var program = context.program;
|
|
152868
153216
|
var checker = program.getTypeChecker();
|
|
@@ -153000,7 +153348,7 @@ var ts;
|
|
|
153000
153348
|
}
|
|
153001
153349
|
return parameters;
|
|
153002
153350
|
}
|
|
153003
|
-
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
|
|
153351
|
+
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
|
|
153004
153352
|
/** This is *a* signature with the maximal number of arguments,
|
|
153005
153353
|
* such that if there is a "maximal" signature without rest arguments,
|
|
153006
153354
|
* this is one of them.
|
|
@@ -153031,7 +153379,7 @@ var ts;
|
|
|
153031
153379
|
parameters.push(restParameter);
|
|
153032
153380
|
}
|
|
153033
153381
|
return createStubbedMethod(modifiers, name, optional,
|
|
153034
|
-
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
|
|
153382
|
+
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
|
|
153035
153383
|
}
|
|
153036
153384
|
function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
|
|
153037
153385
|
if (ts.length(signatures)) {
|
|
@@ -153039,10 +153387,10 @@ var ts;
|
|
|
153039
153387
|
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
|
|
153040
153388
|
}
|
|
153041
153389
|
}
|
|
153042
|
-
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
|
|
153390
|
+
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
|
|
153043
153391
|
return ts.factory.createMethodDeclaration(
|
|
153044
153392
|
/*decorators*/ undefined, modifiers,
|
|
153045
|
-
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
|
|
153393
|
+
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
|
|
153046
153394
|
}
|
|
153047
153395
|
function createStubbedMethodBody(quotePreference) {
|
|
153048
153396
|
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
|
|
@@ -159053,8 +159401,8 @@ var ts;
|
|
|
159053
159401
|
var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
|
|
159054
159402
|
list._children = [];
|
|
159055
159403
|
var pos = nodes.pos;
|
|
159056
|
-
for (var _i = 0,
|
|
159057
|
-
var node =
|
|
159404
|
+
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
159405
|
+
var node = nodes_3[_i];
|
|
159058
159406
|
addSyntheticNodes(list._children, pos, node.pos, parent);
|
|
159059
159407
|
list._children.push(node);
|
|
159060
159408
|
pos = node.end;
|