@tslite/services 0.0.0-stage → 1.13.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 (176) hide show
  1. package/LICENSE +55 -0
  2. package/NOTICE +13 -0
  3. package/dist/_namespaces/edit.d.ts +8 -0
  4. package/dist/_namespaces/edit.js +11 -0
  5. package/dist/_namespaces/ts.Completions.StringCompletions.d.ts +1 -0
  6. package/dist/_namespaces/ts.Completions.StringCompletions.js +2 -0
  7. package/dist/_namespaces/ts.Completions.d.ts +2 -0
  8. package/dist/_namespaces/ts.Completions.js +3 -0
  9. package/dist/_namespaces/ts.FindAllReferences.d.ts +2 -0
  10. package/dist/_namespaces/ts.FindAllReferences.js +3 -0
  11. package/dist/_namespaces/ts.GoToDefinition.d.ts +1 -0
  12. package/dist/_namespaces/ts.GoToDefinition.js +2 -0
  13. package/dist/_namespaces/ts.NavigationBar.d.ts +1 -0
  14. package/dist/_namespaces/ts.NavigationBar.js +2 -0
  15. package/dist/_namespaces/ts.OrganizeImports.d.ts +1 -0
  16. package/dist/_namespaces/ts.OrganizeImports.js +2 -0
  17. package/dist/_namespaces/ts.OutliningElementsCollector.d.ts +1 -0
  18. package/dist/_namespaces/ts.OutliningElementsCollector.js +2 -0
  19. package/dist/_namespaces/ts.Rename.d.ts +1 -0
  20. package/dist/_namespaces/ts.Rename.js +2 -0
  21. package/dist/_namespaces/ts.SignatureHelp.d.ts +1 -0
  22. package/dist/_namespaces/ts.SignatureHelp.js +2 -0
  23. package/dist/_namespaces/ts.SmartSelectionRange.d.ts +1 -0
  24. package/dist/_namespaces/ts.SmartSelectionRange.js +2 -0
  25. package/dist/_namespaces/ts.SymbolDisplay.d.ts +1 -0
  26. package/dist/_namespaces/ts.SymbolDisplay.js +2 -0
  27. package/dist/_namespaces/ts.codefix.d.ts +26 -0
  28. package/dist/_namespaces/ts.codefix.js +27 -0
  29. package/dist/_namespaces/ts.d.ts +17 -0
  30. package/dist/_namespaces/ts.formatting.d.ts +7 -0
  31. package/dist/_namespaces/ts.formatting.js +8 -0
  32. package/dist/_namespaces/ts.js +20 -0
  33. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.d.ts +1 -0
  34. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +2 -0
  35. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.d.ts +1 -0
  36. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +2 -0
  37. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.d.ts +1 -0
  38. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +2 -0
  39. package/dist/_namespaces/ts.refactor.d.ts +9 -0
  40. package/dist/_namespaces/ts.refactor.extractSymbol.d.ts +1 -0
  41. package/dist/_namespaces/ts.refactor.extractSymbol.js +2 -0
  42. package/dist/_namespaces/ts.refactor.js +10 -0
  43. package/dist/_namespaces/ts.textChanges.d.ts +1 -0
  44. package/dist/_namespaces/ts.textChanges.js +2 -0
  45. package/dist/classifier.d.ts +5 -0
  46. package/dist/classifier.js +439 -0
  47. package/dist/codeFixProvider.d.ts +13 -0
  48. package/dist/codeFixProvider.js +84 -0
  49. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +1 -0
  50. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +21 -0
  51. package/dist/codefixes/addEmptyExportDeclaration.d.ts +1 -0
  52. package/dist/codefixes/addEmptyExportDeclaration.js +17 -0
  53. package/dist/codefixes/addMissingAsync.d.ts +1 -0
  54. package/dist/codefixes/addMissingAsync.js +75 -0
  55. package/dist/codefixes/addMissingAwait.d.ts +1 -0
  56. package/dist/codefixes/addMissingAwait.js +236 -0
  57. package/dist/codefixes/addMissingConst.d.ts +1 -0
  58. package/dist/codefixes/addMissingConst.js +91 -0
  59. package/dist/codefixes/addNameToNamelessParameter.d.ts +1 -0
  60. package/dist/codefixes/addNameToNamelessParameter.js +29 -0
  61. package/dist/codefixes/convertConstToLet.d.ts +1 -0
  62. package/dist/codefixes/convertConstToLet.js +30 -0
  63. package/dist/codefixes/convertToAsyncFunction.d.ts +1 -0
  64. package/dist/codefixes/convertToAsyncFunction.js +495 -0
  65. package/dist/codefixes/convertToMappedObjectType.d.ts +1 -0
  66. package/dist/codefixes/convertToMappedObjectType.js +48 -0
  67. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.d.ts +1 -0
  68. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +33 -0
  69. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.d.ts +1 -0
  70. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +27 -0
  71. package/dist/codefixes/fixAwaitInSyncFunction.d.ts +1 -0
  72. package/dist/codefixes/fixAwaitInSyncFunction.js +69 -0
  73. package/dist/codefixes/fixExpectedComma.d.ts +1 -0
  74. package/dist/codefixes/fixExpectedComma.js +35 -0
  75. package/dist/codefixes/fixInvalidJsxCharacters.d.ts +1 -0
  76. package/dist/codefixes/fixInvalidJsxCharacters.js +41 -0
  77. package/dist/codefixes/fixMissingCallParentheses.d.ts +1 -0
  78. package/dist/codefixes/fixMissingCallParentheses.js +42 -0
  79. package/dist/codefixes/fixSpelling.d.ts +1 -0
  80. package/dist/codefixes/fixSpelling.js +94 -0
  81. package/dist/codefixes/fixUnreachableCode.d.ts +1 -0
  82. package/dist/codefixes/fixUnreachableCode.js +65 -0
  83. package/dist/codefixes/fixUnusedIdentifier.d.ts +1 -0
  84. package/dist/codefixes/fixUnusedIdentifier.js +224 -0
  85. package/dist/codefixes/helpers.d.ts +8 -0
  86. package/dist/codefixes/helpers.js +53 -0
  87. package/dist/codefixes/importFixes.d.ts +14 -0
  88. package/dist/codefixes/importFixes.js +441 -0
  89. package/dist/codefixes/inferFromUsage.d.ts +1 -0
  90. package/dist/codefixes/inferFromUsage.js +742 -0
  91. package/dist/codefixes/removeUnnecessaryAwait.d.ts +1 -0
  92. package/dist/codefixes/removeUnnecessaryAwait.js +41 -0
  93. package/dist/codefixes/returnValueCorrect.d.ts +1 -0
  94. package/dist/codefixes/returnValueCorrect.js +132 -0
  95. package/dist/codefixes/splitTypeOnlyImport.d.ts +1 -0
  96. package/dist/codefixes/splitTypeOnlyImport.js +32 -0
  97. package/dist/codefixes/useBigintLiteral.d.ts +1 -0
  98. package/dist/codefixes/useBigintLiteral.js +29 -0
  99. package/dist/completions.d.ts +83 -0
  100. package/dist/completions.js +1720 -0
  101. package/dist/documentHighlights.d.ts +8 -0
  102. package/dist/documentHighlights.js +367 -0
  103. package/dist/documentRegistry.d.ts +36 -0
  104. package/dist/documentRegistry.js +63 -0
  105. package/dist/editingServices.d.ts +1 -0
  106. package/dist/editingServices.js +4 -0
  107. package/dist/findAllReferences.d.ts +113 -0
  108. package/dist/findAllReferences.js +1366 -0
  109. package/dist/formatting/formatting.d.ts +26 -0
  110. package/dist/formatting/formatting.js +1021 -0
  111. package/dist/formatting/formattingContext.d.ts +34 -0
  112. package/dist/formatting/formattingContext.js +78 -0
  113. package/dist/formatting/formattingScanner.d.ts +14 -0
  114. package/dist/formatting/formattingScanner.js +228 -0
  115. package/dist/formatting/rule.d.ts +31 -0
  116. package/dist/formatting/rule.js +22 -0
  117. package/dist/formatting/rules.d.ts +7 -0
  118. package/dist/formatting/rules.js +610 -0
  119. package/dist/formatting/rulesMap.d.ts +5 -0
  120. package/dist/formatting/rulesMap.js +127 -0
  121. package/dist/formatting/smartIndenter.d.ts +44 -0
  122. package/dist/formatting/smartIndenter.js +518 -0
  123. package/dist/getEditsForFileRename.d.ts +6 -0
  124. package/dist/getEditsForFileRename.js +86 -0
  125. package/dist/goToDefinition.d.ts +8 -0
  126. package/dist/goToDefinition.js +246 -0
  127. package/dist/importTracker.d.ts +50 -0
  128. package/dist/importTracker.js +422 -0
  129. package/dist/index.d.ts +1 -0
  130. package/dist/index.js +3 -0
  131. package/dist/navigationBar.d.ts +3 -0
  132. package/dist/navigationBar.js +549 -0
  133. package/dist/organizeImports.d.ts +18 -0
  134. package/dist/organizeImports.js +290 -0
  135. package/dist/outliningElementsCollector.d.ts +2 -0
  136. package/dist/outliningElementsCollector.js +261 -0
  137. package/dist/refactorProvider.d.ts +5 -0
  138. package/dist/refactorProvider.js +16 -0
  139. package/dist/refactors/addOrRemoveBracesToArrowFunction.d.ts +1 -0
  140. package/dist/refactors/addOrRemoveBracesToArrowFunction.js +86 -0
  141. package/dist/refactors/convertExport.d.ts +1 -0
  142. package/dist/refactors/convertExport.js +126 -0
  143. package/dist/refactors/convertImport.d.ts +1 -0
  144. package/dist/refactors/convertImport.js +116 -0
  145. package/dist/refactors/convertParamsToDestructuredObject.d.ts +1 -0
  146. package/dist/refactors/convertParamsToDestructuredObject.js +282 -0
  147. package/dist/refactors/convertStringOrTemplateLiteral.d.ts +1 -0
  148. package/dist/refactors/convertStringOrTemplateLiteral.js +148 -0
  149. package/dist/refactors/extractSymbol.d.ts +60 -0
  150. package/dist/refactors/extractSymbol.js +1281 -0
  151. package/dist/refactors/extractType.d.ts +1 -0
  152. package/dist/refactors/extractType.js +102 -0
  153. package/dist/refactors/moveToNewFile.d.ts +1 -0
  154. package/dist/refactors/moveToNewFile.js +477 -0
  155. package/dist/rename.d.ts +2 -0
  156. package/dist/rename.js +100 -0
  157. package/dist/services.d.ts +48 -0
  158. package/dist/services.js +1480 -0
  159. package/dist/signatureHelp.d.ts +8 -0
  160. package/dist/signatureHelp.js +414 -0
  161. package/dist/smartSelection.d.ts +2 -0
  162. package/dist/smartSelection.js +243 -0
  163. package/dist/stringCompletions.d.ts +4 -0
  164. package/dist/stringCompletions.js +220 -0
  165. package/dist/suggestionDiagnostics.d.ts +6 -0
  166. package/dist/suggestionDiagnostics.js +92 -0
  167. package/dist/symbolDisplay.d.ts +16 -0
  168. package/dist/symbolDisplay.js +400 -0
  169. package/dist/textChanges.d.ts +161 -0
  170. package/dist/textChanges.js +1163 -0
  171. package/dist/types.d.ts +908 -0
  172. package/dist/types.js +263 -0
  173. package/dist/utilities.d.ts +283 -0
  174. package/dist/utilities.js +1981 -0
  175. package/package.json +45 -3
  176. package/README.md +0 -3
