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,485 +0,0 @@
|
|
|
1
|
-
import { BugIndicatingError } from '../../../../../base/common/errors.js';
|
|
2
|
-
import { CursorColumns } from '../../../core/cursorColumns.js';
|
|
3
|
-
import { lengthToObj, lengthGetLineCount, lengthAdd, lengthZero } from './length.js';
|
|
4
|
-
import { SmallImmutableSet } from './smallImmutableSet.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
|
-
/**
|
|
11
|
-
* The base implementation for all AST nodes.
|
|
12
|
-
*/
|
|
13
|
-
class BaseAstNode {
|
|
14
|
-
/**
|
|
15
|
-
* The length of the entire node, which should equal the sum of lengths of all children.
|
|
16
|
-
*/
|
|
17
|
-
get length() {
|
|
18
|
-
return this._length;
|
|
19
|
-
}
|
|
20
|
-
constructor(length) {
|
|
21
|
-
this._length = length;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Represents a bracket pair including its child (e.g. `{ ... }`).
|
|
26
|
-
* Might be unclosed.
|
|
27
|
-
* Immutable, if all children are immutable.
|
|
28
|
-
*/
|
|
29
|
-
class PairAstNode extends BaseAstNode {
|
|
30
|
-
static create(openingBracket, child, closingBracket) {
|
|
31
|
-
let length = openingBracket.length;
|
|
32
|
-
if (child) {
|
|
33
|
-
length = lengthAdd(length, child.length);
|
|
34
|
-
}
|
|
35
|
-
if (closingBracket) {
|
|
36
|
-
length = lengthAdd(length, closingBracket.length);
|
|
37
|
-
}
|
|
38
|
-
return new PairAstNode(length, openingBracket, child, closingBracket, child ? child.missingOpeningBracketIds : SmallImmutableSet.getEmpty());
|
|
39
|
-
}
|
|
40
|
-
get kind() {
|
|
41
|
-
return 2 /* AstNodeKind.Pair */;
|
|
42
|
-
}
|
|
43
|
-
get listHeight() {
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
get childrenLength() {
|
|
47
|
-
return 3;
|
|
48
|
-
}
|
|
49
|
-
getChild(idx) {
|
|
50
|
-
switch (idx) {
|
|
51
|
-
case 0: return this.openingBracket;
|
|
52
|
-
case 1: return this.child;
|
|
53
|
-
case 2: return this.closingBracket;
|
|
54
|
-
}
|
|
55
|
-
throw new Error('Invalid child index');
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Avoid using this property, it allocates an array!
|
|
59
|
-
*/
|
|
60
|
-
get children() {
|
|
61
|
-
const result = [];
|
|
62
|
-
result.push(this.openingBracket);
|
|
63
|
-
if (this.child) {
|
|
64
|
-
result.push(this.child);
|
|
65
|
-
}
|
|
66
|
-
if (this.closingBracket) {
|
|
67
|
-
result.push(this.closingBracket);
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
constructor(length, openingBracket, child, closingBracket, missingOpeningBracketIds) {
|
|
72
|
-
super(length);
|
|
73
|
-
this.openingBracket = openingBracket;
|
|
74
|
-
this.child = child;
|
|
75
|
-
this.closingBracket = closingBracket;
|
|
76
|
-
this.missingOpeningBracketIds = missingOpeningBracketIds;
|
|
77
|
-
}
|
|
78
|
-
canBeReused(openBracketIds) {
|
|
79
|
-
if (this.closingBracket === null) {
|
|
80
|
-
// Unclosed pair ast nodes only
|
|
81
|
-
// end at the end of the document
|
|
82
|
-
// or when a parent node is closed.
|
|
83
|
-
// This could be improved:
|
|
84
|
-
// Only return false if some next token is neither "undefined" nor a bracket that closes a parent.
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
if (openBracketIds.intersects(this.missingOpeningBracketIds)) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
deepClone() {
|
|
93
|
-
return new PairAstNode(this.length, this.openingBracket.deepClone(), this.child && this.child.deepClone(), this.closingBracket && this.closingBracket.deepClone(), this.missingOpeningBracketIds);
|
|
94
|
-
}
|
|
95
|
-
computeMinIndentation(offset, textModel) {
|
|
96
|
-
return this.child ? this.child.computeMinIndentation(lengthAdd(offset, this.openingBracket.length), textModel) : Number.MAX_SAFE_INTEGER;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
class ListAstNode extends BaseAstNode {
|
|
100
|
-
/**
|
|
101
|
-
* This method uses more memory-efficient list nodes that can only store 2 or 3 children.
|
|
102
|
-
*/
|
|
103
|
-
static create23(item1, item2, item3, immutable = false) {
|
|
104
|
-
let length = item1.length;
|
|
105
|
-
let missingBracketIds = item1.missingOpeningBracketIds;
|
|
106
|
-
if (item1.listHeight !== item2.listHeight) {
|
|
107
|
-
throw new Error('Invalid list heights');
|
|
108
|
-
}
|
|
109
|
-
length = lengthAdd(length, item2.length);
|
|
110
|
-
missingBracketIds = missingBracketIds.merge(item2.missingOpeningBracketIds);
|
|
111
|
-
if (item3) {
|
|
112
|
-
if (item1.listHeight !== item3.listHeight) {
|
|
113
|
-
throw new Error('Invalid list heights');
|
|
114
|
-
}
|
|
115
|
-
length = lengthAdd(length, item3.length);
|
|
116
|
-
missingBracketIds = missingBracketIds.merge(item3.missingOpeningBracketIds);
|
|
117
|
-
}
|
|
118
|
-
return immutable
|
|
119
|
-
? new Immutable23ListAstNode(length, item1.listHeight + 1, item1, item2, item3, missingBracketIds)
|
|
120
|
-
: new TwoThreeListAstNode(length, item1.listHeight + 1, item1, item2, item3, missingBracketIds);
|
|
121
|
-
}
|
|
122
|
-
static getEmpty() {
|
|
123
|
-
return new ImmutableArrayListAstNode(lengthZero, 0, [], SmallImmutableSet.getEmpty());
|
|
124
|
-
}
|
|
125
|
-
get kind() {
|
|
126
|
-
return 4 /* AstNodeKind.List */;
|
|
127
|
-
}
|
|
128
|
-
get missingOpeningBracketIds() {
|
|
129
|
-
return this._missingOpeningBracketIds;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Use ListAstNode.create.
|
|
133
|
-
*/
|
|
134
|
-
constructor(length, listHeight, _missingOpeningBracketIds) {
|
|
135
|
-
super(length);
|
|
136
|
-
this.listHeight = listHeight;
|
|
137
|
-
this._missingOpeningBracketIds = _missingOpeningBracketIds;
|
|
138
|
-
this.cachedMinIndentation = -1;
|
|
139
|
-
}
|
|
140
|
-
throwIfImmutable() {
|
|
141
|
-
// NOOP
|
|
142
|
-
}
|
|
143
|
-
makeLastElementMutable() {
|
|
144
|
-
this.throwIfImmutable();
|
|
145
|
-
const childCount = this.childrenLength;
|
|
146
|
-
if (childCount === 0) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
const lastChild = this.getChild(childCount - 1);
|
|
150
|
-
const mutable = lastChild.kind === 4 /* AstNodeKind.List */ ? lastChild.toMutable() : lastChild;
|
|
151
|
-
if (lastChild !== mutable) {
|
|
152
|
-
this.setChild(childCount - 1, mutable);
|
|
153
|
-
}
|
|
154
|
-
return mutable;
|
|
155
|
-
}
|
|
156
|
-
makeFirstElementMutable() {
|
|
157
|
-
this.throwIfImmutable();
|
|
158
|
-
const childCount = this.childrenLength;
|
|
159
|
-
if (childCount === 0) {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
const firstChild = this.getChild(0);
|
|
163
|
-
const mutable = firstChild.kind === 4 /* AstNodeKind.List */ ? firstChild.toMutable() : firstChild;
|
|
164
|
-
if (firstChild !== mutable) {
|
|
165
|
-
this.setChild(0, mutable);
|
|
166
|
-
}
|
|
167
|
-
return mutable;
|
|
168
|
-
}
|
|
169
|
-
canBeReused(openBracketIds) {
|
|
170
|
-
if (openBracketIds.intersects(this.missingOpeningBracketIds)) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
if (this.childrenLength === 0) {
|
|
174
|
-
// Don't reuse empty lists.
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
let lastChild = this;
|
|
178
|
-
while (lastChild.kind === 4 /* AstNodeKind.List */) {
|
|
179
|
-
const lastLength = lastChild.childrenLength;
|
|
180
|
-
if (lastLength === 0) {
|
|
181
|
-
// Empty lists should never be contained in other lists.
|
|
182
|
-
throw new BugIndicatingError();
|
|
183
|
-
}
|
|
184
|
-
lastChild = lastChild.getChild(lastLength - 1);
|
|
185
|
-
}
|
|
186
|
-
return lastChild.canBeReused(openBracketIds);
|
|
187
|
-
}
|
|
188
|
-
handleChildrenChanged() {
|
|
189
|
-
this.throwIfImmutable();
|
|
190
|
-
const count = this.childrenLength;
|
|
191
|
-
let length = this.getChild(0).length;
|
|
192
|
-
let unopenedBrackets = this.getChild(0).missingOpeningBracketIds;
|
|
193
|
-
for (let i = 1; i < count; i++) {
|
|
194
|
-
const child = this.getChild(i);
|
|
195
|
-
length = lengthAdd(length, child.length);
|
|
196
|
-
unopenedBrackets = unopenedBrackets.merge(child.missingOpeningBracketIds);
|
|
197
|
-
}
|
|
198
|
-
this._length = length;
|
|
199
|
-
this._missingOpeningBracketIds = unopenedBrackets;
|
|
200
|
-
this.cachedMinIndentation = -1;
|
|
201
|
-
}
|
|
202
|
-
computeMinIndentation(offset, textModel) {
|
|
203
|
-
if (this.cachedMinIndentation !== -1) {
|
|
204
|
-
return this.cachedMinIndentation;
|
|
205
|
-
}
|
|
206
|
-
let minIndentation = Number.MAX_SAFE_INTEGER;
|
|
207
|
-
let childOffset = offset;
|
|
208
|
-
for (let i = 0; i < this.childrenLength; i++) {
|
|
209
|
-
const child = this.getChild(i);
|
|
210
|
-
if (child) {
|
|
211
|
-
minIndentation = Math.min(minIndentation, child.computeMinIndentation(childOffset, textModel));
|
|
212
|
-
childOffset = lengthAdd(childOffset, child.length);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
this.cachedMinIndentation = minIndentation;
|
|
216
|
-
return minIndentation;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
class TwoThreeListAstNode extends ListAstNode {
|
|
220
|
-
get childrenLength() {
|
|
221
|
-
return this._item3 !== null ? 3 : 2;
|
|
222
|
-
}
|
|
223
|
-
getChild(idx) {
|
|
224
|
-
switch (idx) {
|
|
225
|
-
case 0: return this._item1;
|
|
226
|
-
case 1: return this._item2;
|
|
227
|
-
case 2: return this._item3;
|
|
228
|
-
}
|
|
229
|
-
throw new Error('Invalid child index');
|
|
230
|
-
}
|
|
231
|
-
setChild(idx, node) {
|
|
232
|
-
switch (idx) {
|
|
233
|
-
case 0:
|
|
234
|
-
this._item1 = node;
|
|
235
|
-
return;
|
|
236
|
-
case 1:
|
|
237
|
-
this._item2 = node;
|
|
238
|
-
return;
|
|
239
|
-
case 2:
|
|
240
|
-
this._item3 = node;
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
throw new Error('Invalid child index');
|
|
244
|
-
}
|
|
245
|
-
get children() {
|
|
246
|
-
return this._item3 ? [this._item1, this._item2, this._item3] : [this._item1, this._item2];
|
|
247
|
-
}
|
|
248
|
-
get item1() {
|
|
249
|
-
return this._item1;
|
|
250
|
-
}
|
|
251
|
-
get item2() {
|
|
252
|
-
return this._item2;
|
|
253
|
-
}
|
|
254
|
-
get item3() {
|
|
255
|
-
return this._item3;
|
|
256
|
-
}
|
|
257
|
-
constructor(length, listHeight, _item1, _item2, _item3, missingOpeningBracketIds) {
|
|
258
|
-
super(length, listHeight, missingOpeningBracketIds);
|
|
259
|
-
this._item1 = _item1;
|
|
260
|
-
this._item2 = _item2;
|
|
261
|
-
this._item3 = _item3;
|
|
262
|
-
}
|
|
263
|
-
deepClone() {
|
|
264
|
-
return new TwoThreeListAstNode(this.length, this.listHeight, this._item1.deepClone(), this._item2.deepClone(), this._item3 ? this._item3.deepClone() : null, this.missingOpeningBracketIds);
|
|
265
|
-
}
|
|
266
|
-
appendChildOfSameHeight(node) {
|
|
267
|
-
if (this._item3) {
|
|
268
|
-
throw new Error('Cannot append to a full (2,3) tree node');
|
|
269
|
-
}
|
|
270
|
-
this.throwIfImmutable();
|
|
271
|
-
this._item3 = node;
|
|
272
|
-
this.handleChildrenChanged();
|
|
273
|
-
}
|
|
274
|
-
unappendChild() {
|
|
275
|
-
if (!this._item3) {
|
|
276
|
-
throw new Error('Cannot remove from a non-full (2,3) tree node');
|
|
277
|
-
}
|
|
278
|
-
this.throwIfImmutable();
|
|
279
|
-
const result = this._item3;
|
|
280
|
-
this._item3 = null;
|
|
281
|
-
this.handleChildrenChanged();
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
prependChildOfSameHeight(node) {
|
|
285
|
-
if (this._item3) {
|
|
286
|
-
throw new Error('Cannot prepend to a full (2,3) tree node');
|
|
287
|
-
}
|
|
288
|
-
this.throwIfImmutable();
|
|
289
|
-
this._item3 = this._item2;
|
|
290
|
-
this._item2 = this._item1;
|
|
291
|
-
this._item1 = node;
|
|
292
|
-
this.handleChildrenChanged();
|
|
293
|
-
}
|
|
294
|
-
unprependChild() {
|
|
295
|
-
if (!this._item3) {
|
|
296
|
-
throw new Error('Cannot remove from a non-full (2,3) tree node');
|
|
297
|
-
}
|
|
298
|
-
this.throwIfImmutable();
|
|
299
|
-
const result = this._item1;
|
|
300
|
-
this._item1 = this._item2;
|
|
301
|
-
this._item2 = this._item3;
|
|
302
|
-
this._item3 = null;
|
|
303
|
-
this.handleChildrenChanged();
|
|
304
|
-
return result;
|
|
305
|
-
}
|
|
306
|
-
toMutable() {
|
|
307
|
-
return this;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Immutable, if all children are immutable.
|
|
312
|
-
*/
|
|
313
|
-
class Immutable23ListAstNode extends TwoThreeListAstNode {
|
|
314
|
-
toMutable() {
|
|
315
|
-
return new TwoThreeListAstNode(this.length, this.listHeight, this.item1, this.item2, this.item3, this.missingOpeningBracketIds);
|
|
316
|
-
}
|
|
317
|
-
throwIfImmutable() {
|
|
318
|
-
throw new Error('this instance is immutable');
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* For debugging.
|
|
323
|
-
*/
|
|
324
|
-
class ArrayListAstNode extends ListAstNode {
|
|
325
|
-
get childrenLength() {
|
|
326
|
-
return this._children.length;
|
|
327
|
-
}
|
|
328
|
-
getChild(idx) {
|
|
329
|
-
return this._children[idx];
|
|
330
|
-
}
|
|
331
|
-
setChild(idx, child) {
|
|
332
|
-
this._children[idx] = child;
|
|
333
|
-
}
|
|
334
|
-
get children() {
|
|
335
|
-
return this._children;
|
|
336
|
-
}
|
|
337
|
-
constructor(length, listHeight, _children, missingOpeningBracketIds) {
|
|
338
|
-
super(length, listHeight, missingOpeningBracketIds);
|
|
339
|
-
this._children = _children;
|
|
340
|
-
}
|
|
341
|
-
deepClone() {
|
|
342
|
-
const children = new Array(this._children.length);
|
|
343
|
-
for (let i = 0; i < this._children.length; i++) {
|
|
344
|
-
children[i] = this._children[i].deepClone();
|
|
345
|
-
}
|
|
346
|
-
return new ArrayListAstNode(this.length, this.listHeight, children, this.missingOpeningBracketIds);
|
|
347
|
-
}
|
|
348
|
-
appendChildOfSameHeight(node) {
|
|
349
|
-
this.throwIfImmutable();
|
|
350
|
-
this._children.push(node);
|
|
351
|
-
this.handleChildrenChanged();
|
|
352
|
-
}
|
|
353
|
-
unappendChild() {
|
|
354
|
-
this.throwIfImmutable();
|
|
355
|
-
const item = this._children.pop();
|
|
356
|
-
this.handleChildrenChanged();
|
|
357
|
-
return item;
|
|
358
|
-
}
|
|
359
|
-
prependChildOfSameHeight(node) {
|
|
360
|
-
this.throwIfImmutable();
|
|
361
|
-
this._children.unshift(node);
|
|
362
|
-
this.handleChildrenChanged();
|
|
363
|
-
}
|
|
364
|
-
unprependChild() {
|
|
365
|
-
this.throwIfImmutable();
|
|
366
|
-
const item = this._children.shift();
|
|
367
|
-
this.handleChildrenChanged();
|
|
368
|
-
return item;
|
|
369
|
-
}
|
|
370
|
-
toMutable() {
|
|
371
|
-
return this;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Immutable, if all children are immutable.
|
|
376
|
-
*/
|
|
377
|
-
class ImmutableArrayListAstNode extends ArrayListAstNode {
|
|
378
|
-
toMutable() {
|
|
379
|
-
return new ArrayListAstNode(this.length, this.listHeight, [...this.children], this.missingOpeningBracketIds);
|
|
380
|
-
}
|
|
381
|
-
throwIfImmutable() {
|
|
382
|
-
throw new Error('this instance is immutable');
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
const emptyArray = [];
|
|
386
|
-
class ImmutableLeafAstNode extends BaseAstNode {
|
|
387
|
-
get listHeight() {
|
|
388
|
-
return 0;
|
|
389
|
-
}
|
|
390
|
-
get childrenLength() {
|
|
391
|
-
return 0;
|
|
392
|
-
}
|
|
393
|
-
getChild(idx) {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
get children() {
|
|
397
|
-
return emptyArray;
|
|
398
|
-
}
|
|
399
|
-
deepClone() {
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
class TextAstNode extends ImmutableLeafAstNode {
|
|
404
|
-
get kind() {
|
|
405
|
-
return 0 /* AstNodeKind.Text */;
|
|
406
|
-
}
|
|
407
|
-
get missingOpeningBracketIds() {
|
|
408
|
-
return SmallImmutableSet.getEmpty();
|
|
409
|
-
}
|
|
410
|
-
canBeReused(_openedBracketIds) {
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
computeMinIndentation(offset, textModel) {
|
|
414
|
-
const start = lengthToObj(offset);
|
|
415
|
-
// Text ast nodes don't have partial indentation (ensured by the tokenizer).
|
|
416
|
-
// Thus, if this text node does not start at column 0, the first line cannot have any indentation at all.
|
|
417
|
-
const startLineNumber = (start.columnCount === 0 ? start.lineCount : start.lineCount + 1) + 1;
|
|
418
|
-
const endLineNumber = lengthGetLineCount(lengthAdd(offset, this.length)) + 1;
|
|
419
|
-
let result = Number.MAX_SAFE_INTEGER;
|
|
420
|
-
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
|
|
421
|
-
const firstNonWsColumn = textModel.getLineFirstNonWhitespaceColumn(lineNumber);
|
|
422
|
-
const lineContent = textModel.getLineContent(lineNumber);
|
|
423
|
-
if (firstNonWsColumn === 0) {
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
const visibleColumn = CursorColumns.visibleColumnFromColumn(lineContent, firstNonWsColumn, textModel.getOptions().tabSize);
|
|
427
|
-
result = Math.min(result, visibleColumn);
|
|
428
|
-
}
|
|
429
|
-
return result;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
class BracketAstNode extends ImmutableLeafAstNode {
|
|
433
|
-
static create(length, bracketInfo, bracketIds) {
|
|
434
|
-
const node = new BracketAstNode(length, bracketInfo, bracketIds);
|
|
435
|
-
return node;
|
|
436
|
-
}
|
|
437
|
-
get kind() {
|
|
438
|
-
return 1 /* AstNodeKind.Bracket */;
|
|
439
|
-
}
|
|
440
|
-
get missingOpeningBracketIds() {
|
|
441
|
-
return SmallImmutableSet.getEmpty();
|
|
442
|
-
}
|
|
443
|
-
constructor(length, bracketInfo,
|
|
444
|
-
/**
|
|
445
|
-
* In case of a opening bracket, this is the id of the opening bracket.
|
|
446
|
-
* In case of a closing bracket, this contains the ids of all opening brackets it can close.
|
|
447
|
-
*/
|
|
448
|
-
bracketIds) {
|
|
449
|
-
super(length);
|
|
450
|
-
this.bracketInfo = bracketInfo;
|
|
451
|
-
this.bracketIds = bracketIds;
|
|
452
|
-
}
|
|
453
|
-
get text() {
|
|
454
|
-
return this.bracketInfo.bracketText;
|
|
455
|
-
}
|
|
456
|
-
get languageId() {
|
|
457
|
-
return this.bracketInfo.languageId;
|
|
458
|
-
}
|
|
459
|
-
canBeReused(_openedBracketIds) {
|
|
460
|
-
// These nodes could be reused,
|
|
461
|
-
// but not in a general way.
|
|
462
|
-
// Their parent may be reused.
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
computeMinIndentation(offset, textModel) {
|
|
466
|
-
return Number.MAX_SAFE_INTEGER;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
class InvalidBracketAstNode extends ImmutableLeafAstNode {
|
|
470
|
-
get kind() {
|
|
471
|
-
return 3 /* AstNodeKind.UnexpectedClosingBracket */;
|
|
472
|
-
}
|
|
473
|
-
constructor(closingBrackets, length) {
|
|
474
|
-
super(length);
|
|
475
|
-
this.missingOpeningBracketIds = closingBrackets;
|
|
476
|
-
}
|
|
477
|
-
canBeReused(openedBracketIds) {
|
|
478
|
-
return !openedBracketIds.intersects(this.missingOpeningBracketIds);
|
|
479
|
-
}
|
|
480
|
-
computeMinIndentation(offset, textModel) {
|
|
481
|
-
return Number.MAX_SAFE_INTEGER;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
export { BracketAstNode, InvalidBracketAstNode, ListAstNode, PairAstNode, TextAstNode };
|