monaco-editor11 1.0.9 → 1.1.1

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 (232) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/monaco-editor11.es.js +12 -16
  3. package/dist/monaco-editor11.umd.js +1 -1
  4. package/package.json +2 -2
  5. package/dist/monaco.d.ts +0 -8
  6. package/dist/workers/common/initialize.js +0 -16
  7. package/dist/workers/common/workers.js +0 -141
  8. package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
  9. package/dist/workers/editor/common/abstractText.js +0 -89
  10. package/dist/workers/editor/common/ast.js +0 -485
  11. package/dist/workers/editor/common/autoIndent.js +0 -390
  12. package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
  13. package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
  14. package/dist/workers/editor/common/bracketPairsTree.js +0 -343
  15. package/dist/workers/editor/common/brackets.js +0 -108
  16. package/dist/workers/editor/common/characterClassifier.js +0 -59
  17. package/dist/workers/editor/common/characterPair.js +0 -40
  18. package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
  19. package/dist/workers/editor/common/columnRange.js +0 -35
  20. package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
  21. package/dist/workers/editor/common/common.js +0 -20
  22. package/dist/workers/editor/common/computeMovedLines.js +0 -249
  23. package/dist/workers/editor/common/concat23Trees.js +0 -192
  24. package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
  25. package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
  26. package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
  27. package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
  28. package/dist/workers/editor/common/coordinatesConverter.js +0 -51
  29. package/dist/workers/editor/common/cursor.js +0 -899
  30. package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
  31. package/dist/workers/editor/common/cursorCollection.js +0 -194
  32. package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
  33. package/dist/workers/editor/common/cursorColumns.js +0 -112
  34. package/dist/workers/editor/common/cursorCommon.js +0 -250
  35. package/dist/workers/editor/common/cursorContext.js +0 -15
  36. package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
  37. package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
  38. package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
  39. package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
  40. package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
  41. package/dist/workers/editor/common/cursorUtils.js +0 -75
  42. package/dist/workers/editor/common/cursorWordOperations.js +0 -720
  43. package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
  44. package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
  45. package/dist/workers/editor/common/diffAlgorithm.js +0 -139
  46. package/dist/workers/editor/common/diffEditor.js +0 -38
  47. package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
  48. package/dist/workers/editor/common/edit.js +0 -183
  49. package/dist/workers/editor/common/editOperation.js +0 -36
  50. package/dist/workers/editor/common/editStack.js +0 -363
  51. package/dist/workers/editor/common/editorAction.js +0 -26
  52. package/dist/workers/editor/common/editorBaseApi.js +0 -43
  53. package/dist/workers/editor/common/editorColorRegistry.js +0 -102
  54. package/dist/workers/editor/common/editorCommon.js +0 -13
  55. package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
  56. package/dist/workers/editor/common/editorContextKeys.js +0 -84
  57. package/dist/workers/editor/common/editorFeatures.js +0 -17
  58. package/dist/workers/editor/common/editorOptions.js +0 -3440
  59. package/dist/workers/editor/common/editorTheme.js +0 -23
  60. package/dist/workers/editor/common/editorWebWorker.js +0 -299
  61. package/dist/workers/editor/common/editorWorker.js +0 -9
  62. package/dist/workers/editor/common/editorWorkerHost.js +0 -15
  63. package/dist/workers/editor/common/editorZoom.js +0 -26
  64. package/dist/workers/editor/common/electricCharacter.js +0 -55
  65. package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
  66. package/dist/workers/editor/common/enterAction.js +0 -53
  67. package/dist/workers/editor/common/eolCounter.js +0 -44
  68. package/dist/workers/editor/common/findSectionHeaders.js +0 -128
  69. package/dist/workers/editor/common/fixBrackets.js +0 -67
  70. package/dist/workers/editor/common/fixedArray.js +0 -70
  71. package/dist/workers/editor/common/fontInfo.js +0 -172
  72. package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
  73. package/dist/workers/editor/common/getIconClasses.js +0 -106
  74. package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
  75. package/dist/workers/editor/common/glyphLanesModel.js +0 -61
  76. package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
  77. package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
  78. package/dist/workers/editor/common/indentRules.js +0 -63
  79. package/dist/workers/editor/common/indentation.js +0 -39
  80. package/dist/workers/editor/common/indentationGuesser.js +0 -178
  81. package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
  82. package/dist/workers/editor/common/inlineDecorations.js +0 -26
  83. package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
  84. package/dist/workers/editor/common/inputMode.js +0 -22
  85. package/dist/workers/editor/common/intervalTree.js +0 -1002
  86. package/dist/workers/editor/common/language.js +0 -9
  87. package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
  88. package/dist/workers/editor/common/languageConfiguration.js +0 -138
  89. package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
  90. package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
  91. package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
  92. package/dist/workers/editor/common/languageFeatures.js +0 -9
  93. package/dist/workers/editor/common/languageFeaturesService.js +0 -47
  94. package/dist/workers/editor/common/languageSelector.js +0 -112
  95. package/dist/workers/editor/common/languageService.js +0 -92
  96. package/dist/workers/editor/common/languages.js +0 -522
  97. package/dist/workers/editor/common/languagesAssociations.js +0 -193
  98. package/dist/workers/editor/common/languagesRegistry.js +0 -237
  99. package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
  100. package/dist/workers/editor/common/length.js +0 -129
  101. package/dist/workers/editor/common/lineDecorations.js +0 -208
  102. package/dist/workers/editor/common/lineEdit.js +0 -75
  103. package/dist/workers/editor/common/lineHeights.js +0 -370
  104. package/dist/workers/editor/common/linePart.js +0 -25
  105. package/dist/workers/editor/common/lineRange.js +0 -312
  106. package/dist/workers/editor/common/lineSequence.js +0 -36
  107. package/dist/workers/editor/common/lineTokens.js +0 -405
  108. package/dist/workers/editor/common/linesDiffComputer.js +0 -29
  109. package/dist/workers/editor/common/linesDiffComputers.js +0 -13
  110. package/dist/workers/editor/common/linesLayout.js +0 -765
  111. package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
  112. package/dist/workers/editor/common/linkComputer.js +0 -269
  113. package/dist/workers/editor/common/markerDecorations.js +0 -9
  114. package/dist/workers/editor/common/markerDecorationsService.js +0 -248
  115. package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
  116. package/dist/workers/editor/common/mirrorTextModel.js +0 -117
  117. package/dist/workers/editor/common/model.js +0 -9
  118. package/dist/workers/editor/common/modelLineProjection.js +0 -350
  119. package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
  120. package/dist/workers/editor/common/modelService.js +0 -413
  121. package/dist/workers/editor/common/modesRegistry.js +0 -75
  122. package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
  123. package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
  124. package/dist/workers/editor/common/nodeReader.js +0 -127
  125. package/dist/workers/editor/common/nullTokenize.js +0 -29
  126. package/dist/workers/editor/common/offsetRange.js +0 -225
  127. package/dist/workers/editor/common/onEnter.js +0 -109
  128. package/dist/workers/editor/common/oneCursor.js +0 -117
  129. package/dist/workers/editor/common/overviewZoneManager.js +0 -176
  130. package/dist/workers/editor/common/parser.js +0 -121
  131. package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
  132. package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
  133. package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
  134. package/dist/workers/editor/common/point.js +0 -50
  135. package/dist/workers/editor/common/position.js +0 -142
  136. package/dist/workers/editor/common/positionToOffset.js +0 -17
  137. package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
  138. package/dist/workers/editor/common/prefixSumComputer.js +0 -226
  139. package/dist/workers/editor/common/range.js +0 -421
  140. package/dist/workers/editor/common/rangeMapping.js +0 -229
  141. package/dist/workers/editor/common/rangeSingleLine.js +0 -17
  142. package/dist/workers/editor/common/rbTreeBase.js +0 -362
  143. package/dist/workers/editor/common/rect.js +0 -163
  144. package/dist/workers/editor/common/replaceCommand.js +0 -158
  145. package/dist/workers/editor/common/resolverService.js +0 -5
  146. package/dist/workers/editor/common/rgba.js +0 -35
  147. package/dist/workers/editor/common/richEditBrackets.js +0 -356
  148. package/dist/workers/editor/common/selection.js +0 -145
  149. package/dist/workers/editor/common/semanticTokensDto.js +0 -82
  150. package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
  151. package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
  152. package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
  153. package/dist/workers/editor/common/shiftCommand.js +0 -241
  154. package/dist/workers/editor/common/smallImmutableSet.js +0 -108
  155. package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
  156. package/dist/workers/editor/common/sparseTokensStore.js +0 -210
  157. package/dist/workers/editor/common/standaloneEnums.js +0 -1017
  158. package/dist/workers/editor/common/standaloneStrings.js +0 -42
  159. package/dist/workers/editor/common/stringBuilder.js +0 -122
  160. package/dist/workers/editor/common/stringEdit.js +0 -165
  161. package/dist/workers/editor/common/supports.js +0 -58
  162. package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
  163. package/dist/workers/editor/common/textChange.js +0 -248
  164. package/dist/workers/editor/common/textEdit.js +0 -269
  165. package/dist/workers/editor/common/textLength.js +0 -87
  166. package/dist/workers/editor/common/textModel.js +0 -2031
  167. package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
  168. package/dist/workers/editor/common/textModelDefaults.js +0 -18
  169. package/dist/workers/editor/common/textModelEditSource.js +0 -166
  170. package/dist/workers/editor/common/textModelEvents.js +0 -216
  171. package/dist/workers/editor/common/textModelGuides.js +0 -40
  172. package/dist/workers/editor/common/textModelPart.js +0 -23
  173. package/dist/workers/editor/common/textModelSearch.js +0 -455
  174. package/dist/workers/editor/common/textModelStringEdit.js +0 -11
  175. package/dist/workers/editor/common/textModelSync.impl.js +0 -307
  176. package/dist/workers/editor/common/textModelText.js +0 -26
  177. package/dist/workers/editor/common/textModelTokens.js +0 -436
  178. package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
  179. package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
  180. package/dist/workers/editor/common/tokenStore.js +0 -407
  181. package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
  182. package/dist/workers/editor/common/tokenization.js +0 -287
  183. package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
  184. package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
  185. package/dist/workers/editor/common/tokenizer.js +0 -301
  186. package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
  187. package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
  188. package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
  189. package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
  190. package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
  191. package/dist/workers/editor/common/treeSitterTree.js +0 -395
  192. package/dist/workers/editor/common/treeViewsDnd.js +0 -24
  193. package/dist/workers/editor/common/treeViewsDndService.js +0 -12
  194. package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
  195. package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
  196. package/dist/workers/editor/common/utils.js +0 -62
  197. package/dist/workers/editor/common/viewContext.js +0 -22
  198. package/dist/workers/editor/common/viewEventHandler.js +0 -186
  199. package/dist/workers/editor/common/viewEvents.js +0 -180
  200. package/dist/workers/editor/common/viewLayout.js +0 -368
  201. package/dist/workers/editor/common/viewLineRenderer.js +0 -948
  202. package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
  203. package/dist/workers/editor/common/viewModel.js +0 -98
  204. package/dist/workers/editor/common/viewModelDecoration.js +0 -55
  205. package/dist/workers/editor/common/viewModelDecorations.js +0 -132
  206. package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
  207. package/dist/workers/editor/common/viewModelImpl.js +0 -1163
  208. package/dist/workers/editor/common/viewModelLines.js +0 -938
  209. package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
  210. package/dist/workers/editor/common/wordHelper.js +0 -127
  211. package/dist/workers/language/cssMode.js +0 -198
  212. package/dist/workers/language/cssWorker.js +0 -183
  213. package/dist/workers/language/htmlMode.js +0 -213
  214. package/dist/workers/language/htmlWorker.js +0 -126
  215. package/dist/workers/language/jsonMode.js +0 -224
  216. package/dist/workers/language/jsonWorker.js +0 -187
  217. package/dist/workers/language/languageFeatures.js +0 -1009
  218. package/dist/workers/language/lib.index.js +0 -103
  219. package/dist/workers/language/lib.js +0 -1107
  220. package/dist/workers/language/lspLanguageFeatures.js +0 -716
  221. package/dist/workers/language/monaco.contribution.js +0 -144
  222. package/dist/workers/language/tokenization.js +0 -189
  223. package/dist/workers/language/tsMode.js +0 -212
  224. package/dist/workers/language/tsWorker.js +0 -352
  225. package/dist/workers/language/typescriptServices.js +0 -210154
  226. package/dist/workers/language/typescriptServicesMetadata.js +0 -3
  227. package/dist/workers/language/workerManager.js +0 -65
  228. /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
  229. /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
  230. /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
  231. /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
  232. /package/dist/workers/{language/ts.worker.js → ts.worker.js} +0 -0