@@ -0,0 +1,518 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/formatting/smartIndenter.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { CharacterCodes, Debug, IndentStyle, SyntaxKind, contains, find, findChildOfKind, findListItemInfo, findNextToken, findPrecedingToken, getLineAndCharacterOfPosition, getLineStartPositionForPosition, getRangeOfEnclosingComment, getStartPositionOfLine, isCallExpression, isCallOrNewExpression, isDeclaration, isStatementButNotDeclaration, isStringOrRegularExpressionOrTemplateLiteral, isWhiteSpaceLike, isWhiteSpaceSingleLine, positionBelongsToNode, rangeContainsRange, rangeContainsStartEnd, skipTrivia, } from "../_namespaces/edit.js";
3
+ export var SmartIndenter;
4
+ (function (SmartIndenter) {
5
+ let Value;
6
+ (function (Value) {
7
+ Value[Value["Unknown"] = -1] = "Unknown";
8
+ })(Value || (Value = {}));
9
+ /**
10
+ * @param assumeNewLineBeforeCloseBrace
11
+ * `false` when called on text from a real source file.
12
+ * `true` when we need to assume `position` is on a newline.
13
+ *
14
+ * This is useful for codefixes. Consider
15
+ * ```
16
+ * function f() {
17
+ * |}
18
+ * ```
19
+ * with `position` at `|`.
20
+ *
21
+ * When inserting some text after an open brace, we would like to get indentation as if a newline was already there.
22
+ * By default indentation at `position` will be 0 so 'assumeNewLineBeforeCloseBrace' overrides this behavior.
23
+ */
24
+ function getIndentation(position, sourceFile, options, assumeNewLineBeforeCloseBrace = false) {
25
+ if (position > sourceFile.text.length) {
26
+ return getBaseIndentation(options); // past EOF
27
+ }
28
+ // no indentation when the indent style is set to none,
29
+ // so we can return fast
30
+ if (options.indentStyle === IndentStyle.None) {
31
+ return 0;
32
+ }
33
+ // Na tag, sem o token de um JSDoc (o `excludeJsdoc`, CK-03).
34
+ const precedingToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined);
35
+ // eslint-disable-next-line no-null/no-null
36
+ const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, precedingToken || null);
37
+ if (enclosingCommentRange && enclosingCommentRange.kind === SyntaxKind.MultiLineCommentTrivia) {
38
+ return getCommentIndent(sourceFile, position, options, enclosingCommentRange);
39
+ }
40
+ if (!precedingToken) {
41
+ return getBaseIndentation(options);
42
+ }
43
+ // no indentation in string \regex\template literals
44
+ const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
45
+ if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < precedingToken.end) {
46
+ return 0;
47
+ }
48
+ const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
49
+ // indentation is first non-whitespace character in a previous line
50
+ // for block indentation, we should look for a line which contains something that's not
51
+ // whitespace.
52
+ if (options.indentStyle === IndentStyle.Block) {
53
+ return getBlockIndent(sourceFile, position, options);
54
+ }
55
+ if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
56
+ // previous token is comma that separates items in list - find the previous item and try to derive indentation from it
57
+ const actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
58
+ if (actualIndentation !== -1 /* Value.Unknown */) {
59
+ return actualIndentation;
60
+ }
61
+ }
62
+ const containerList = getListByPosition(position, precedingToken.parent, sourceFile);
63
+ // use list position if the preceding token is before any list items
64
+ if (containerList && !rangeContainsRange(containerList, precedingToken)) {
65
+ return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize; // TODO: GH#18217
66
+ }
67
+ return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
68
+ }
69
+ SmartIndenter.getIndentation = getIndentation;
70
+ function getCommentIndent(sourceFile, position, options, enclosingCommentRange) {
71
+ const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1;
72
+ const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line;
73
+ Debug.assert(commentStartLine >= 0);
74
+ if (previousLine <= commentStartLine) {
75
+ return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options);
76
+ }
77
+ const startPositionOfLine = getStartPositionOfLine(previousLine, sourceFile);
78
+ const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPositionOfLine, position, sourceFile, options);
79
+ if (column === 0) {
80
+ return column;
81
+ }
82
+ const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character);
83
+ return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column;
84
+ }
85
+ function getBlockIndent(sourceFile, position, options) {
86
+ // move backwards until we find a line with a non-whitespace character,
87
+ // then find the first non-whitespace character for that line.
88
+ let current = position;
89
+ while (current > 0) {
90
+ const char = sourceFile.text.charCodeAt(current);
91
+ if (!isWhiteSpaceLike(char)) {
92
+ break;
93
+ }
94
+ current--;
95
+ }
96
+ const lineStart = getLineStartPositionForPosition(current, sourceFile);
97
+ return findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options);
98
+ }
99
+ function getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options) {
100
+ // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken'
101
+ // if such node is found - compute initial indentation for 'position' inside this node
102
+ let previous;
103
+ let current = precedingToken;
104
+ while (current) {
105
+ if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) {
106
+ const currentStart = getStartLineAndCharacterForNode(current, sourceFile);
107
+ const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile);
108
+ const indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */
109
+ // handle cases when codefix is about to be inserted before the close brace
110
+ ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0
111
+ : lineAtPosition !== currentStart.line ? options.indentSize : 0;
112
+ return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217
113
+ }
114
+ // check if current node is a list item - if yes, take indentation from it
115
+ // do not consider parent-child line sharing yet:
116
+ // function foo(a
117
+ // | preceding node 'a' does share line with its parent but indentation is expected
118
+ const actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true);
119
+ if (actualIndentation !== -1 /* Value.Unknown */) {
120
+ return actualIndentation;
121
+ }
122
+ previous = current;
123
+ current = current.parent;
124
+ }
125
+ // no parent was found - return the base indentation of the SourceFile
126
+ return getBaseIndentation(options);
127
+ }
128
+ function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) {
129
+ const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
130
+ return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, /*isNextChild*/ false, options);
131
+ }
132
+ SmartIndenter.getIndentationForNode = getIndentationForNode;
133
+ function getBaseIndentation(options) {
134
+ return options.baseIndentSize || 0;
135
+ }
136
+ SmartIndenter.getBaseIndentation = getBaseIndentation;
137
+ function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, isNextChild, options) {
138
+ let parent = current.parent;
139
+ // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if
140
+ // * parent and child nodes start on the same line, or
141
+ // * parent is an IfStatement and child starts on the same line as an 'else clause'.
142
+ while (parent) {
143
+ let useActualIndentation = true;
144
+ if (ignoreActualIndentationRange) {
145
+ const start = current.getStart(sourceFile);
146
+ useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end;
147
+ }
148
+ const containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile);
149
+ const parentAndChildShareLine = containingListOrParentStart.line === currentStart.line ||
150
+ childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile);
151
+ if (useActualIndentation) {
152
+ // check if current node is a list item - if yes, take indentation from it
153
+ let actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine);
154
+ if (actualIndentation !== -1 /* Value.Unknown */) {
155
+ return actualIndentation + indentationDelta;
156
+ }
157
+ // try to fetch actual indentation for current node from source text
158
+ actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options);
159
+ if (actualIndentation !== -1 /* Value.Unknown */) {
160
+ return actualIndentation + indentationDelta;
161
+ }
162
+ }
163
+ // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line
164
+ if (shouldIndentChildNode(options, parent, current, sourceFile, isNextChild) && !parentAndChildShareLine) {
165
+ indentationDelta += options.indentSize;
166
+ }
167
+ // In our AST, a call argument's `parent` is the call-expression, not the argument list.
168
+ // We would like to increase indentation based on the relationship between an argument and its argument-list,
169
+ // so we spoof the starting position of the (parent) call-expression to match the (non-parent) argument-list.
170
+ // But, the spoofed start-value could then cause a problem when comparing the start position of the call-expression
171
+ // to *its* parent (in the case of an iife, an expression statement), adding an extra level of indentation.
172
+ //
173
+ // Instead, when at an argument, we unspoof the starting position of the enclosing call expression
174
+ // *after* applying indentation for the argument.
175
+ const useTrueStart = isArgumentAndStartLineOverlapsExpressionBeingCalled(parent, current, currentStart.line, sourceFile);
176
+ current = parent;
177
+ parent = current.parent;
178
+ currentStart = useTrueStart ? sourceFile.getLineAndCharacterOfPosition(current.getStart(sourceFile)) : containingListOrParentStart;
179
+ }
180
+ return indentationDelta + getBaseIndentation(options);
181
+ }
182
+ function getContainingListOrParentStart(parent, child, sourceFile) {
183
+ const containingList = getContainingList(child, sourceFile);
184
+ const startPos = containingList ? containingList.pos : parent.getStart(sourceFile);
185
+ return sourceFile.getLineAndCharacterOfPosition(startPos);
186
+ }
187
+ /*
188
+ * Function returns Value.Unknown if indentation cannot be determined
189
+ */
190
+ function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) {
191
+ // previous token is comma that separates items in list - find the previous item and try to derive indentation from it
192
+ const commaItemInfo = findListItemInfo(commaToken);
193
+ if (commaItemInfo && commaItemInfo.listItemIndex > 0) {
194
+ return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options);
195
+ }
196
+ else {
197
+ // handle broken code gracefully
198
+ return -1 /* Value.Unknown */;
199
+ }
200
+ }
201
+ /*
202
+ * Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression)
203
+ */
204
+ function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) {
205
+ // actual indentation is used for statements\declarations if one of cases below is true:
206
+ // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
207
+ // - parent and child are not on the same line
208
+ const useActualIndentation = (isDeclaration(current) || isStatementButNotDeclaration(current)) &&
209
+ (parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
210
+ if (!useActualIndentation) {
211
+ return -1 /* Value.Unknown */;
212
+ }
213
+ return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options);
214
+ }
215
+ let NextTokenKind;
216
+ (function (NextTokenKind) {
217
+ NextTokenKind[NextTokenKind["Unknown"] = 0] = "Unknown";
218
+ NextTokenKind[NextTokenKind["OpenBrace"] = 1] = "OpenBrace";
219
+ NextTokenKind[NextTokenKind["CloseBrace"] = 2] = "CloseBrace";
220
+ })(NextTokenKind || (NextTokenKind = {}));
221
+ function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) {
222
+ const nextToken = findNextToken(precedingToken, current, sourceFile);
223
+ if (!nextToken) {
224
+ return 0 /* NextTokenKind.Unknown */;
225
+ }
226
+ if (nextToken.kind === SyntaxKind.OpenBraceToken) {
227
+ // open braces are always indented at the parent level
228
+ return 1 /* NextTokenKind.OpenBrace */;
229
+ }
230
+ else if (nextToken.kind === SyntaxKind.CloseBraceToken) {
231
+ // close braces are indented at the parent level if they are located on the same line with cursor
232
+ // this means that if new line will be added at $ position, this case will be indented
233
+ // class A {
234
+ // $
235
+ // }
236
+ /// and this one - not
237
+ // class A {
238
+ // $}
239
+ const nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
240
+ return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */;
241
+ }
242
+ return 0 /* NextTokenKind.Unknown */;
243
+ }
244
+ function getStartLineAndCharacterForNode(n, sourceFile) {
245
+ return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
246
+ }
247
+ function isArgumentAndStartLineOverlapsExpressionBeingCalled(parent, child, childStartLine, sourceFile) {
248
+ if (!(isCallExpression(parent) && contains(parent.arguments, child))) {
249
+ return false;
250
+ }
251
+ const expressionOfCallExpressionEnd = parent.expression.getEnd();
252
+ const expressionOfCallExpressionEndLine = getLineAndCharacterOfPosition(sourceFile, expressionOfCallExpressionEnd).line;
253
+ return expressionOfCallExpressionEndLine === childStartLine;
254
+ }
255
+ SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled;
256
+ function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) {
257
+ if (parent.kind === SyntaxKind.IfStatement && parent.elseStatement === child) {
258
+ const elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
259
+ Debug.assert(elseKeyword !== undefined);
260
+ const elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
261
+ return elseKeywordStartLine === childStartLine;
262
+ }
263
+ return false;
264
+ }
265
+ SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement;
266
+ function argumentStartsOnSameLineAsPreviousArgument(parent, child, childStartLine, sourceFile) {
267
+ if (isCallOrNewExpression(parent)) {
268
+ if (!parent.arguments)
269
+ return false;
270
+ const currentNode = find(parent.arguments, arg => arg.pos === child.pos);
271
+ // If it's not one of the arguments, don't look past this
272
+ if (!currentNode)
273
+ return false;
274
+ const currentIndex = parent.arguments.indexOf(currentNode);
275
+ if (currentIndex === 0)
276
+ return false; // Can't look at previous node if first
277
+ const previousNode = parent.arguments[currentIndex - 1];
278
+ const lineOfPreviousNode = getLineAndCharacterOfPosition(sourceFile, previousNode.getEnd()).line;
279
+ if (childStartLine === lineOfPreviousNode) {
280
+ return true;
281
+ }
282
+ }
283
+ return false;
284
+ }
285
+ SmartIndenter.argumentStartsOnSameLineAsPreviousArgument = argumentStartsOnSameLineAsPreviousArgument;
286
+ function getContainingList(node, sourceFile) {
287
+ return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile);
288
+ }
289
+ SmartIndenter.getContainingList = getContainingList;
290
+ function getListByPosition(pos, node, sourceFile) {
291
+ return node && getListByRange(pos, pos, node, sourceFile);
292
+ }
293
+ function getListByRange(start, end, node, sourceFile) {
294
+ switch (node.kind) {
295
+ case SyntaxKind.TypeReference:
296
+ return getList(node.typeArguments);
297
+ case SyntaxKind.ObjectLiteralExpression:
298
+ return getList(node.properties);
299
+ case SyntaxKind.ArrayLiteralExpression:
300
+ return getList(node.elements);
301
+ case SyntaxKind.TypeLiteral:
302
+ return getList(node.members);
303
+ // Na tag, também a `function`, a function expression, o método, o construtor, o tipo construtor e a construct
304
+ // signature (CK-02), e a method signature (CK-36).
305
+ case SyntaxKind.ArrowFunction:
306
+ case SyntaxKind.CallSignature:
307
+ return getList(node.typeParameters) || getList(node.parameters);
308
+ // Na tag, também a classe, a class expression e a interface (CK-02), e o `@template` do JSDoc (CK-03).
309
+ case SyntaxKind.TypeAliasDeclaration:
310
+ return getList(node.typeParameters);
311
+ // Na tag, também o `new` (CK-02).
312
+ case SyntaxKind.CallExpression:
313
+ return getList(node.typeArguments) || getList(node.arguments);
314
+ case SyntaxKind.VariableDeclarationList:
315
+ return getList(node.declarations);
316
+ case SyntaxKind.NamedImports:
317
+ case SyntaxKind.NamedExports:
318
+ return getList(node.elements);
319
+ case SyntaxKind.ObjectBindingPattern:
320
+ case SyntaxKind.ArrayBindingPattern:
321
+ return getList(node.elements);
322
+ }
323
+ function getList(list) {
324
+ return list && rangeContainsStartEnd(getVisualListRange(node, list, sourceFile), start, end) ? list : undefined;
325
+ }
326
+ }
327
+ function getVisualListRange(node, list, sourceFile) {
328
+ const children = node.getChildren(sourceFile);
329
+ for (let i = 1; i < children.length - 1; i++) {
330
+ if (children[i].pos === list.pos && children[i].end === list.end) {
331
+ return { pos: children[i - 1].end, end: children[i + 1].getStart(sourceFile) };
332
+ }
333
+ }
334
+ return list;
335
+ }
336
+ function getActualIndentationForListStartLine(list, sourceFile, options) {
337
+ if (!list) {
338
+ return -1 /* Value.Unknown */;
339
+ }
340
+ return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options);
341
+ }
342
+ function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) {
343
+ if (node.parent && node.parent.kind === SyntaxKind.VariableDeclarationList) {
344
+ // VariableDeclarationList has no wrapping tokens
345
+ return -1 /* Value.Unknown */;
346
+ }
347
+ const containingList = getContainingList(node, sourceFile);
348
+ if (containingList) {
349
+ const index = containingList.indexOf(node);
350
+ if (index !== -1) {
351
+ const result = deriveActualIndentationFromList(containingList, index, sourceFile, options);
352
+ if (result !== -1 /* Value.Unknown */) {
353
+ return result;
354
+ }
355
+ }
356
+ return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217
357
+ }
358
+ return -1 /* Value.Unknown */;
359
+ }
360
+ function deriveActualIndentationFromList(list, index, sourceFile, options) {
361
+ Debug.assert(index >= 0 && index < list.length);
362
+ const node = list[index];
363
+ // walk toward the start of the list starting from current node and check if the line is the same for all items.
364
+ // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i]
365
+ let lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
366
+ for (let i = index - 1; i >= 0; i--) {
367
+ if (list[i].kind === SyntaxKind.CommaToken) {
368
+ continue;
369
+ }
370
+ // skip list items that ends on the same line with the current list element
371
+ const prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
372
+ if (prevEndLine !== lineAndCharacter.line) {
373
+ return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
374
+ }
375
+ lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile);
376
+ }
377
+ return -1 /* Value.Unknown */;
378
+ }
379
+ function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) {
380
+ const lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
381
+ return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
382
+ }
383
+ /**
384
+ * Character is the actual index of the character since the beginning of the line.
385
+ * Column - position of the character after expanding tabs to spaces.
386
+ * "0\t2$"
387
+ * value of 'character' for '$' is 3
388
+ * value of 'column' for '$' is 6 (assuming that tab size is 4)
389
+ */
390
+ function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) {
391
+ let character = 0;
392
+ let column = 0;
393
+ for (let pos = startPos; pos < endPos; pos++) {
394
+ const ch = sourceFile.text.charCodeAt(pos);
395
+ if (!isWhiteSpaceSingleLine(ch)) {
396
+ break;
397
+ }
398
+ if (ch === CharacterCodes.tab) {
399
+ column += options.tabSize + (column % options.tabSize);
400
+ }
401
+ else {
402
+ column++;
403
+ }
404
+ character++;
405
+ }
406
+ return { column, character };
407
+ }
408
+ SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn;
409
+ function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) {
410
+ return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column;
411
+ }
412
+ SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn;
413
+ function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) {
414
+ const childKind = child ? child.kind : SyntaxKind.Unknown;
415
+ switch (parent.kind) {
416
+ // Na tag, também a classe, a class expression, a interface, o enum, o `new`, a construct signature, o tipo
417
+ // construtor, o template marcado e a propriedade de classe (CK-02), e a method signature (CK-36).
418
+ case SyntaxKind.ExpressionStatement:
419
+ case SyntaxKind.TypeAliasDeclaration:
420
+ case SyntaxKind.ArrayLiteralExpression:
421
+ case SyntaxKind.Block:
422
+ case SyntaxKind.ModuleBlock:
423
+ case SyntaxKind.ObjectLiteralExpression:
424
+ case SyntaxKind.TypeLiteral:
425
+ case SyntaxKind.MappedType:
426
+ case SyntaxKind.TupleType:
427
+ case SyntaxKind.CaseBlock:
428
+ case SyntaxKind.DefaultClause:
429
+ case SyntaxKind.CaseClause:
430
+ case SyntaxKind.ParenthesizedExpression:
431
+ case SyntaxKind.PropertyAccessExpression:
432
+ case SyntaxKind.CallExpression:
433
+ case SyntaxKind.VariableStatement:
434
+ case SyntaxKind.ExportAssignment:
435
+ case SyntaxKind.ReturnStatement:
436
+ case SyntaxKind.ConditionalExpression:
437
+ case SyntaxKind.ArrayBindingPattern:
438
+ case SyntaxKind.ObjectBindingPattern:
439
+ case SyntaxKind.JsxOpeningElement:
440
+ case SyntaxKind.JsxOpeningFragment:
441
+ case SyntaxKind.JsxSelfClosingElement:
442
+ case SyntaxKind.JsxExpression:
443
+ case SyntaxKind.CallSignature:
444
+ case SyntaxKind.Parameter:
445
+ case SyntaxKind.FunctionType:
446
+ case SyntaxKind.ParenthesizedType:
447
+ case SyntaxKind.AwaitExpression:
448
+ case SyntaxKind.NamedExports:
449
+ case SyntaxKind.NamedImports:
450
+ case SyntaxKind.ExportSpecifier:
451
+ case SyntaxKind.ImportSpecifier:
452
+ return true;
453
+ case SyntaxKind.VariableDeclaration:
454
+ case SyntaxKind.PropertyAssignment:
455
+ case SyntaxKind.BinaryExpression:
456
+ if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind.ObjectLiteralExpression) { // TODO: GH#18217
457
+ return rangeIsOnOneLine(sourceFile, child);
458
+ }
459
+ if (parent.kind !== SyntaxKind.BinaryExpression) {
460
+ return true;
461
+ }
462
+ break;
463
+ case SyntaxKind.DoStatement:
464
+ case SyntaxKind.WhileStatement:
465
+ case SyntaxKind.ForInStatement:
466
+ case SyntaxKind.ForOfStatement:
467
+ case SyntaxKind.ForStatement:
468
+ case SyntaxKind.IfStatement:
469
+ // Na tag, também a `function`, a function expression, o método, o construtor e o acessor (CK-02).
470
+ case SyntaxKind.ArrowFunction:
471
+ return childKind !== SyntaxKind.Block;
472
+ case SyntaxKind.ExportDeclaration:
473
+ return childKind !== SyntaxKind.NamedExports;
474
+ case SyntaxKind.ImportDeclaration:
475
+ return childKind !== SyntaxKind.ImportClause ||
476
+ (!!child.namedBindings && child.namedBindings.kind !== SyntaxKind.NamedImports);
477
+ case SyntaxKind.JsxElement:
478
+ return childKind !== SyntaxKind.JsxClosingElement;
479
+ case SyntaxKind.JsxFragment:
480
+ return childKind !== SyntaxKind.JsxClosingFragment;
481
+ case SyntaxKind.IntersectionType:
482
+ case SyntaxKind.UnionType:
483
+ if (childKind === SyntaxKind.TypeLiteral) {
484
+ return false;
485
+ }
486
+ // falls through
487
+ }
488
+ // No explicit rule for given nodes so the result will follow the default value argument
489
+ return indentByDefault;
490
+ }
491
+ SmartIndenter.nodeWillIndentChild = nodeWillIndentChild;
492
+ function isControlFlowEndingStatement(kind, parent) {
493
+ switch (kind) {
494
+ case SyntaxKind.ReturnStatement:
495
+ case SyntaxKind.ThrowStatement:
496
+ case SyntaxKind.ContinueStatement:
497
+ case SyntaxKind.BreakStatement:
498
+ return parent.kind !== SyntaxKind.Block;
499
+ default:
500
+ return false;
501
+ }
502
+ }
503
+ /**
504
+ * True when the parent node should indent the given child by an explicit rule.
505
+ * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
506
+ */
507
+ function shouldIndentChildNode(settings, parent, child, sourceFile, isNextChild = false) {
508
+ return nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false)
509
+ && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent));
510
+ }
511
+ SmartIndenter.shouldIndentChildNode = shouldIndentChildNode;
512
+ function rangeIsOnOneLine(sourceFile, range) {
513
+ const rangeStart = skipTrivia(sourceFile.text, range.pos);
514
+ const startLine = sourceFile.getLineAndCharacterOfPosition(rangeStart).line;
515
+ const endLine = sourceFile.getLineAndCharacterOfPosition(range.end).line;
516
+ return startLine === endLine;
517
+ }
518
+ })(SmartIndenter || (SmartIndenter = {}));
@@ -0,0 +1,6 @@
1
+ import type { CheckResult, FileTextChanges, GetCanonicalFileName, LanguageServiceHost, UserPreferences, formatting } from "./_namespaces/edit.js";
2
+ export declare function getEditsForFileRename(program: CheckResult, oldFileOrDirPath: string, newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences): readonly FileTextChanges[];
3
+ /** If 'path' refers to an old directory, returns path in the new directory. */
4
+ type PathUpdater = (path: string) => string | undefined;
5
+ export declare function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName): PathUpdater;
6
+ export {};
@@ -0,0 +1,86 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/getEditsForFileRename.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ // Saem a atualização do `tsconfig` (o `files`, o `include`, o `exclude` e as opções de caminho) e o mapa de fontes (o
3
+ // `sourceMapper`, que achava o `.ts` de um `.d.ts`), que são do host (CK-47, CK-06); e a referência `/// <reference
4
+ // path>` (CK-03). A resolução de um import é do host (CK-46): onde a tag refazia a resolução do Node a partir do lugar
5
+ // antigo de quem importa, o language service pergunta ao `resolveModule` do host; e o import que não resolve mais, que a
6
+ // tag achava pelos caminhos que a resolução tentou (os `failedLookupLocations`), não tem o que perguntar.
7
+ import { createGetCanonicalFileName, createModuleSpecifierResolutionHost, createRange, find, getResolvedModule, hostUsesCaseSensitiveFileNames, isAmbientModule, isSourceFile, moduleSpecifiers, pathIsRelative, textChanges, tryRemoveDirectoryPrefix, } from "./_namespaces/edit.js";
8
+ export function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences) {
9
+ const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host);
10
+ const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
11
+ const oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName);
12
+ const newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName);
13
+ return textChanges.ChangeTracker.with({ host, formatContext, preferences }, changeTracker => {
14
+ updateImports(program, changeTracker, oldToNew, newToOld, host);
15
+ });
16
+ }
17
+ // exported for tests
18
+ export function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) {
19
+ const canonicalOldPath = getCanonicalFileName(oldFileOrDirPath);
20
+ return path => getUpdatedPath(path);
21
+ function getUpdatedPath(pathToUpdate) {
22
+ if (getCanonicalFileName(pathToUpdate) === canonicalOldPath)
23
+ return newFileOrDirPath;
24
+ const suffix = tryRemoveDirectoryPrefix(pathToUpdate, canonicalOldPath, getCanonicalFileName);
25
+ return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix;
26
+ }
27
+ }
28
+ function updateImports(program, changeTracker, oldToNew, newToOld, host) {
29
+ const allFiles = program.getSourceFiles();
30
+ for (const sourceFile of allFiles) {
31
+ const newFromOld = oldToNew(sourceFile.path);
32
+ const newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path;
33
+ const oldFromNew = newToOld(sourceFile.fileName);
34
+ const oldImportFromPath = oldFromNew || sourceFile.fileName;
35
+ const importingSourceFileMoved = newFromOld !== undefined || oldFromNew !== undefined;
36
+ updateImportsWorker(sourceFile, changeTracker, importLiteral => {
37
+ const importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral);
38
+ // No need to update if it's an ambient module
39
+ if (importedModuleSymbol && importedModuleSymbol.declarations.some(d => isAmbientModule(d)))
40
+ return undefined;
41
+ const toImport = oldFromNew !== undefined
42
+ // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location.
43
+ ? getSourceFileToImportFromResolved(host.resolveModule(importLiteral.text, oldImportFromPath), oldToNew)
44
+ : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, oldToNew);
45
+ // Need an update if the imported file moved, or the importing file moved and was using a relative path.
46
+ return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && pathIsRelative(importLiteral.text)))
47
+ ? moduleSpecifiers.updateModuleSpecifier(newImportFromPath, toImport.newFileName, createModuleSpecifierResolutionHost(host), importLiteral.text)
48
+ : undefined;
49
+ });
50
+ }
51
+ }
52
+ function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, oldToNew) {
53
+ if (importedModuleSymbol) {
54
+ // `find` should succeed because we checked for ambient modules before calling this function.
55
+ const oldFileName = find(importedModuleSymbol.declarations, isSourceFile).fileName;
56
+ const newFileName = oldToNew(oldFileName);
57
+ return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
58
+ }
59
+ else {
60
+ // O arquivo a que o import resolve sem dar um símbolo de módulo (o que não tem `import` nem `export`). Na tag, a
61
+ // resolução vinha do cache do host, com os caminhos que ela tentou; aqui, é a que o `check` gravou no arquivo,
62
+ // o arquivo que o host deu ou nada (CK-46).
63
+ const resolved = getResolvedModule(importingSourceFile, importLiteral.text);
64
+ return getSourceFileToImportFromResolved(resolved && resolved.resolvedFileName, oldToNew);
65
+ }
66
+ }
67
+ // Na tag, a resolução vinha com os caminhos que ela tentou e não achou, e eles se procuravam entre os que mudaram; o
68
+ // `resolveModule` do host dá só o arquivo (CK-46).
69
+ function getSourceFileToImportFromResolved(resolvedFileName, oldToNew) {
70
+ if (!resolvedFileName)
71
+ return undefined;
72
+ const newFileName = oldToNew(resolvedFileName);
73
+ return newFileName ? { newFileName, updated: true } : { newFileName: resolvedFileName, updated: false };
74
+ }
75
+ // Na tag, também as referências `/// <reference path>` do arquivo (CK-03). Com elas, saíram o caminho que a referência daria
76
+ // e os auxiliares de caminho que ela e o `tsconfig` usavam.
77
+ function updateImportsWorker(sourceFile, changeTracker, updateImport) {
78
+ for (const importStringLiteral of sourceFile.imports) {
79
+ const updated = updateImport(importStringLiteral);
80
+ if (updated !== undefined && updated !== importStringLiteral.text)
81
+ changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated);
82
+ }
83
+ }
84
+ function createStringRange(node, sourceFile) {
85
+ return createRange(node.getStart(sourceFile) + 1, node.end - 1);
86
+ }
@@ -0,0 +1,8 @@
1
+ import type { CheckResult, DefinitionInfo, DefinitionInfoAndBoundSpan, SourceFile, TypeChecker } from "./_namespaces/ts.js";
2
+ /**
3
+ * Na tag, também a referência `/// <reference path>`, `<reference types>` e `<reference lib>` na posição, que dava o
4
+ * arquivo referido (CK-03, CK-46, CK-39), e o label de um `break` ou `continue` (CK-02).
5
+ */
6
+ export declare function getDefinitionAtPosition(program: CheckResult, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined;
7
+ export declare function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined;
8
+ export declare function getDefinitionAndBoundSpan(program: CheckResult, sourceFile: SourceFile, position: number): DefinitionInfoAndBoundSpan | undefined;