@tslite/services 1.16.0 → 1.17.0

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.
Files changed (123) hide show
  1. package/NOTICE +3 -1
  2. package/dist/_namespaces/edit.d.ts +1 -1
  3. package/dist/_namespaces/edit.js +10759 -11
  4. package/dist/_namespaces/ts.codefix.d.ts +0 -1
  5. package/dist/_namespaces/ts.js +10196 -19
  6. package/dist/classifier.d.ts +3 -1
  7. package/dist/codeFixProvider.d.ts +2 -1
  8. package/dist/codefixes/helpers.d.ts +3 -1
  9. package/dist/codefixes/importFixes.d.ts +3 -1
  10. package/dist/completions.d.ts +5 -2
  11. package/dist/documentHighlights.d.ts +3 -1
  12. package/dist/documentRegistry.d.ts +2 -1
  13. package/dist/findAllReferences.d.ts +3 -1
  14. package/dist/formatting/formatting.d.ts +3 -2
  15. package/dist/formatting/formattingContext.d.ts +2 -1
  16. package/dist/formatting/formattingScanner.d.ts +2 -2
  17. package/dist/formatting/rule.d.ts +1 -1
  18. package/dist/formatting/rulesMap.d.ts +1 -1
  19. package/dist/formatting/smartIndenter.d.ts +2 -1
  20. package/dist/getEditsForFileRename.d.ts +4 -1
  21. package/dist/goToDefinition.d.ts +3 -1
  22. package/dist/importTracker.d.ts +2 -1
  23. package/dist/navigationBar.d.ts +3 -1
  24. package/dist/organizeImports.d.ts +4 -2
  25. package/dist/outliningElementsCollector.d.ts +3 -1
  26. package/dist/refactorProvider.d.ts +1 -1
  27. package/dist/refactors/extractSymbol.d.ts +2 -1
  28. package/dist/rename.d.ts +3 -1
  29. package/dist/services.d.ts +5 -2
  30. package/dist/signatureHelp.d.ts +3 -1
  31. package/dist/smartSelection.d.ts +2 -1
  32. package/dist/stringCompletions.d.ts +3 -1
  33. package/dist/suggestionDiagnostics.d.ts +4 -3
  34. package/dist/symbolDisplay.d.ts +3 -1
  35. package/dist/textChanges.d.ts +4 -2
  36. package/dist/types.d.ts +3 -3
  37. package/dist/utilities.d.ts +7 -2
  38. package/package.json +7 -5
  39. package/dist/_namespaces/ts.Completions.StringCompletions.js +0 -2
  40. package/dist/_namespaces/ts.Completions.js +0 -3
  41. package/dist/_namespaces/ts.FindAllReferences.js +0 -3
  42. package/dist/_namespaces/ts.GoToDefinition.js +0 -2
  43. package/dist/_namespaces/ts.NavigationBar.js +0 -2
  44. package/dist/_namespaces/ts.OrganizeImports.js +0 -2
  45. package/dist/_namespaces/ts.OutliningElementsCollector.js +0 -2
  46. package/dist/_namespaces/ts.Rename.js +0 -2
  47. package/dist/_namespaces/ts.SignatureHelp.js +0 -2
  48. package/dist/_namespaces/ts.SmartSelectionRange.js +0 -2
  49. package/dist/_namespaces/ts.SymbolDisplay.js +0 -2
  50. package/dist/_namespaces/ts.codefix.js +0 -27
  51. package/dist/_namespaces/ts.formatting.js +0 -8
  52. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +0 -2
  53. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +0 -2
  54. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +0 -2
  55. package/dist/_namespaces/ts.refactor.extractSymbol.js +0 -2
  56. package/dist/_namespaces/ts.refactor.js +0 -10
  57. package/dist/_namespaces/ts.textChanges.js +0 -2
  58. package/dist/classifier.js +0 -715
  59. package/dist/codeFixProvider.js +0 -84
  60. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +0 -1
  61. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +0 -21
  62. package/dist/codefixes/addEmptyExportDeclaration.js +0 -17
  63. package/dist/codefixes/addMissingAsync.js +0 -75
  64. package/dist/codefixes/addMissingAwait.js +0 -236
  65. package/dist/codefixes/addMissingConst.js +0 -91
  66. package/dist/codefixes/addNameToNamelessParameter.js +0 -29
  67. package/dist/codefixes/convertConstToLet.js +0 -30
  68. package/dist/codefixes/convertToAsyncFunction.js +0 -495
  69. package/dist/codefixes/convertToMappedObjectType.js +0 -48
  70. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +0 -33
  71. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +0 -27
  72. package/dist/codefixes/fixAwaitInSyncFunction.js +0 -69
  73. package/dist/codefixes/fixExpectedComma.js +0 -35
  74. package/dist/codefixes/fixInvalidJsxCharacters.js +0 -41
  75. package/dist/codefixes/fixMissingCallParentheses.js +0 -42
  76. package/dist/codefixes/fixSpelling.js +0 -94
  77. package/dist/codefixes/fixUnreachableCode.js +0 -65
  78. package/dist/codefixes/fixUnusedIdentifier.js +0 -224
  79. package/dist/codefixes/helpers.js +0 -53
  80. package/dist/codefixes/importFixes.js +0 -441
  81. package/dist/codefixes/inferFromUsage.js +0 -742
  82. package/dist/codefixes/removeUnnecessaryAwait.js +0 -41
  83. package/dist/codefixes/returnValueCorrect.js +0 -132
  84. package/dist/codefixes/splitTypeOnlyImport.js +0 -32
  85. package/dist/codefixes/useBigintLiteral.js +0 -29
  86. package/dist/completions.js +0 -1720
  87. package/dist/documentHighlights.js +0 -367
  88. package/dist/documentRegistry.js +0 -63
  89. package/dist/editingServices.js +0 -4
  90. package/dist/findAllReferences.js +0 -1366
  91. package/dist/formatting/formatting.js +0 -1021
  92. package/dist/formatting/formattingContext.js +0 -78
  93. package/dist/formatting/formattingScanner.js +0 -228
  94. package/dist/formatting/rule.js +0 -22
  95. package/dist/formatting/rules.js +0 -610
  96. package/dist/formatting/rulesMap.js +0 -127
  97. package/dist/formatting/smartIndenter.js +0 -518
  98. package/dist/getEditsForFileRename.js +0 -86
  99. package/dist/goToDefinition.js +0 -246
  100. package/dist/importTracker.js +0 -422
  101. package/dist/index.js +0 -3
  102. package/dist/navigationBar.js +0 -549
  103. package/dist/organizeImports.js +0 -290
  104. package/dist/outliningElementsCollector.js +0 -261
  105. package/dist/refactorProvider.js +0 -16
  106. package/dist/refactors/addOrRemoveBracesToArrowFunction.js +0 -86
  107. package/dist/refactors/convertExport.js +0 -126
  108. package/dist/refactors/convertImport.js +0 -116
  109. package/dist/refactors/convertParamsToDestructuredObject.js +0 -282
  110. package/dist/refactors/convertStringOrTemplateLiteral.js +0 -148
  111. package/dist/refactors/extractSymbol.js +0 -1281
  112. package/dist/refactors/extractType.js +0 -102
  113. package/dist/refactors/moveToNewFile.js +0 -477
  114. package/dist/rename.js +0 -100
  115. package/dist/services.js +0 -1480
  116. package/dist/signatureHelp.js +0 -414
  117. package/dist/smartSelection.js +0 -243
  118. package/dist/stringCompletions.js +0 -220
  119. package/dist/suggestionDiagnostics.js +0 -92
  120. package/dist/symbolDisplay.js +0 -400
  121. package/dist/textChanges.js +0 -1163
  122. package/dist/types.js +0 -263
  123. package/dist/utilities.js +0 -1981
