@tslite/services 0.0.0-stage → 1.12.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,127 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/formatting/rulesMap.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { Debug, SyntaxKind, every, } from "../_namespaces/edit.js";
3
+ import { anyContext, getAllRules, } from "../_namespaces/ts.formatting.js";
4
+ export function getFormatContext(options, host) {
5
+ return { options, getRules: getRulesMap(), host };
6
+ }
7
+ let rulesMapCache;
8
+ function getRulesMap() {
9
+ if (rulesMapCache === undefined) {
10
+ rulesMapCache = createRulesMap(getAllRules());
11
+ }
12
+ return rulesMapCache;
13
+ }
14
+ /**
15
+ * For a given rule action, gets a mask of other rule actions that
16
+ * cannot be applied at the same position.
17
+ */
18
+ function getRuleActionExclusion(ruleAction) {
19
+ let mask = 0;
20
+ if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) {
21
+ mask |= 28 /* RuleAction.ModifySpaceAction */;
22
+ }
23
+ if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) {
24
+ mask |= 96 /* RuleAction.ModifyTokenAction */;
25
+ }
26
+ if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) {
27
+ mask |= 28 /* RuleAction.ModifySpaceAction */;
28
+ }
29
+ if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) {
30
+ mask |= 96 /* RuleAction.ModifyTokenAction */;
31
+ }
32
+ return mask;
33
+ }
34
+ function createRulesMap(rules) {
35
+ const map = buildMap(rules);
36
+ return context => {
37
+ const bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)];
38
+ if (bucket) {
39
+ const rules = [];
40
+ let ruleActionMask = 0;
41
+ for (const rule of bucket) {
42
+ const acceptRuleActions = ~getRuleActionExclusion(ruleActionMask);
43
+ if (rule.action & acceptRuleActions && every(rule.context, c => c(context))) {
44
+ rules.push(rule);
45
+ ruleActionMask |= rule.action;
46
+ }
47
+ }
48
+ if (rules.length) {
49
+ return rules;
50
+ }
51
+ }
52
+ };
53
+ }
54
+ function buildMap(rules) {
55
+ // Map from bucket index to array of rules
56
+ const map = new Array(mapRowLength * mapRowLength);
57
+ // This array is used only during construction of the rulesbucket in the map
58
+ const rulesBucketConstructionStateList = new Array(map.length);
59
+ for (const rule of rules) {
60
+ const specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific;
61
+ for (const left of rule.leftTokenRange.tokens) {
62
+ for (const right of rule.rightTokenRange.tokens) {
63
+ const index = getRuleBucketIndex(left, right);
64
+ let rulesBucket = map[index];
65
+ if (rulesBucket === undefined) {
66
+ rulesBucket = map[index] = [];
67
+ }
68
+ addRule(rulesBucket, rule.rule, specificRule, rulesBucketConstructionStateList, index);
69
+ }
70
+ }
71
+ }
72
+ return map;
73
+ }
74
+ function getRuleBucketIndex(row, column) {
75
+ Debug.assert(row <= SyntaxKind.LastKeyword && column <= SyntaxKind.LastKeyword, "Must compute formatting context from tokens");
76
+ return (row * mapRowLength) + column;
77
+ }
78
+ const maskBitSize = 5;
79
+ const mask = 0b11111; // MaskBitSize bits
80
+ const mapRowLength = SyntaxKind.LastToken + 1;
81
+ var RulesPosition;
82
+ (function (RulesPosition) {
83
+ RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific";
84
+ RulesPosition[RulesPosition["StopRulesAny"] = 5] = "StopRulesAny";
85
+ RulesPosition[RulesPosition["ContextRulesSpecific"] = 10] = "ContextRulesSpecific";
86
+ RulesPosition[RulesPosition["ContextRulesAny"] = 15] = "ContextRulesAny";
87
+ RulesPosition[RulesPosition["NoContextRulesSpecific"] = 20] = "NoContextRulesSpecific";
88
+ RulesPosition[RulesPosition["NoContextRulesAny"] = 25] = "NoContextRulesAny";
89
+ })(RulesPosition || (RulesPosition = {}));
90
+ // The Rules list contains all the inserted rules into a rulebucket in the following order:
91
+ // 1- Ignore rules with specific token combination
92
+ // 2- Ignore rules with any token combination
93
+ // 3- Context rules with specific token combination
94
+ // 4- Context rules with any token combination
95
+ // 5- Non-context rules with specific token combination
96
+ // 6- Non-context rules with any token combination
97
+ //
98
+ // The member rulesInsertionIndexBitmap is used to describe the number of rules
99
+ // in each sub-bucket (above) hence can be used to know the index of where to insert
100
+ // the next rule. It's a bitmap which contains 6 different sections each is given 5 bits.
101
+ //
102
+ // Example:
103
+ // In order to insert a rule to the end of sub-bucket (3), we get the index by adding
104
+ // the values in the bitmap segments 3rd, 2nd, and 1st.
105
+ function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) {
106
+ const position = rule.action & 3 /* RuleAction.StopAction */ ?
107
+ specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny :
108
+ rule.context !== anyContext ?
109
+ specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny :
110
+ specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny;
111
+ const state = constructionState[rulesBucketIndex] || 0;
112
+ rules.splice(getInsertionIndex(state, position), 0, rule);
113
+ constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position);
114
+ }
115
+ function getInsertionIndex(indexBitmap, maskPosition) {
116
+ let index = 0;
117
+ for (let pos = 0; pos <= maskPosition; pos += maskBitSize) {
118
+ index += indexBitmap & mask;
119
+ indexBitmap >>= maskBitSize;
120
+ }
121
+ return index;
122
+ }
123
+ function increaseInsertionIndex(indexBitmap, maskPosition) {
124
+ const value = ((indexBitmap >> maskPosition) & mask) + 1;
125
+ Debug.assert((value & mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules.");
126
+ return (indexBitmap & ~(mask << maskPosition)) | (value << maskPosition);
127
+ }
@@ -0,0 +1,44 @@
1
+ import type { EditorSettings, FormatCodeSettings, Node, NodeArray, SourceFile, SourceFileLike, TextRange } from "../_namespaces/edit.js";
2
+ import type { TextRangeWithKind } from "../_namespaces/ts.formatting.js";
3
+ export declare namespace SmartIndenter {
4
+ /**
5
+ * @param assumeNewLineBeforeCloseBrace
6
+ * `false` when called on text from a real source file.
7
+ * `true` when we need to assume `position` is on a newline.
8
+ *
9
+ * This is useful for codefixes. Consider
10
+ * ```
11
+ * function f() {
12
+ * |}
13
+ * ```
14
+ * with `position` at `|`.
15
+ *
16
+ * When inserting some text after an open brace, we would like to get indentation as if a newline was already there.
17
+ * By default indentation at `position` will be 0 so 'assumeNewLineBeforeCloseBrace' overrides this behavior.
18
+ */
19
+ function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, assumeNewLineBeforeCloseBrace?: boolean): number;
20
+ function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number;
21
+ function getBaseIndentation(options: EditorSettings): number;
22
+ function isArgumentAndStartLineOverlapsExpressionBeingCalled(parent: Node, child: Node, childStartLine: number, sourceFile: SourceFileLike): boolean;
23
+ function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean;
24
+ function argumentStartsOnSameLineAsPreviousArgument(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean;
25
+ function getContainingList(node: Node, sourceFile: SourceFile): NodeArray<Node> | undefined;
26
+ /**
27
+ * Character is the actual index of the character since the beginning of the line.
28
+ * Column - position of the character after expanding tabs to spaces.
29
+ * "0\t2$"
30
+ * value of 'character' for '$' is 3
31
+ * value of 'column' for '$' is 6 (assuming that tab size is 4)
32
+ */
33
+ function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): {
34
+ column: number;
35
+ character: number;
36
+ };
37
+ function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): number;
38
+ function nodeWillIndentChild(settings: FormatCodeSettings, parent: TextRangeWithKind, child: TextRangeWithKind | undefined, sourceFile: SourceFileLike | undefined, indentByDefault: boolean): boolean;
39
+ /**
40
+ * True when the parent node should indent the given child by an explicit rule.
41
+ * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
42
+ */
43
+ function shouldIndentChildNode(settings: FormatCodeSettings, parent: TextRangeWithKind, child?: Node, sourceFile?: SourceFileLike, isNextChild?: boolean): boolean;
44
+ }