@@ -1,263 +0,0 @@
1
- import { IThemeService } from '../../../platform/theme/common/themeService.js';
2
- import { ILogService } from '../../../platform/log/common/log.js';
3
- import { SparseMultilineTokens } from '../tokens/sparseMultilineTokens.js';
4
- import { ILanguageService } from '../languages/language.js';
5
-
6
- /*---------------------------------------------------------------------------------------------
7
- * Copyright (c) Microsoft Corporation. All rights reserved.
8
- * Licensed under the MIT License. See License.txt in the project root for license information.
9
- *--------------------------------------------------------------------------------------------*/
10
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
11
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
- return c > 3 && r && Object.defineProperty(target, key, r), r;
15
- };
16
- var __param = (undefined && undefined.__param) || function (paramIndex, decorator) {
17
- return function (target, key) { decorator(target, key, paramIndex); }
18
- };
19
- let SemanticTokensProviderStyling = class SemanticTokensProviderStyling {
20
- constructor(_legend, _themeService, _languageService, _logService) {
21
- this._legend = _legend;
22
- this._themeService = _themeService;
23
- this._languageService = _languageService;
24
- this._logService = _logService;
25
- this._hasWarnedOverlappingTokens = false;
26
- this._hasWarnedInvalidLengthTokens = false;
27
- this._hasWarnedInvalidEditStart = false;
28
- this._hashTable = new HashTable();
29
- }
30
- getMetadata(tokenTypeIndex, tokenModifierSet, languageId) {
31
- const encodedLanguageId = this._languageService.languageIdCodec.encodeLanguageId(languageId);
32
- const entry = this._hashTable.get(tokenTypeIndex, tokenModifierSet, encodedLanguageId);
33
- let metadata;
34
- if (entry) {
35
- metadata = entry.metadata;
36
- }
37
- else {
38
- let tokenType = this._legend.tokenTypes[tokenTypeIndex];
39
- const tokenModifiers = [];
40
- if (tokenType) {
41
- let modifierSet = tokenModifierSet;
42
- for (let modifierIndex = 0; modifierSet > 0 && modifierIndex < this._legend.tokenModifiers.length; modifierIndex++) {
43
- if (modifierSet & 1) {
44
- tokenModifiers.push(this._legend.tokenModifiers[modifierIndex]);
45
- }
46
- modifierSet = modifierSet >> 1;
47
- }
48
- const tokenStyle = this._themeService.getColorTheme().getTokenStyleMetadata(tokenType, tokenModifiers, languageId);
49
- if (typeof tokenStyle === 'undefined') {
50
- metadata = 2147483647 /* SemanticTokensProviderStylingConstants.NO_STYLING */;
51
- }
52
- else {
53
- metadata = 0;
54
- if (typeof tokenStyle.italic !== 'undefined') {
55
- const italicBit = (tokenStyle.italic ? 1 /* FontStyle.Italic */ : 0) << 11 /* MetadataConsts.FONT_STYLE_OFFSET */;
56
- metadata |= italicBit | 1 /* MetadataConsts.SEMANTIC_USE_ITALIC */;
57
- }
58
- if (typeof tokenStyle.bold !== 'undefined') {
59
- const boldBit = (tokenStyle.bold ? 2 /* FontStyle.Bold */ : 0) << 11 /* MetadataConsts.FONT_STYLE_OFFSET */;
60
- metadata |= boldBit | 2 /* MetadataConsts.SEMANTIC_USE_BOLD */;
61
- }
62
- if (typeof tokenStyle.underline !== 'undefined') {
63
- const underlineBit = (tokenStyle.underline ? 4 /* FontStyle.Underline */ : 0) << 11 /* MetadataConsts.FONT_STYLE_OFFSET */;
64
- metadata |= underlineBit | 4 /* MetadataConsts.SEMANTIC_USE_UNDERLINE */;
65
- }
66
- if (typeof tokenStyle.strikethrough !== 'undefined') {
67
- const strikethroughBit = (tokenStyle.strikethrough ? 8 /* FontStyle.Strikethrough */ : 0) << 11 /* MetadataConsts.FONT_STYLE_OFFSET */;
68
- metadata |= strikethroughBit | 8 /* MetadataConsts.SEMANTIC_USE_STRIKETHROUGH */;
69
- }
70
- if (tokenStyle.foreground) {
71
- const foregroundBits = (tokenStyle.foreground) << 15 /* MetadataConsts.FOREGROUND_OFFSET */;
72
- metadata |= foregroundBits | 16 /* MetadataConsts.SEMANTIC_USE_FOREGROUND */;
73
- }
74
- if (metadata === 0) {
75
- // Nothing!
76
- metadata = 2147483647 /* SemanticTokensProviderStylingConstants.NO_STYLING */;
77
- }
78
- }
79
- }
80
- else {
81
- metadata = 2147483647 /* SemanticTokensProviderStylingConstants.NO_STYLING */;
82
- tokenType = 'not-in-legend';
83
- }
84
- this._hashTable.add(tokenTypeIndex, tokenModifierSet, encodedLanguageId, metadata);
85
- }
86
- return metadata;
87
- }
88
- warnOverlappingSemanticTokens(lineNumber, startColumn) {
89
- if (!this._hasWarnedOverlappingTokens) {
90
- this._hasWarnedOverlappingTokens = true;
91
- this._logService.warn(`Overlapping semantic tokens detected at lineNumber ${lineNumber}, column ${startColumn}`);
92
- }
93
- }
94
- warnInvalidLengthSemanticTokens(lineNumber, startColumn) {
95
- if (!this._hasWarnedInvalidLengthTokens) {
96
- this._hasWarnedInvalidLengthTokens = true;
97
- this._logService.warn(`Semantic token with invalid length detected at lineNumber ${lineNumber}, column ${startColumn}`);
98
- }
99
- }
100
- warnInvalidEditStart(previousResultId, resultId, editIndex, editStart, maxExpectedStart) {
101
- if (!this._hasWarnedInvalidEditStart) {
102
- this._hasWarnedInvalidEditStart = true;
103
- this._logService.warn(`Invalid semantic tokens edit detected (previousResultId: ${previousResultId}, resultId: ${resultId}) at edit #${editIndex}: The provided start offset ${editStart} is outside the previous data (length ${maxExpectedStart}).`);
104
- }
105
- }
106
- };
107
- SemanticTokensProviderStyling = __decorate([
108
- __param(1, IThemeService),
109
- __param(2, ILanguageService),
110
- __param(3, ILogService)
111
- ], SemanticTokensProviderStyling);
112
- function toMultilineTokens2(tokens, styling, languageId) {
113
- const srcData = tokens.data;
114
- const tokenCount = (tokens.data.length / 5) | 0;
115
- const tokensPerArea = Math.max(Math.ceil(tokenCount / 1024 /* SemanticColoringConstants.DesiredMaxAreas */), 400 /* SemanticColoringConstants.DesiredTokensPerArea */);
116
- const result = [];
117
- let tokenIndex = 0;
118
- let lastLineNumber = 1;
119
- let lastStartCharacter = 0;
120
- while (tokenIndex < tokenCount) {
121
- const tokenStartIndex = tokenIndex;
122
- let tokenEndIndex = Math.min(tokenStartIndex + tokensPerArea, tokenCount);
123
- // Keep tokens on the same line in the same area...
124
- if (tokenEndIndex < tokenCount) {
125
- let smallTokenEndIndex = tokenEndIndex;
126
- while (smallTokenEndIndex - 1 > tokenStartIndex && srcData[5 * smallTokenEndIndex] === 0) {
127
- smallTokenEndIndex--;
128
- }
129
- if (smallTokenEndIndex - 1 === tokenStartIndex) {
130
- // there are so many tokens on this line that our area would be empty, we must now go right
131
- let bigTokenEndIndex = tokenEndIndex;
132
- while (bigTokenEndIndex + 1 < tokenCount && srcData[5 * bigTokenEndIndex] === 0) {
133
- bigTokenEndIndex++;
134
- }
135
- tokenEndIndex = bigTokenEndIndex;
136
- }
137
- else {
138
- tokenEndIndex = smallTokenEndIndex;
139
- }
140
- }
141
- let destData = new Uint32Array((tokenEndIndex - tokenStartIndex) * 4);
142
- let destOffset = 0;
143
- let areaLine = 0;
144
- let prevLineNumber = 0;
145
- let prevEndCharacter = 0;
146
- while (tokenIndex < tokenEndIndex) {
147
- const srcOffset = 5 * tokenIndex;
148
- const deltaLine = srcData[srcOffset];
149
- const deltaCharacter = srcData[srcOffset + 1];
150
- // Casting both `lineNumber`, `startCharacter` and `endCharacter` here to uint32 using `|0`
151
- // to validate below with the actual values that will be inserted in the Uint32Array result
152
- const lineNumber = (lastLineNumber + deltaLine) | 0;
153
- const startCharacter = (deltaLine === 0 ? (lastStartCharacter + deltaCharacter) | 0 : deltaCharacter);
154
- const length = srcData[srcOffset + 2];
155
- const endCharacter = (startCharacter + length) | 0;
156
- const tokenTypeIndex = srcData[srcOffset + 3];
157
- const tokenModifierSet = srcData[srcOffset + 4];
158
- if (endCharacter <= startCharacter) {
159
- // this token is invalid (most likely a negative length casted to uint32)
160
- styling.warnInvalidLengthSemanticTokens(lineNumber, startCharacter + 1);
161
- }
162
- else if (prevLineNumber === lineNumber && prevEndCharacter > startCharacter) {
163
- // this token overlaps with the previous token
164
- styling.warnOverlappingSemanticTokens(lineNumber, startCharacter + 1);
165
- }
166
- else {
167
- const metadata = styling.getMetadata(tokenTypeIndex, tokenModifierSet, languageId);
168
- if (metadata !== 2147483647 /* SemanticTokensProviderStylingConstants.NO_STYLING */) {
169
- if (areaLine === 0) {
170
- areaLine = lineNumber;
171
- }
172
- destData[destOffset] = lineNumber - areaLine;
173
- destData[destOffset + 1] = startCharacter;
174
- destData[destOffset + 2] = endCharacter;
175
- destData[destOffset + 3] = metadata;
176
- destOffset += 4;
177
- prevLineNumber = lineNumber;
178
- prevEndCharacter = endCharacter;
179
- }
180
- }
181
- lastLineNumber = lineNumber;
182
- lastStartCharacter = startCharacter;
183
- tokenIndex++;
184
- }
185
- if (destOffset !== destData.length) {
186
- destData = destData.subarray(0, destOffset);
187
- }
188
- const tokens = SparseMultilineTokens.create(areaLine, destData);
189
- result.push(tokens);
190
- }
191
- return result;
192
- }
193
- class HashTableEntry {
194
- constructor(tokenTypeIndex, tokenModifierSet, languageId, metadata) {
195
- this.tokenTypeIndex = tokenTypeIndex;
196
- this.tokenModifierSet = tokenModifierSet;
197
- this.languageId = languageId;
198
- this.metadata = metadata;
199
- this.next = null;
200
- }
201
- }
202
- class HashTable {
203
- static { this._SIZES = [3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143]; }
204
- constructor() {
205
- this._elementsCount = 0;
206
- this._currentLengthIndex = 0;
207
- this._currentLength = HashTable._SIZES[this._currentLengthIndex];
208
- this._growCount = Math.round(this._currentLengthIndex + 1 < HashTable._SIZES.length ? 2 / 3 * this._currentLength : 0);
209
- this._elements = [];
210
- HashTable._nullOutEntries(this._elements, this._currentLength);
211
- }
212
- static _nullOutEntries(entries, length) {
213
- for (let i = 0; i < length; i++) {
214
- entries[i] = null;
215
- }
216
- }
217
- _hash2(n1, n2) {
218
- return (((n1 << 5) - n1) + n2) | 0; // n1 * 31 + n2, keep as int32
219
- }
220
- _hashFunc(tokenTypeIndex, tokenModifierSet, languageId) {
221
- return this._hash2(this._hash2(tokenTypeIndex, tokenModifierSet), languageId) % this._currentLength;
222
- }
223
- get(tokenTypeIndex, tokenModifierSet, languageId) {
224
- const hash = this._hashFunc(tokenTypeIndex, tokenModifierSet, languageId);
225
- let p = this._elements[hash];
226
- while (p) {
227
- if (p.tokenTypeIndex === tokenTypeIndex && p.tokenModifierSet === tokenModifierSet && p.languageId === languageId) {
228
- return p;
229
- }
230
- p = p.next;
231
- }
232
- return null;
233
- }
234
- add(tokenTypeIndex, tokenModifierSet, languageId, metadata) {
235
- this._elementsCount++;
236
- if (this._growCount !== 0 && this._elementsCount >= this._growCount) {
237
- // expand!
238
- const oldElements = this._elements;
239
- this._currentLengthIndex++;
240
- this._currentLength = HashTable._SIZES[this._currentLengthIndex];
241
- this._growCount = Math.round(this._currentLengthIndex + 1 < HashTable._SIZES.length ? 2 / 3 * this._currentLength : 0);
242
- this._elements = [];
243
- HashTable._nullOutEntries(this._elements, this._currentLength);
244
- for (const first of oldElements) {
245
- let p = first;
246
- while (p) {
247
- const oldNext = p.next;
248
- p.next = null;
249
- this._add(p);
250
- p = oldNext;
251
- }
252
- }
253
- }
254
- this._add(new HashTableEntry(tokenTypeIndex, tokenModifierSet, languageId, metadata));
255
- }
256
- _add(element) {
257
- const hash = this._hashFunc(element.tokenTypeIndex, element.tokenModifierSet, element.languageId);
258
- element.next = this._elements[hash];
259
- this._elements[hash] = element;
260
- }
261
- }
262
-
263
- export { SemanticTokensProviderStyling, toMultilineTokens2 };
@@ -1,9 +0,0 @@
1
- import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';
2
-
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License. See License.txt in the project root for license information.
6
- *--------------------------------------------------------------------------------------------*/
7
- const ISemanticTokensStylingService = createDecorator('semanticTokensStylingService');
8
-
9
- export { ISemanticTokensStylingService };
@@ -1,47 +0,0 @@
1
- import { Disposable } from '../../../base/common/lifecycle.js';
2
- import { ILanguageService } from '../languages/language.js';
3
- import { IThemeService } from '../../../platform/theme/common/themeService.js';
4
- import { ILogService } from '../../../platform/log/common/log.js';
5
- import { SemanticTokensProviderStyling } from './semanticTokensProviderStyling.js';
6
- import { ISemanticTokensStylingService } from './semanticTokensStyling.js';
7
- import { registerSingleton } from '../../../platform/instantiation/common/extensions.js';
8
-
9
- /*---------------------------------------------------------------------------------------------
10
- * Copyright (c) Microsoft Corporation. All rights reserved.
11
- * Licensed under the MIT License. See License.txt in the project root for license information.
12
- *--------------------------------------------------------------------------------------------*/
13
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
14
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
- return c > 3 && r && Object.defineProperty(target, key, r), r;
18
- };
19
- var __param = (undefined && undefined.__param) || function (paramIndex, decorator) {
20
- return function (target, key) { decorator(target, key, paramIndex); }
21
- };
22
- let SemanticTokensStylingService = class SemanticTokensStylingService extends Disposable {
23
- constructor(_themeService, _logService, _languageService) {
24
- super();
25
- this._themeService = _themeService;
26
- this._logService = _logService;
27
- this._languageService = _languageService;
28
- this._caches = new WeakMap();
29
- this._register(this._themeService.onDidColorThemeChange(() => {
30
- this._caches = new WeakMap();
31
- }));
32
- }
33
- getStyling(provider) {
34
- if (!this._caches.has(provider)) {
35
- this._caches.set(provider, new SemanticTokensProviderStyling(provider.getLegend(), this._themeService, this._languageService, this._logService));
36
- }
37
- return this._caches.get(provider);
38
- }
39
- };
40
- SemanticTokensStylingService = __decorate([
41
- __param(0, IThemeService),
42
- __param(1, ILogService),
43
- __param(2, ILanguageService)
44
- ], SemanticTokensStylingService);
45
- registerSingleton(ISemanticTokensStylingService, SemanticTokensStylingService, 1 /* InstantiationType.Delayed */);
46
-
47
- export { SemanticTokensStylingService };
@@ -1,241 +0,0 @@
1
- import { firstNonWhitespaceIndex } from '../../../base/common/strings.js';
2
- import { CursorColumns } from '../core/cursorColumns.js';
3
- import { Range } from '../core/range.js';
4
- import { Selection } from '../core/selection.js';
5
- import { getEnterAction } from '../languages/enterAction.js';
6
- import { ILanguageConfigurationService } from '../languages/languageConfigurationRegistry.js';
7
-
8
- /*---------------------------------------------------------------------------------------------
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License. See License.txt in the project root for license information.
11
- *--------------------------------------------------------------------------------------------*/
12
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
13
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
- return c > 3 && r && Object.defineProperty(target, key, r), r;
17
- };
18
- var __param = (undefined && undefined.__param) || function (paramIndex, decorator) {
19
- return function (target, key) { decorator(target, key, paramIndex); }
20
- };
21
- var ShiftCommand_1;
22
- const repeatCache = Object.create(null);
23
- function cachedStringRepeat(str, count) {
24
- if (count <= 0) {
25
- return '';
26
- }
27
- if (!repeatCache[str]) {
28
- repeatCache[str] = ['', str];
29
- }
30
- const cache = repeatCache[str];
31
- for (let i = cache.length; i <= count; i++) {
32
- cache[i] = cache[i - 1] + str;
33
- }
34
- return cache[count];
35
- }
36
- let ShiftCommand = ShiftCommand_1 = class ShiftCommand {
37
- static unshiftIndent(line, column, tabSize, indentSize, insertSpaces) {
38
- // Determine the visible column where the content starts
39
- const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
40
- if (insertSpaces) {
41
- const indent = cachedStringRepeat(' ', indentSize);
42
- const desiredTabStop = CursorColumns.prevIndentTabStop(contentStartVisibleColumn, indentSize);
43
- const indentCount = desiredTabStop / indentSize; // will be an integer
44
- return cachedStringRepeat(indent, indentCount);
45
- }
46
- else {
47
- const indent = '\t';
48
- const desiredTabStop = CursorColumns.prevRenderTabStop(contentStartVisibleColumn, tabSize);
49
- const indentCount = desiredTabStop / tabSize; // will be an integer
50
- return cachedStringRepeat(indent, indentCount);
51
- }
52
- }
53
- static shiftIndent(line, column, tabSize, indentSize, insertSpaces) {
54
- // Determine the visible column where the content starts
55
- const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
56
- if (insertSpaces) {
57
- const indent = cachedStringRepeat(' ', indentSize);
58
- const desiredTabStop = CursorColumns.nextIndentTabStop(contentStartVisibleColumn, indentSize);
59
- const indentCount = desiredTabStop / indentSize; // will be an integer
60
- return cachedStringRepeat(indent, indentCount);
61
- }
62
- else {
63
- const indent = '\t';
64
- const desiredTabStop = CursorColumns.nextRenderTabStop(contentStartVisibleColumn, tabSize);
65
- const indentCount = desiredTabStop / tabSize; // will be an integer
66
- return cachedStringRepeat(indent, indentCount);
67
- }
68
- }
69
- constructor(range, opts, _languageConfigurationService) {
70
- this._languageConfigurationService = _languageConfigurationService;
71
- this._opts = opts;
72
- this._selection = range;
73
- this._selectionId = null;
74
- this._useLastEditRangeForCursorEndPosition = false;
75
- this._selectionStartColumnStaysPut = false;
76
- }
77
- _addEditOperation(builder, range, text) {
78
- if (this._useLastEditRangeForCursorEndPosition) {
79
- builder.addTrackedEditOperation(range, text);
80
- }
81
- else {
82
- builder.addEditOperation(range, text);
83
- }
84
- }
85
- getEditOperations(model, builder) {
86
- const startLine = this._selection.startLineNumber;
87
- let endLine = this._selection.endLineNumber;
88
- if (this._selection.endColumn === 1 && startLine !== endLine) {
89
- endLine = endLine - 1;
90
- }
91
- const { tabSize, indentSize, insertSpaces } = this._opts;
92
- const shouldIndentEmptyLines = (startLine === endLine);
93
- if (this._opts.useTabStops) {
94
- // if indenting or outdenting on a whitespace only line
95
- if (this._selection.isEmpty()) {
96
- if (/^\s*$/.test(model.getLineContent(startLine))) {
97
- this._useLastEditRangeForCursorEndPosition = true;
98
- }
99
- }
100
- // keep track of previous line's "miss-alignment"
101
- let previousLineExtraSpaces = 0, extraSpaces = 0;
102
- for (let lineNumber = startLine; lineNumber <= endLine; lineNumber++, previousLineExtraSpaces = extraSpaces) {
103
- extraSpaces = 0;
104
- const lineText = model.getLineContent(lineNumber);
105
- let indentationEndIndex = firstNonWhitespaceIndex(lineText);
106
- if (this._opts.isUnshift && (lineText.length === 0 || indentationEndIndex === 0)) {
107
- // empty line or line with no leading whitespace => nothing to do
108
- continue;
109
- }
110
- if (!shouldIndentEmptyLines && !this._opts.isUnshift && lineText.length === 0) {
111
- // do not indent empty lines => nothing to do
112
- continue;
113
- }
114
- if (indentationEndIndex === -1) {
115
- // the entire line is whitespace
116
- indentationEndIndex = lineText.length;
117
- }
118
- if (lineNumber > 1) {
119
- const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(lineText, indentationEndIndex + 1, tabSize);
120
- if (contentStartVisibleColumn % indentSize !== 0) {
121
- // The current line is "miss-aligned", so let's see if this is expected...
122
- // This can only happen when it has trailing commas in the indent
123
- if (model.tokenization.isCheapToTokenize(lineNumber - 1)) {
124
- const enterAction = getEnterAction(this._opts.autoIndent, model, new Range(lineNumber - 1, model.getLineMaxColumn(lineNumber - 1), lineNumber - 1, model.getLineMaxColumn(lineNumber - 1)), this._languageConfigurationService);
125
- if (enterAction) {
126
- extraSpaces = previousLineExtraSpaces;
127
- if (enterAction.appendText) {
128
- for (let j = 0, lenJ = enterAction.appendText.length; j < lenJ && extraSpaces < indentSize; j++) {
129
- if (enterAction.appendText.charCodeAt(j) === 32 /* CharCode.Space */) {
130
- extraSpaces++;
131
- }
132
- else {
133
- break;
134
- }
135
- }
136
- }
137
- if (enterAction.removeText) {
138
- extraSpaces = Math.max(0, extraSpaces - enterAction.removeText);
139
- }
140
- // Act as if `prefixSpaces` is not part of the indentation
141
- for (let j = 0; j < extraSpaces; j++) {
142
- if (indentationEndIndex === 0 || lineText.charCodeAt(indentationEndIndex - 1) !== 32 /* CharCode.Space */) {
143
- break;
144
- }
145
- indentationEndIndex--;
146
- }
147
- }
148
- }
149
- }
150
- }
151
- if (this._opts.isUnshift && indentationEndIndex === 0) {
152
- // line with no leading whitespace => nothing to do
153
- continue;
154
- }
155
- let desiredIndent;
156
- if (this._opts.isUnshift) {
157
- desiredIndent = ShiftCommand_1.unshiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
158
- }
159
- else {
160
- desiredIndent = ShiftCommand_1.shiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
161
- }
162
- this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), desiredIndent);
163
- if (lineNumber === startLine && !this._selection.isEmpty()) {
164
- // Force the startColumn to stay put because we're inserting after it
165
- this._selectionStartColumnStaysPut = (this._selection.startColumn <= indentationEndIndex + 1);
166
- }
167
- }
168
- }
169
- else {
170
- // if indenting or outdenting on a whitespace only line
171
- if (!this._opts.isUnshift && this._selection.isEmpty() && model.getLineLength(startLine) === 0) {
172
- this._useLastEditRangeForCursorEndPosition = true;
173
- }
174
- const oneIndent = (insertSpaces ? cachedStringRepeat(' ', indentSize) : '\t');
175
- for (let lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
176
- const lineText = model.getLineContent(lineNumber);
177
- let indentationEndIndex = firstNonWhitespaceIndex(lineText);
178
- if (this._opts.isUnshift && (lineText.length === 0 || indentationEndIndex === 0)) {
179
- // empty line or line with no leading whitespace => nothing to do
180
- continue;
181
- }
182
- if (!shouldIndentEmptyLines && !this._opts.isUnshift && lineText.length === 0) {
183
- // do not indent empty lines => nothing to do
184
- continue;
185
- }
186
- if (indentationEndIndex === -1) {
187
- // the entire line is whitespace
188
- indentationEndIndex = lineText.length;
189
- }
190
- if (this._opts.isUnshift && indentationEndIndex === 0) {
191
- // line with no leading whitespace => nothing to do
192
- continue;
193
- }
194
- if (this._opts.isUnshift) {
195
- indentationEndIndex = Math.min(indentationEndIndex, indentSize);
196
- for (let i = 0; i < indentationEndIndex; i++) {
197
- const chr = lineText.charCodeAt(i);
198
- if (chr === 9 /* CharCode.Tab */) {
199
- indentationEndIndex = i + 1;
200
- break;
201
- }
202
- }
203
- this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), '');
204
- }
205
- else {
206
- this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, 1), oneIndent);
207
- if (lineNumber === startLine && !this._selection.isEmpty()) {
208
- // Force the startColumn to stay put because we're inserting after it
209
- this._selectionStartColumnStaysPut = (this._selection.startColumn === 1);
210
- }
211
- }
212
- }
213
- }
214
- this._selectionId = builder.trackSelection(this._selection);
215
- }
216
- computeCursorState(model, helper) {
217
- if (this._useLastEditRangeForCursorEndPosition) {
218
- const lastOp = helper.getInverseEditOperations()[0];
219
- return new Selection(lastOp.range.endLineNumber, lastOp.range.endColumn, lastOp.range.endLineNumber, lastOp.range.endColumn);
220
- }
221
- const result = helper.getTrackedSelection(this._selectionId);
222
- if (this._selectionStartColumnStaysPut) {
223
- // The selection start should not move
224
- const initialStartColumn = this._selection.startColumn;
225
- const resultStartColumn = result.startColumn;
226
- if (resultStartColumn <= initialStartColumn) {
227
- return result;
228
- }
229
- if (result.getDirection() === 0 /* SelectionDirection.LTR */) {
230
- return new Selection(result.startLineNumber, initialStartColumn, result.endLineNumber, result.endColumn);
231
- }
232
- return new Selection(result.endLineNumber, result.endColumn, result.startLineNumber, initialStartColumn);
233
- }
234
- return result;
235
- }
236
- };
237
- ShiftCommand = ShiftCommand_1 = __decorate([
238
- __param(2, ILanguageConfigurationService)
239
- ], ShiftCommand);
240
-
241
- export { ShiftCommand };
@@ -1,108 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- const emptyArr = [];
6
- /**
7
- * Represents an immutable set that works best for a small number of elements (less than 32).
8
- * It uses bits to encode element membership efficiently.
9
- */
10
- class SmallImmutableSet {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- static { this.cache = new Array(129); }
13
- static create(items, additionalItems) {
14
- if (items <= 128 && additionalItems.length === 0) {
15
- // We create a cache of 128=2^7 elements to cover all sets with up to 7 (dense) elements.
16
- let cached = SmallImmutableSet.cache[items];
17
- if (!cached) {
18
- cached = new SmallImmutableSet(items, additionalItems);
19
- SmallImmutableSet.cache[items] = cached;
20
- }
21
- return cached;
22
- }
23
- return new SmallImmutableSet(items, additionalItems);
24
- }
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- static { this.empty = SmallImmutableSet.create(0, emptyArr); }
27
- static getEmpty() {
28
- return this.empty;
29
- }
30
- constructor(items, additionalItems) {
31
- this.items = items;
32
- this.additionalItems = additionalItems;
33
- }
34
- add(value, keyProvider) {
35
- const key = keyProvider.getKey(value);
36
- let idx = key >> 5; // divided by 32
37
- if (idx === 0) {
38
- // fast path
39
- const newItem = (1 << key) | this.items;
40
- if (newItem === this.items) {
41
- return this;
42
- }
43
- return SmallImmutableSet.create(newItem, this.additionalItems);
44
- }
45
- idx--;
46
- const newItems = this.additionalItems.slice(0);
47
- while (newItems.length < idx) {
48
- newItems.push(0);
49
- }
50
- newItems[idx] |= 1 << (key & 31);
51
- return SmallImmutableSet.create(this.items, newItems);
52
- }
53
- merge(other) {
54
- const merged = this.items | other.items;
55
- if (this.additionalItems === emptyArr && other.additionalItems === emptyArr) {
56
- // fast path
57
- if (merged === this.items) {
58
- return this;
59
- }
60
- if (merged === other.items) {
61
- return other;
62
- }
63
- return SmallImmutableSet.create(merged, emptyArr);
64
- }
65
- // This can be optimized, but it's not a common case
66
- const newItems = [];
67
- for (let i = 0; i < Math.max(this.additionalItems.length, other.additionalItems.length); i++) {
68
- const item1 = this.additionalItems[i] || 0;
69
- const item2 = other.additionalItems[i] || 0;
70
- newItems.push(item1 | item2);
71
- }
72
- return SmallImmutableSet.create(merged, newItems);
73
- }
74
- intersects(other) {
75
- if ((this.items & other.items) !== 0) {
76
- return true;
77
- }
78
- for (let i = 0; i < Math.min(this.additionalItems.length, other.additionalItems.length); i++) {
79
- if ((this.additionalItems[i] & other.additionalItems[i]) !== 0) {
80
- return true;
81
- }
82
- }
83
- return false;
84
- }
85
- }
86
- const identityKeyProvider = {
87
- getKey(value) {
88
- return value;
89
- }
90
- };
91
- /**
92
- * Assigns values a unique incrementing key.
93
- */
94
- class DenseKeyProvider {
95
- constructor() {
96
- this.items = new Map();
97
- }
98
- getKey(value) {
99
- let existing = this.items.get(value);
100
- if (existing === undefined) {
101
- existing = this.items.size;
102
- this.items.set(value, existing);
103
- }
104
- return existing;
105
- }
106
- }
107
-
108
- export { DenseKeyProvider, SmallImmutableSet, identityKeyProvider };