@@ -1,148 +0,0 @@
1
- // Modificado de microsoft/TypeScript v3.9.10, src/services/refactors/convertStringOrTemplateLiteral.ts: o namespace virou módulo ES, com os imports explícitos.
2
- import { Debug, Diagnostics, SyntaxKind, copyTrailingAsLeadingComments, copyTrailingComments, createNoSubstitutionTemplateLiteral, createTemplateExpression, createTemplateHead, createTemplateMiddle, createTemplateSpan, createTemplateTail, emptyArray, getLocaleSpecificMessage, getTokenAtPosition, getTrailingCommentRanges, isBinaryExpression, isParenthesizedExpression, isStringLiteral, textChanges, } from "../_namespaces/edit.js";
3
- import { registerRefactor, } from "../_namespaces/ts.refactor.js";
4
- const refactorName = "Convert to template string";
5
- const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
6
- registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
7
- function getAvailableActions(context) {
8
- const { file, startPosition } = context;
9
- const node = getNodeOrParentOfParentheses(file, startPosition);
10
- const maybeBinary = getParentBinaryExpression(node);
11
- const refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
12
- if (isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
13
- refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
14
- return [refactorInfo];
15
- }
16
- return emptyArray;
17
- }
18
- function getNodeOrParentOfParentheses(file, startPosition) {
19
- const node = getTokenAtPosition(file, startPosition);
20
- const nestedBinary = getParentBinaryExpression(node);
21
- const isNonStringBinary = !isStringConcatenationValid(nestedBinary);
22
- if (isNonStringBinary &&
23
- isParenthesizedExpression(nestedBinary.parent) &&
24
- isBinaryExpression(nestedBinary.parent.parent)) {
25
- return nestedBinary.parent.parent;
26
- }
27
- return node;
28
- }
29
- function getEditsForAction(context, actionName) {
30
- const { file, startPosition } = context;
31
- const node = getNodeOrParentOfParentheses(file, startPosition);
32
- switch (actionName) {
33
- case refactorDescription:
34
- return { edits: getEditsForToTemplateLiteral(context, node) };
35
- default:
36
- return Debug.fail("invalid action");
37
- }
38
- }
39
- function getEditsForToTemplateLiteral(context, node) {
40
- const maybeBinary = getParentBinaryExpression(node);
41
- const file = context.file;
42
- const templateLiteral = nodesToTemplate(treeToArray(maybeBinary), file);
43
- const trailingCommentRanges = getTrailingCommentRanges(file.text, maybeBinary.end);
44
- if (trailingCommentRanges) {
45
- const lastComment = trailingCommentRanges[trailingCommentRanges.length - 1];
46
- const trailingRange = { pos: trailingCommentRanges[0].pos, end: lastComment.end };
47
- // since suppressTrailingTrivia(maybeBinary) does not work, the trailing comment is removed manually
48
- // otherwise it would have the trailing comment twice
49
- return textChanges.ChangeTracker.with(context, t => {
50
- t.deleteRange(file, trailingRange);
51
- t.replaceNode(file, maybeBinary, templateLiteral);
52
- });
53
- }
54
- else {
55
- return textChanges.ChangeTracker.with(context, t => t.replaceNode(file, maybeBinary, templateLiteral));
56
- }
57
- }
58
- function isNotEqualsOperator(node) {
59
- return node.operatorToken.kind !== SyntaxKind.EqualsToken;
60
- }
61
- function getParentBinaryExpression(expr) {
62
- while (isBinaryExpression(expr.parent) && isNotEqualsOperator(expr.parent)) {
63
- expr = expr.parent;
64
- }
65
- return expr;
66
- }
67
- function isStringConcatenationValid(node) {
68
- const { containsString, areOperatorsValid } = treeToArray(node);
69
- return containsString && areOperatorsValid;
70
- }
71
- function treeToArray(current) {
72
- if (isBinaryExpression(current)) {
73
- const { nodes, operators, containsString: leftHasString, areOperatorsValid: leftOperatorValid } = treeToArray(current.left);
74
- if (!leftHasString && !isStringLiteral(current.right)) {
75
- return { nodes: [current], operators: [], containsString: false, areOperatorsValid: true };
76
- }
77
- const currentOperatorValid = current.operatorToken.kind === SyntaxKind.PlusToken;
78
- const areOperatorsValid = leftOperatorValid && currentOperatorValid;
79
- nodes.push(current.right);
80
- operators.push(current.operatorToken);
81
- return { nodes, operators, containsString: true, areOperatorsValid };
82
- }
83
- return { nodes: [current], operators: [], containsString: isStringLiteral(current), areOperatorsValid: true };
84
- }
85
- // to copy comments following the operator
86
- // "foo" + /* comment */ "bar"
87
- const copyTrailingOperatorComments = (operators, file) => (index, targetNode) => {
88
- if (index < operators.length) {
89
- copyTrailingComments(operators[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
90
- }
91
- };
92
- // to copy comments following the string
93
- // "foo" /* comment */ + "bar" /* comment */ + "bar2"
94
- const copyCommentFromMultiNode = (nodes, file, copyOperatorComments) => (indexes, targetNode) => {
95
- while (indexes.length > 0) {
96
- const index = indexes.shift();
97
- copyTrailingComments(nodes[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
98
- copyOperatorComments(index, targetNode);
99
- }
100
- };
101
- function concatConsecutiveString(index, nodes) {
102
- let text = "";
103
- const indexes = [];
104
- while (index < nodes.length && isStringLiteral(nodes[index])) {
105
- const stringNode = nodes[index];
106
- text = text + stringNode.text;
107
- indexes.push(index);
108
- index++;
109
- }
110
- return [index, text, indexes];
111
- }
112
- function nodesToTemplate({ nodes, operators }, file) {
113
- const copyOperatorComments = copyTrailingOperatorComments(operators, file);
114
- const copyCommentFromStringLiterals = copyCommentFromMultiNode(nodes, file, copyOperatorComments);
115
- const [begin, headText, headIndexes] = concatConsecutiveString(0, nodes);
116
- if (begin === nodes.length) {
117
- const noSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral(headText);
118
- copyCommentFromStringLiterals(headIndexes, noSubstitutionTemplateLiteral);
119
- return noSubstitutionTemplateLiteral;
120
- }
121
- const templateSpans = [];
122
- const templateHead = createTemplateHead(headText);
123
- copyCommentFromStringLiterals(headIndexes, templateHead);
124
- for (let i = begin; i < nodes.length; i++) {
125
- const currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
126
- copyOperatorComments(i, currentNode);
127
- const [newIndex, subsequentText, stringIndexes] = concatConsecutiveString(i + 1, nodes);
128
- i = newIndex - 1;
129
- const templatePart = i === nodes.length - 1 ? createTemplateTail(subsequentText) : createTemplateMiddle(subsequentText);
130
- copyCommentFromStringLiterals(stringIndexes, templatePart);
131
- templateSpans.push(createTemplateSpan(currentNode, templatePart));
132
- }
133
- return createTemplateExpression(templateHead, templateSpans);
134
- }
135
- // to copy comments following the opening & closing parentheses
136
- // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar"
137
- function copyCommentsWhenParenthesized(node) {
138
- const file = node.getSourceFile();
139
- copyTrailingComments(node, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
140
- copyTrailingAsLeadingComments(node.expression, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
141
- }
142
- function getExpressionFromParenthesesOrExpression(node) {
143
- if (isParenthesizedExpression(node)) {
144
- copyCommentsWhenParenthesized(node);
145
- node = node.expression;
146
- }
147
- return node;
148
- }