monaco-editor11 1.0.9 → 1.1.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.
- package/dist/index.d.ts +1 -1
- package/dist/monaco-editor11.es.js +11 -16
- package/dist/monaco-editor11.umd.js +1 -1
- package/package.json +2 -2
- package/dist/monaco.d.ts +0 -8
- package/dist/workers/common/initialize.js +0 -16
- package/dist/workers/common/workers.js +0 -141
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
- package/dist/workers/editor/common/abstractText.js +0 -89
- package/dist/workers/editor/common/ast.js +0 -485
- package/dist/workers/editor/common/autoIndent.js +0 -390
- package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
- package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
- package/dist/workers/editor/common/bracketPairsTree.js +0 -343
- package/dist/workers/editor/common/brackets.js +0 -108
- package/dist/workers/editor/common/characterClassifier.js +0 -59
- package/dist/workers/editor/common/characterPair.js +0 -40
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
- package/dist/workers/editor/common/columnRange.js +0 -35
- package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
- package/dist/workers/editor/common/common.js +0 -20
- package/dist/workers/editor/common/computeMovedLines.js +0 -249
- package/dist/workers/editor/common/concat23Trees.js +0 -192
- package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
- package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
- package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
- package/dist/workers/editor/common/coordinatesConverter.js +0 -51
- package/dist/workers/editor/common/cursor.js +0 -899
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
- package/dist/workers/editor/common/cursorCollection.js +0 -194
- package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
- package/dist/workers/editor/common/cursorColumns.js +0 -112
- package/dist/workers/editor/common/cursorCommon.js +0 -250
- package/dist/workers/editor/common/cursorContext.js +0 -15
- package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
- package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
- package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
- package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
- package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
- package/dist/workers/editor/common/cursorUtils.js +0 -75
- package/dist/workers/editor/common/cursorWordOperations.js +0 -720
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
- package/dist/workers/editor/common/diffAlgorithm.js +0 -139
- package/dist/workers/editor/common/diffEditor.js +0 -38
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
- package/dist/workers/editor/common/edit.js +0 -183
- package/dist/workers/editor/common/editOperation.js +0 -36
- package/dist/workers/editor/common/editStack.js +0 -363
- package/dist/workers/editor/common/editorAction.js +0 -26
- package/dist/workers/editor/common/editorBaseApi.js +0 -43
- package/dist/workers/editor/common/editorColorRegistry.js +0 -102
- package/dist/workers/editor/common/editorCommon.js +0 -13
- package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
- package/dist/workers/editor/common/editorContextKeys.js +0 -84
- package/dist/workers/editor/common/editorFeatures.js +0 -17
- package/dist/workers/editor/common/editorOptions.js +0 -3440
- package/dist/workers/editor/common/editorTheme.js +0 -23
- package/dist/workers/editor/common/editorWebWorker.js +0 -299
- package/dist/workers/editor/common/editorWorker.js +0 -9
- package/dist/workers/editor/common/editorWorkerHost.js +0 -15
- package/dist/workers/editor/common/editorZoom.js +0 -26
- package/dist/workers/editor/common/electricCharacter.js +0 -55
- package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
- package/dist/workers/editor/common/enterAction.js +0 -53
- package/dist/workers/editor/common/eolCounter.js +0 -44
- package/dist/workers/editor/common/findSectionHeaders.js +0 -128
- package/dist/workers/editor/common/fixBrackets.js +0 -67
- package/dist/workers/editor/common/fixedArray.js +0 -70
- package/dist/workers/editor/common/fontInfo.js +0 -172
- package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
- package/dist/workers/editor/common/getIconClasses.js +0 -106
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
- package/dist/workers/editor/common/glyphLanesModel.js +0 -61
- package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
- package/dist/workers/editor/common/indentRules.js +0 -63
- package/dist/workers/editor/common/indentation.js +0 -39
- package/dist/workers/editor/common/indentationGuesser.js +0 -178
- package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
- package/dist/workers/editor/common/inlineDecorations.js +0 -26
- package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
- package/dist/workers/editor/common/inputMode.js +0 -22
- package/dist/workers/editor/common/intervalTree.js +0 -1002
- package/dist/workers/editor/common/language.js +0 -9
- package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
- package/dist/workers/editor/common/languageConfiguration.js +0 -138
- package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
- package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
- package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
- package/dist/workers/editor/common/languageFeatures.js +0 -9
- package/dist/workers/editor/common/languageFeaturesService.js +0 -47
- package/dist/workers/editor/common/languageSelector.js +0 -112
- package/dist/workers/editor/common/languageService.js +0 -92
- package/dist/workers/editor/common/languages.js +0 -522
- package/dist/workers/editor/common/languagesAssociations.js +0 -193
- package/dist/workers/editor/common/languagesRegistry.js +0 -237
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
- package/dist/workers/editor/common/length.js +0 -129
- package/dist/workers/editor/common/lineDecorations.js +0 -208
- package/dist/workers/editor/common/lineEdit.js +0 -75
- package/dist/workers/editor/common/lineHeights.js +0 -370
- package/dist/workers/editor/common/linePart.js +0 -25
- package/dist/workers/editor/common/lineRange.js +0 -312
- package/dist/workers/editor/common/lineSequence.js +0 -36
- package/dist/workers/editor/common/lineTokens.js +0 -405
- package/dist/workers/editor/common/linesDiffComputer.js +0 -29
- package/dist/workers/editor/common/linesDiffComputers.js +0 -13
- package/dist/workers/editor/common/linesLayout.js +0 -765
- package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
- package/dist/workers/editor/common/linkComputer.js +0 -269
- package/dist/workers/editor/common/markerDecorations.js +0 -9
- package/dist/workers/editor/common/markerDecorationsService.js +0 -248
- package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
- package/dist/workers/editor/common/mirrorTextModel.js +0 -117
- package/dist/workers/editor/common/model.js +0 -9
- package/dist/workers/editor/common/modelLineProjection.js +0 -350
- package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
- package/dist/workers/editor/common/modelService.js +0 -413
- package/dist/workers/editor/common/modesRegistry.js +0 -75
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
- package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
- package/dist/workers/editor/common/nodeReader.js +0 -127
- package/dist/workers/editor/common/nullTokenize.js +0 -29
- package/dist/workers/editor/common/offsetRange.js +0 -225
- package/dist/workers/editor/common/onEnter.js +0 -109
- package/dist/workers/editor/common/oneCursor.js +0 -117
- package/dist/workers/editor/common/overviewZoneManager.js +0 -176
- package/dist/workers/editor/common/parser.js +0 -121
- package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
- package/dist/workers/editor/common/point.js +0 -50
- package/dist/workers/editor/common/position.js +0 -142
- package/dist/workers/editor/common/positionToOffset.js +0 -17
- package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
- package/dist/workers/editor/common/prefixSumComputer.js +0 -226
- package/dist/workers/editor/common/range.js +0 -421
- package/dist/workers/editor/common/rangeMapping.js +0 -229
- package/dist/workers/editor/common/rangeSingleLine.js +0 -17
- package/dist/workers/editor/common/rbTreeBase.js +0 -362
- package/dist/workers/editor/common/rect.js +0 -163
- package/dist/workers/editor/common/replaceCommand.js +0 -158
- package/dist/workers/editor/common/resolverService.js +0 -5
- package/dist/workers/editor/common/rgba.js +0 -35
- package/dist/workers/editor/common/richEditBrackets.js +0 -356
- package/dist/workers/editor/common/selection.js +0 -145
- package/dist/workers/editor/common/semanticTokensDto.js +0 -82
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
- package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
- package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
- package/dist/workers/editor/common/shiftCommand.js +0 -241
- package/dist/workers/editor/common/smallImmutableSet.js +0 -108
- package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
- package/dist/workers/editor/common/sparseTokensStore.js +0 -210
- package/dist/workers/editor/common/standaloneEnums.js +0 -1017
- package/dist/workers/editor/common/standaloneStrings.js +0 -42
- package/dist/workers/editor/common/stringBuilder.js +0 -122
- package/dist/workers/editor/common/stringEdit.js +0 -165
- package/dist/workers/editor/common/supports.js +0 -58
- package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
- package/dist/workers/editor/common/textChange.js +0 -248
- package/dist/workers/editor/common/textEdit.js +0 -269
- package/dist/workers/editor/common/textLength.js +0 -87
- package/dist/workers/editor/common/textModel.js +0 -2031
- package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
- package/dist/workers/editor/common/textModelDefaults.js +0 -18
- package/dist/workers/editor/common/textModelEditSource.js +0 -166
- package/dist/workers/editor/common/textModelEvents.js +0 -216
- package/dist/workers/editor/common/textModelGuides.js +0 -40
- package/dist/workers/editor/common/textModelPart.js +0 -23
- package/dist/workers/editor/common/textModelSearch.js +0 -455
- package/dist/workers/editor/common/textModelStringEdit.js +0 -11
- package/dist/workers/editor/common/textModelSync.impl.js +0 -307
- package/dist/workers/editor/common/textModelText.js +0 -26
- package/dist/workers/editor/common/textModelTokens.js +0 -436
- package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
- package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
- package/dist/workers/editor/common/tokenStore.js +0 -407
- package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
- package/dist/workers/editor/common/tokenization.js +0 -287
- package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
- package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
- package/dist/workers/editor/common/tokenizer.js +0 -301
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
- package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
- package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
- package/dist/workers/editor/common/treeSitterTree.js +0 -395
- package/dist/workers/editor/common/treeViewsDnd.js +0 -24
- package/dist/workers/editor/common/treeViewsDndService.js +0 -12
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
- package/dist/workers/editor/common/utils.js +0 -62
- package/dist/workers/editor/common/viewContext.js +0 -22
- package/dist/workers/editor/common/viewEventHandler.js +0 -186
- package/dist/workers/editor/common/viewEvents.js +0 -180
- package/dist/workers/editor/common/viewLayout.js +0 -368
- package/dist/workers/editor/common/viewLineRenderer.js +0 -948
- package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
- package/dist/workers/editor/common/viewModel.js +0 -98
- package/dist/workers/editor/common/viewModelDecoration.js +0 -55
- package/dist/workers/editor/common/viewModelDecorations.js +0 -132
- package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
- package/dist/workers/editor/common/viewModelImpl.js +0 -1163
- package/dist/workers/editor/common/viewModelLines.js +0 -938
- package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
- package/dist/workers/editor/common/wordHelper.js +0 -127
- package/dist/workers/language/cssMode.js +0 -198
- package/dist/workers/language/cssWorker.js +0 -183
- package/dist/workers/language/htmlMode.js +0 -213
- package/dist/workers/language/htmlWorker.js +0 -126
- package/dist/workers/language/jsonMode.js +0 -224
- package/dist/workers/language/jsonWorker.js +0 -187
- package/dist/workers/language/languageFeatures.js +0 -1009
- package/dist/workers/language/lib.index.js +0 -103
- package/dist/workers/language/lib.js +0 -1107
- package/dist/workers/language/lspLanguageFeatures.js +0 -716
- package/dist/workers/language/monaco.contribution.js +0 -144
- package/dist/workers/language/tokenization.js +0 -189
- package/dist/workers/language/tsMode.js +0 -212
- package/dist/workers/language/tsWorker.js +0 -352
- package/dist/workers/language/typescriptServices.js +0 -210154
- package/dist/workers/language/typescriptServicesMetadata.js +0 -3
- package/dist/workers/language/workerManager.js +0 -65
- /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
- /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
- /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
- /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
- /package/dist/workers/{language/ts.worker.js → ts.worker.js} +0 -0
|
@@ -1,407 +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
|
-
// Exported for tests
|
|
6
|
-
class ListNode {
|
|
7
|
-
get children() { return this._children; }
|
|
8
|
-
get length() { return this._length; }
|
|
9
|
-
constructor(height) {
|
|
10
|
-
this.height = height;
|
|
11
|
-
this._children = [];
|
|
12
|
-
this._length = 0;
|
|
13
|
-
}
|
|
14
|
-
static create(node1, node2) {
|
|
15
|
-
const list = new ListNode(node1.height + 1);
|
|
16
|
-
list.appendChild(node1);
|
|
17
|
-
list.appendChild(node2);
|
|
18
|
-
return list;
|
|
19
|
-
}
|
|
20
|
-
canAppendChild() {
|
|
21
|
-
return this._children.length < 3;
|
|
22
|
-
}
|
|
23
|
-
appendChild(node) {
|
|
24
|
-
if (!this.canAppendChild()) {
|
|
25
|
-
throw new Error('Cannot insert more than 3 children in a ListNode');
|
|
26
|
-
}
|
|
27
|
-
this._children.push(node);
|
|
28
|
-
this._length += node.length;
|
|
29
|
-
this._updateParentLength(node.length);
|
|
30
|
-
if (!isLeaf(node)) {
|
|
31
|
-
node.parent = this;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
_updateParentLength(delta) {
|
|
35
|
-
let updateParent = this.parent;
|
|
36
|
-
while (updateParent) {
|
|
37
|
-
updateParent._length += delta;
|
|
38
|
-
updateParent = updateParent.parent;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
unappendChild() {
|
|
42
|
-
const child = this._children.pop();
|
|
43
|
-
this._length -= child.length;
|
|
44
|
-
this._updateParentLength(-child.length);
|
|
45
|
-
return child;
|
|
46
|
-
}
|
|
47
|
-
prependChild(node) {
|
|
48
|
-
if (this._children.length >= 3) {
|
|
49
|
-
throw new Error('Cannot prepend more than 3 children in a ListNode');
|
|
50
|
-
}
|
|
51
|
-
this._children.unshift(node);
|
|
52
|
-
this._length += node.length;
|
|
53
|
-
this._updateParentLength(node.length);
|
|
54
|
-
if (!isLeaf(node)) {
|
|
55
|
-
node.parent = this;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
unprependChild() {
|
|
59
|
-
const child = this._children.shift();
|
|
60
|
-
this._length -= child.length;
|
|
61
|
-
this._updateParentLength(-child.length);
|
|
62
|
-
return child;
|
|
63
|
-
}
|
|
64
|
-
lastChild() {
|
|
65
|
-
return this._children[this._children.length - 1];
|
|
66
|
-
}
|
|
67
|
-
dispose() {
|
|
68
|
-
this._children.splice(0, this._children.length);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
var TokenQuality;
|
|
72
|
-
(function (TokenQuality) {
|
|
73
|
-
TokenQuality[TokenQuality["None"] = 0] = "None";
|
|
74
|
-
TokenQuality[TokenQuality["ViewportGuess"] = 1] = "ViewportGuess";
|
|
75
|
-
TokenQuality[TokenQuality["EditGuess"] = 2] = "EditGuess";
|
|
76
|
-
TokenQuality[TokenQuality["Accurate"] = 3] = "Accurate";
|
|
77
|
-
})(TokenQuality || (TokenQuality = {}));
|
|
78
|
-
function isLeaf(node) {
|
|
79
|
-
return node.token !== undefined;
|
|
80
|
-
}
|
|
81
|
-
// Heavily inspired by https://github.com/microsoft/vscode/blob/4eb2658d592cb6114a7a393655574176cc790c5b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/concat23Trees.ts#L108-L109
|
|
82
|
-
function append(node, nodeToAppend) {
|
|
83
|
-
let curNode = node;
|
|
84
|
-
const parents = [];
|
|
85
|
-
let nodeToAppendOfCorrectHeight;
|
|
86
|
-
while (true) {
|
|
87
|
-
if (nodeToAppend.height === curNode.height) {
|
|
88
|
-
nodeToAppendOfCorrectHeight = nodeToAppend;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
if (isLeaf(curNode)) {
|
|
92
|
-
throw new Error('unexpected');
|
|
93
|
-
}
|
|
94
|
-
parents.push(curNode);
|
|
95
|
-
curNode = curNode.lastChild();
|
|
96
|
-
}
|
|
97
|
-
for (let i = parents.length - 1; i >= 0; i--) {
|
|
98
|
-
const parent = parents[i];
|
|
99
|
-
if (nodeToAppendOfCorrectHeight) {
|
|
100
|
-
// Can we take the element?
|
|
101
|
-
if (parent.children.length >= 3) {
|
|
102
|
-
// we need to split to maintain (2,3)-tree property.
|
|
103
|
-
// Send the third element + the new element to the parent.
|
|
104
|
-
const newList = ListNode.create(parent.unappendChild(), nodeToAppendOfCorrectHeight);
|
|
105
|
-
nodeToAppendOfCorrectHeight = newList;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
parent.appendChild(nodeToAppendOfCorrectHeight);
|
|
109
|
-
nodeToAppendOfCorrectHeight = undefined;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (nodeToAppendOfCorrectHeight) {
|
|
114
|
-
const newList = new ListNode(nodeToAppendOfCorrectHeight.height + 1);
|
|
115
|
-
newList.appendChild(node);
|
|
116
|
-
newList.appendChild(nodeToAppendOfCorrectHeight);
|
|
117
|
-
return newList;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
return node;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function prepend(list, nodeToAppend) {
|
|
124
|
-
let curNode = list;
|
|
125
|
-
const parents = [];
|
|
126
|
-
while (nodeToAppend.height !== curNode.height) {
|
|
127
|
-
if (isLeaf(curNode)) {
|
|
128
|
-
throw new Error('unexpected');
|
|
129
|
-
}
|
|
130
|
-
parents.push(curNode);
|
|
131
|
-
// assert 2 <= curNode.childrenFast.length <= 3
|
|
132
|
-
curNode = curNode.children[0];
|
|
133
|
-
}
|
|
134
|
-
let nodeToPrependOfCorrectHeight = nodeToAppend;
|
|
135
|
-
// assert nodeToAppendOfCorrectHeight!.listHeight === curNode.listHeight
|
|
136
|
-
for (let i = parents.length - 1; i >= 0; i--) {
|
|
137
|
-
const parent = parents[i];
|
|
138
|
-
if (nodeToPrependOfCorrectHeight) {
|
|
139
|
-
// Can we take the element?
|
|
140
|
-
if (parent.children.length >= 3) {
|
|
141
|
-
// we need to split to maintain (2,3)-tree property.
|
|
142
|
-
// Send the third element + the new element to the parent.
|
|
143
|
-
nodeToPrependOfCorrectHeight = ListNode.create(nodeToPrependOfCorrectHeight, parent.unprependChild());
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
parent.prependChild(nodeToPrependOfCorrectHeight);
|
|
147
|
-
nodeToPrependOfCorrectHeight = undefined;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (nodeToPrependOfCorrectHeight) {
|
|
152
|
-
return ListNode.create(nodeToPrependOfCorrectHeight, list);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return list;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function concat(node1, node2) {
|
|
159
|
-
if (node1.height === node2.height) {
|
|
160
|
-
return ListNode.create(node1, node2);
|
|
161
|
-
}
|
|
162
|
-
else if (node1.height > node2.height) {
|
|
163
|
-
// node1 is the tree we want to insert into
|
|
164
|
-
return append(node1, node2);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return prepend(node2, node1);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
class TokenStore {
|
|
171
|
-
constructor(_textModel) {
|
|
172
|
-
this._textModel = _textModel;
|
|
173
|
-
this._root = this.createEmptyRoot();
|
|
174
|
-
}
|
|
175
|
-
createEmptyRoot() {
|
|
176
|
-
return {
|
|
177
|
-
length: this._textModel.getValueLength(),
|
|
178
|
-
token: 0,
|
|
179
|
-
height: 0,
|
|
180
|
-
tokenQuality: TokenQuality.None
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
*
|
|
185
|
-
* @param update all the tokens for the document in sequence
|
|
186
|
-
*/
|
|
187
|
-
buildStore(tokens, tokenQuality) {
|
|
188
|
-
this._root = this.createFromUpdates(tokens, tokenQuality);
|
|
189
|
-
}
|
|
190
|
-
createFromUpdates(tokens, tokenQuality) {
|
|
191
|
-
if (tokens.length === 0) {
|
|
192
|
-
return this.createEmptyRoot();
|
|
193
|
-
}
|
|
194
|
-
let newRoot = {
|
|
195
|
-
length: tokens[0].length,
|
|
196
|
-
token: tokens[0].token,
|
|
197
|
-
height: 0,
|
|
198
|
-
tokenQuality
|
|
199
|
-
};
|
|
200
|
-
for (let j = 1; j < tokens.length; j++) {
|
|
201
|
-
newRoot = append(newRoot, { length: tokens[j].length, token: tokens[j].token, height: 0, tokenQuality });
|
|
202
|
-
}
|
|
203
|
-
return newRoot;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
*
|
|
207
|
-
* @param tokens tokens are in sequence in the document.
|
|
208
|
-
*/
|
|
209
|
-
update(length, tokens, tokenQuality) {
|
|
210
|
-
if (tokens.length === 0) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
this.replace(length, tokens[0].startOffsetInclusive, tokens, tokenQuality);
|
|
214
|
-
}
|
|
215
|
-
delete(length, startOffset) {
|
|
216
|
-
this.replace(length, startOffset, [], TokenQuality.EditGuess);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
*
|
|
220
|
-
* @param tokens tokens are in sequence in the document.
|
|
221
|
-
*/
|
|
222
|
-
replace(length, updateOffsetStart, tokens, tokenQuality) {
|
|
223
|
-
const firstUnchangedOffsetAfterUpdate = updateOffsetStart + length;
|
|
224
|
-
// Find the last unchanged node preceding the update
|
|
225
|
-
const precedingNodes = [];
|
|
226
|
-
// Find the first unchanged node after the update
|
|
227
|
-
const postcedingNodes = [];
|
|
228
|
-
const stack = [{ node: this._root, offset: 0 }];
|
|
229
|
-
while (stack.length > 0) {
|
|
230
|
-
const node = stack.pop();
|
|
231
|
-
const currentOffset = node.offset;
|
|
232
|
-
if (currentOffset < updateOffsetStart && currentOffset + node.node.length <= updateOffsetStart) {
|
|
233
|
-
if (!isLeaf(node.node)) {
|
|
234
|
-
node.node.parent = undefined;
|
|
235
|
-
}
|
|
236
|
-
precedingNodes.push(node.node);
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
else if (isLeaf(node.node) && (currentOffset < updateOffsetStart)) {
|
|
240
|
-
// We have a partial preceding node
|
|
241
|
-
precedingNodes.push({ length: updateOffsetStart - currentOffset, token: node.node.token, height: 0, tokenQuality: node.node.tokenQuality });
|
|
242
|
-
// Node could also be postceeding, so don't continue
|
|
243
|
-
}
|
|
244
|
-
if ((updateOffsetStart <= currentOffset) && (currentOffset + node.node.length <= firstUnchangedOffsetAfterUpdate)) {
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (currentOffset >= firstUnchangedOffsetAfterUpdate) {
|
|
248
|
-
if (!isLeaf(node.node)) {
|
|
249
|
-
node.node.parent = undefined;
|
|
250
|
-
}
|
|
251
|
-
postcedingNodes.push(node.node);
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
else if (isLeaf(node.node) && (currentOffset + node.node.length > firstUnchangedOffsetAfterUpdate)) {
|
|
255
|
-
// we have a partial postceeding node
|
|
256
|
-
postcedingNodes.push({ length: currentOffset + node.node.length - firstUnchangedOffsetAfterUpdate, token: node.node.token, height: 0, tokenQuality: node.node.tokenQuality });
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
if (!isLeaf(node.node)) {
|
|
260
|
-
// Push children in reverse order to process them left-to-right when popping
|
|
261
|
-
let childOffset = currentOffset + node.node.length;
|
|
262
|
-
for (let i = node.node.children.length - 1; i >= 0; i--) {
|
|
263
|
-
childOffset -= node.node.children[i].length;
|
|
264
|
-
stack.push({ node: node.node.children[i], offset: childOffset });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
let allNodes;
|
|
269
|
-
if (tokens.length > 0) {
|
|
270
|
-
allNodes = precedingNodes.concat(this.createFromUpdates(tokens, tokenQuality), postcedingNodes);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
allNodes = precedingNodes.concat(postcedingNodes);
|
|
274
|
-
}
|
|
275
|
-
let newRoot = allNodes[0];
|
|
276
|
-
for (let i = 1; i < allNodes.length; i++) {
|
|
277
|
-
newRoot = concat(newRoot, allNodes[i]);
|
|
278
|
-
}
|
|
279
|
-
this._root = newRoot ?? this.createEmptyRoot();
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* @param startOffsetInclusive
|
|
284
|
-
* @param endOffsetExclusive
|
|
285
|
-
* @param visitor Return true from visitor to exit early
|
|
286
|
-
* @returns
|
|
287
|
-
*/
|
|
288
|
-
traverseInOrderInRange(startOffsetInclusive, endOffsetExclusive, visitor) {
|
|
289
|
-
const stack = [{ node: this._root, offset: 0 }];
|
|
290
|
-
while (stack.length > 0) {
|
|
291
|
-
const { node, offset } = stack.pop();
|
|
292
|
-
const nodeEnd = offset + node.length;
|
|
293
|
-
// Skip nodes that are completely before or after the range
|
|
294
|
-
if (nodeEnd <= startOffsetInclusive || offset >= endOffsetExclusive) {
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
if (visitor(node, offset)) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (!isLeaf(node)) {
|
|
301
|
-
// Push children in reverse order to process them left-to-right when popping
|
|
302
|
-
let childOffset = offset + node.length;
|
|
303
|
-
for (let i = node.children.length - 1; i >= 0; i--) {
|
|
304
|
-
childOffset -= node.children[i].length;
|
|
305
|
-
stack.push({ node: node.children[i], offset: childOffset });
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
getTokenAt(offset) {
|
|
311
|
-
let result;
|
|
312
|
-
this.traverseInOrderInRange(offset, this._root.length, (node, offset) => {
|
|
313
|
-
if (isLeaf(node)) {
|
|
314
|
-
result = { token: node.token, startOffsetInclusive: offset, length: node.length };
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
return false;
|
|
318
|
-
});
|
|
319
|
-
return result;
|
|
320
|
-
}
|
|
321
|
-
getTokensInRange(startOffsetInclusive, endOffsetExclusive) {
|
|
322
|
-
const result = [];
|
|
323
|
-
this.traverseInOrderInRange(startOffsetInclusive, endOffsetExclusive, (node, offset) => {
|
|
324
|
-
if (isLeaf(node)) {
|
|
325
|
-
let clippedLength = node.length;
|
|
326
|
-
let clippedOffset = offset;
|
|
327
|
-
if ((offset < startOffsetInclusive) && (offset + node.length > endOffsetExclusive)) {
|
|
328
|
-
clippedOffset = startOffsetInclusive;
|
|
329
|
-
clippedLength = endOffsetExclusive - startOffsetInclusive;
|
|
330
|
-
}
|
|
331
|
-
else if (offset < startOffsetInclusive) {
|
|
332
|
-
clippedLength -= (startOffsetInclusive - offset);
|
|
333
|
-
clippedOffset = startOffsetInclusive;
|
|
334
|
-
}
|
|
335
|
-
else if (offset + node.length > endOffsetExclusive) {
|
|
336
|
-
clippedLength -= (offset + node.length - endOffsetExclusive);
|
|
337
|
-
}
|
|
338
|
-
result.push({ token: node.token, startOffsetInclusive: clippedOffset, length: clippedLength });
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
341
|
-
});
|
|
342
|
-
return result;
|
|
343
|
-
}
|
|
344
|
-
markForRefresh(startOffsetInclusive, endOffsetExclusive) {
|
|
345
|
-
this.traverseInOrderInRange(startOffsetInclusive, endOffsetExclusive, (node) => {
|
|
346
|
-
if (isLeaf(node)) {
|
|
347
|
-
node.tokenQuality = TokenQuality.None;
|
|
348
|
-
}
|
|
349
|
-
return false;
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
rangeHasTokens(startOffsetInclusive, endOffsetExclusive, minimumTokenQuality) {
|
|
353
|
-
let hasAny = true;
|
|
354
|
-
this.traverseInOrderInRange(startOffsetInclusive, endOffsetExclusive, (node) => {
|
|
355
|
-
if (isLeaf(node) && (node.tokenQuality < minimumTokenQuality)) {
|
|
356
|
-
hasAny = false;
|
|
357
|
-
}
|
|
358
|
-
return false;
|
|
359
|
-
});
|
|
360
|
-
return hasAny;
|
|
361
|
-
}
|
|
362
|
-
rangeNeedsRefresh(startOffsetInclusive, endOffsetExclusive) {
|
|
363
|
-
let needsRefresh = false;
|
|
364
|
-
this.traverseInOrderInRange(startOffsetInclusive, endOffsetExclusive, (node) => {
|
|
365
|
-
if (isLeaf(node) && (node.tokenQuality !== TokenQuality.Accurate)) {
|
|
366
|
-
needsRefresh = true;
|
|
367
|
-
}
|
|
368
|
-
return false;
|
|
369
|
-
});
|
|
370
|
-
return needsRefresh;
|
|
371
|
-
}
|
|
372
|
-
getNeedsRefresh() {
|
|
373
|
-
const result = [];
|
|
374
|
-
this.traverseInOrderInRange(0, this._textModel.getValueLength(), (node, offset) => {
|
|
375
|
-
if (isLeaf(node) && (node.tokenQuality !== TokenQuality.Accurate)) {
|
|
376
|
-
if ((result.length > 0) && (result[result.length - 1].endOffset === offset)) {
|
|
377
|
-
result[result.length - 1].endOffset += node.length;
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
result.push({ startOffset: offset, endOffset: offset + node.length });
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return false;
|
|
384
|
-
});
|
|
385
|
-
return result;
|
|
386
|
-
}
|
|
387
|
-
dispose() {
|
|
388
|
-
const stack = [[this._root, false]];
|
|
389
|
-
while (stack.length > 0) {
|
|
390
|
-
const [node, visited] = stack.pop();
|
|
391
|
-
if (isLeaf(node)) ;
|
|
392
|
-
else if (!visited) {
|
|
393
|
-
stack.push([node, true]);
|
|
394
|
-
for (let i = node.children.length - 1; i >= 0; i--) {
|
|
395
|
-
stack.push([node.children[i], false]);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
node.dispose();
|
|
400
|
-
node.parent = undefined;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
this._root = undefined;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export { ListNode, TokenQuality, TokenStore };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { OffsetRange } from '../core/ranges/offsetRange.js';
|
|
2
|
-
import { LineTokens } from './lineTokens.js';
|
|
3
|
-
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
/**
|
|
9
|
-
* This class represents a sequence of tokens.
|
|
10
|
-
* Conceptually, each token has a length and a metadata number.
|
|
11
|
-
* A token array might be used to annotate a string with metadata.
|
|
12
|
-
* Use {@link TokenWithTextArrayBuilder} to efficiently create a token array.
|
|
13
|
-
*
|
|
14
|
-
* TODO: Make this class more efficient (e.g. by using a Int32Array).
|
|
15
|
-
*/
|
|
16
|
-
class TokenWithTextArray {
|
|
17
|
-
static fromLineTokens(lineTokens) {
|
|
18
|
-
const tokenInfo = [];
|
|
19
|
-
for (let i = 0; i < lineTokens.getCount(); i++) {
|
|
20
|
-
tokenInfo.push(new TokenWithTextInfo(lineTokens.getTokenText(i), lineTokens.getMetadata(i)));
|
|
21
|
-
}
|
|
22
|
-
return TokenWithTextArray.create(tokenInfo);
|
|
23
|
-
}
|
|
24
|
-
static create(tokenInfo) {
|
|
25
|
-
return new TokenWithTextArray(tokenInfo);
|
|
26
|
-
}
|
|
27
|
-
constructor(_tokenInfo) {
|
|
28
|
-
this._tokenInfo = _tokenInfo;
|
|
29
|
-
}
|
|
30
|
-
toLineTokens(decoder) {
|
|
31
|
-
return LineTokens.createFromTextAndMetadata(this.map((_r, t) => ({ text: t.text, metadata: t.metadata })), decoder);
|
|
32
|
-
}
|
|
33
|
-
map(cb) {
|
|
34
|
-
const result = [];
|
|
35
|
-
let lengthSum = 0;
|
|
36
|
-
for (const tokenInfo of this._tokenInfo) {
|
|
37
|
-
const range = new OffsetRange(lengthSum, lengthSum + tokenInfo.text.length);
|
|
38
|
-
result.push(cb(range, tokenInfo));
|
|
39
|
-
lengthSum += tokenInfo.text.length;
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
slice(range) {
|
|
44
|
-
const result = [];
|
|
45
|
-
let lengthSum = 0;
|
|
46
|
-
for (const tokenInfo of this._tokenInfo) {
|
|
47
|
-
const tokenStart = lengthSum;
|
|
48
|
-
const tokenEndEx = tokenStart + tokenInfo.text.length;
|
|
49
|
-
if (tokenEndEx > range.start) {
|
|
50
|
-
if (tokenStart >= range.endExclusive) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
const deltaBefore = Math.max(0, range.start - tokenStart);
|
|
54
|
-
const deltaAfter = Math.max(0, tokenEndEx - range.endExclusive);
|
|
55
|
-
result.push(new TokenWithTextInfo(tokenInfo.text.slice(deltaBefore, tokenInfo.text.length - deltaAfter), tokenInfo.metadata));
|
|
56
|
-
}
|
|
57
|
-
lengthSum += tokenInfo.text.length;
|
|
58
|
-
}
|
|
59
|
-
return TokenWithTextArray.create(result);
|
|
60
|
-
}
|
|
61
|
-
append(other) {
|
|
62
|
-
const result = this._tokenInfo.concat(other._tokenInfo);
|
|
63
|
-
return TokenWithTextArray.create(result);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class TokenWithTextInfo {
|
|
67
|
-
constructor(text, metadata) {
|
|
68
|
-
this.text = text;
|
|
69
|
-
this.metadata = metadata;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { TokenWithTextArray, TokenWithTextInfo };
|