monaco-editor11 1.0.7 → 1.0.9
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/assets/css.worker-C7FogG4G.js +93 -0
- package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
- package/dist/assets/html.worker-C8VxctEJ.js +470 -0
- package/dist/assets/json.worker-CMC9kgPL.js +58 -0
- package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
- package/dist/index.d.ts +0 -6
- package/dist/monaco-editor11.es.js +49 -78
- package/dist/monaco-editor11.umd.js +1 -50
- package/dist/monaco.d.ts +8 -0
- package/dist/workers/common/initialize.js +16 -0
- package/dist/workers/common/workers.js +141 -0
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
- package/dist/workers/editor/common/abstractText.js +89 -0
- package/dist/workers/editor/common/ast.js +485 -0
- package/dist/workers/editor/common/autoIndent.js +390 -0
- package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
- package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
- package/dist/workers/editor/common/bracketPairsTree.js +343 -0
- package/dist/workers/editor/common/brackets.js +108 -0
- package/dist/workers/editor/common/characterClassifier.js +59 -0
- package/dist/workers/editor/common/characterPair.js +40 -0
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
- package/dist/workers/editor/common/columnRange.js +35 -0
- package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
- package/dist/workers/editor/common/common.js +20 -0
- package/dist/workers/editor/common/computeMovedLines.js +249 -0
- package/dist/workers/editor/common/concat23Trees.js +192 -0
- package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
- package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
- package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
- package/dist/workers/editor/common/coordinatesConverter.js +51 -0
- package/dist/workers/editor/common/cursor.js +899 -0
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
- package/dist/workers/editor/common/cursorCollection.js +194 -0
- package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
- package/dist/workers/editor/common/cursorColumns.js +112 -0
- package/dist/workers/editor/common/cursorCommon.js +250 -0
- package/dist/workers/editor/common/cursorContext.js +15 -0
- package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
- package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
- package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
- package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
- package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
- package/dist/workers/editor/common/cursorUtils.js +75 -0
- package/dist/workers/editor/common/cursorWordOperations.js +720 -0
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
- package/dist/workers/editor/common/diffAlgorithm.js +139 -0
- package/dist/workers/editor/common/diffEditor.js +38 -0
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
- package/dist/workers/editor/common/edit.js +183 -0
- package/dist/workers/editor/common/editOperation.js +36 -0
- package/dist/workers/editor/common/editStack.js +363 -0
- package/dist/workers/editor/common/editorAction.js +26 -0
- package/dist/workers/editor/common/editorBaseApi.js +43 -0
- package/dist/workers/editor/common/editorColorRegistry.js +102 -0
- package/dist/workers/editor/common/editorCommon.js +13 -0
- package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
- package/dist/workers/editor/common/editorContextKeys.js +84 -0
- package/dist/workers/editor/common/editorFeatures.js +17 -0
- package/dist/workers/editor/common/editorOptions.js +3440 -0
- package/dist/workers/editor/common/editorTheme.js +23 -0
- package/dist/workers/editor/common/editorWebWorker.js +299 -0
- package/dist/workers/editor/common/editorWorker.js +9 -0
- package/dist/workers/editor/common/editorWorkerHost.js +15 -0
- package/dist/workers/editor/common/editorZoom.js +26 -0
- package/dist/workers/editor/common/electricCharacter.js +55 -0
- package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
- package/dist/workers/editor/common/enterAction.js +53 -0
- package/dist/workers/editor/common/eolCounter.js +44 -0
- package/dist/workers/editor/common/findSectionHeaders.js +128 -0
- package/dist/workers/editor/common/fixBrackets.js +67 -0
- package/dist/workers/editor/common/fixedArray.js +70 -0
- package/dist/workers/editor/common/fontInfo.js +172 -0
- package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
- package/dist/workers/editor/common/getIconClasses.js +106 -0
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
- package/dist/workers/editor/common/glyphLanesModel.js +61 -0
- package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
- package/dist/workers/editor/common/indentRules.js +63 -0
- package/dist/workers/editor/common/indentation.js +39 -0
- package/dist/workers/editor/common/indentationGuesser.js +178 -0
- package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
- package/dist/workers/editor/common/inlineDecorations.js +26 -0
- package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
- package/dist/workers/editor/common/inputMode.js +22 -0
- package/dist/workers/editor/common/intervalTree.js +1002 -0
- package/dist/workers/editor/common/language.js +9 -0
- package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
- package/dist/workers/editor/common/languageConfiguration.js +138 -0
- package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
- package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
- package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
- package/dist/workers/editor/common/languageFeatures.js +9 -0
- package/dist/workers/editor/common/languageFeaturesService.js +47 -0
- package/dist/workers/editor/common/languageSelector.js +112 -0
- package/dist/workers/editor/common/languageService.js +92 -0
- package/dist/workers/editor/common/languages.js +522 -0
- package/dist/workers/editor/common/languagesAssociations.js +193 -0
- package/dist/workers/editor/common/languagesRegistry.js +237 -0
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
- package/dist/workers/editor/common/length.js +129 -0
- package/dist/workers/editor/common/lineDecorations.js +208 -0
- package/dist/workers/editor/common/lineEdit.js +75 -0
- package/dist/workers/editor/common/lineHeights.js +370 -0
- package/dist/workers/editor/common/linePart.js +25 -0
- package/dist/workers/editor/common/lineRange.js +312 -0
- package/dist/workers/editor/common/lineSequence.js +36 -0
- package/dist/workers/editor/common/lineTokens.js +405 -0
- package/dist/workers/editor/common/linesDiffComputer.js +29 -0
- package/dist/workers/editor/common/linesDiffComputers.js +13 -0
- package/dist/workers/editor/common/linesLayout.js +765 -0
- package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
- package/dist/workers/editor/common/linkComputer.js +269 -0
- package/dist/workers/editor/common/markerDecorations.js +9 -0
- package/dist/workers/editor/common/markerDecorationsService.js +248 -0
- package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
- package/dist/workers/editor/common/mirrorTextModel.js +117 -0
- package/dist/workers/editor/common/model.js +9 -0
- package/dist/workers/editor/common/modelLineProjection.js +350 -0
- package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
- package/dist/workers/editor/common/modelService.js +413 -0
- package/dist/workers/editor/common/modesRegistry.js +75 -0
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
- package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
- package/dist/workers/editor/common/nodeReader.js +127 -0
- package/dist/workers/editor/common/nullTokenize.js +29 -0
- package/dist/workers/editor/common/offsetRange.js +225 -0
- package/dist/workers/editor/common/onEnter.js +109 -0
- package/dist/workers/editor/common/oneCursor.js +117 -0
- package/dist/workers/editor/common/overviewZoneManager.js +176 -0
- package/dist/workers/editor/common/parser.js +121 -0
- package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
- package/dist/workers/editor/common/point.js +50 -0
- package/dist/workers/editor/common/position.js +142 -0
- package/dist/workers/editor/common/positionToOffset.js +17 -0
- package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
- package/dist/workers/editor/common/prefixSumComputer.js +226 -0
- package/dist/workers/editor/common/range.js +421 -0
- package/dist/workers/editor/common/rangeMapping.js +229 -0
- package/dist/workers/editor/common/rangeSingleLine.js +17 -0
- package/dist/workers/editor/common/rbTreeBase.js +362 -0
- package/dist/workers/editor/common/rect.js +163 -0
- package/dist/workers/editor/common/replaceCommand.js +158 -0
- package/dist/workers/editor/common/resolverService.js +5 -0
- package/dist/workers/editor/common/rgba.js +35 -0
- package/dist/workers/editor/common/richEditBrackets.js +356 -0
- package/dist/workers/editor/common/selection.js +145 -0
- package/dist/workers/editor/common/semanticTokensDto.js +82 -0
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
- package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
- package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
- package/dist/workers/editor/common/shiftCommand.js +241 -0
- package/dist/workers/editor/common/smallImmutableSet.js +108 -0
- package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
- package/dist/workers/editor/common/sparseTokensStore.js +210 -0
- package/dist/workers/editor/common/standaloneEnums.js +1017 -0
- package/dist/workers/editor/common/standaloneStrings.js +42 -0
- package/dist/workers/editor/common/stringBuilder.js +122 -0
- package/dist/workers/editor/common/stringEdit.js +165 -0
- package/dist/workers/editor/common/supports.js +58 -0
- package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
- package/dist/workers/editor/common/textChange.js +248 -0
- package/dist/workers/editor/common/textEdit.js +269 -0
- package/dist/workers/editor/common/textLength.js +87 -0
- package/dist/workers/editor/common/textModel.js +2031 -0
- package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
- package/dist/workers/editor/common/textModelDefaults.js +18 -0
- package/dist/workers/editor/common/textModelEditSource.js +166 -0
- package/dist/workers/editor/common/textModelEvents.js +216 -0
- package/dist/workers/editor/common/textModelGuides.js +40 -0
- package/dist/workers/editor/common/textModelPart.js +23 -0
- package/dist/workers/editor/common/textModelSearch.js +455 -0
- package/dist/workers/editor/common/textModelStringEdit.js +11 -0
- package/dist/workers/editor/common/textModelSync.impl.js +307 -0
- package/dist/workers/editor/common/textModelText.js +26 -0
- package/dist/workers/editor/common/textModelTokens.js +436 -0
- package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
- package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
- package/dist/workers/editor/common/tokenStore.js +407 -0
- package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
- package/dist/workers/editor/common/tokenization.js +287 -0
- package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
- package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
- package/dist/workers/editor/common/tokenizer.js +301 -0
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
- package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
- package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
- package/dist/workers/editor/common/treeSitterTree.js +395 -0
- package/dist/workers/editor/common/treeViewsDnd.js +24 -0
- package/dist/workers/editor/common/treeViewsDndService.js +12 -0
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
- package/dist/workers/editor/common/utils.js +62 -0
- package/dist/workers/editor/common/viewContext.js +22 -0
- package/dist/workers/editor/common/viewEventHandler.js +186 -0
- package/dist/workers/editor/common/viewEvents.js +180 -0
- package/dist/workers/editor/common/viewLayout.js +368 -0
- package/dist/workers/editor/common/viewLineRenderer.js +948 -0
- package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
- package/dist/workers/editor/common/viewModel.js +98 -0
- package/dist/workers/editor/common/viewModelDecoration.js +55 -0
- package/dist/workers/editor/common/viewModelDecorations.js +132 -0
- package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
- package/dist/workers/editor/common/viewModelImpl.js +1163 -0
- package/dist/workers/editor/common/viewModelLines.js +938 -0
- package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
- package/dist/workers/editor/common/wordHelper.js +127 -0
- package/dist/workers/editor/editor.worker.js +11 -0
- package/dist/workers/language/css.worker.js +8 -0
- package/dist/workers/language/cssMode.js +198 -0
- package/dist/workers/language/cssWorker.js +183 -0
- package/dist/workers/language/html.worker.js +8 -0
- package/dist/workers/language/htmlMode.js +213 -0
- package/dist/workers/language/htmlWorker.js +126 -0
- package/dist/workers/language/json.worker.js +8 -0
- package/dist/workers/language/jsonMode.js +224 -0
- package/dist/workers/language/jsonWorker.js +187 -0
- package/dist/workers/language/languageFeatures.js +1009 -0
- package/dist/workers/language/lib.index.js +103 -0
- package/dist/workers/language/lib.js +1107 -0
- package/dist/workers/language/lspLanguageFeatures.js +716 -0
- package/dist/workers/language/monaco.contribution.js +144 -0
- package/dist/workers/language/tokenization.js +189 -0
- package/dist/workers/language/ts.worker.js +14 -0
- package/dist/workers/language/tsMode.js +212 -0
- package/dist/workers/language/tsWorker.js +352 -0
- package/dist/workers/language/typescriptServices.js +210154 -0
- package/dist/workers/language/typescriptServicesMetadata.js +3 -0
- package/dist/workers/language/workerManager.js +65 -0
- package/package.json +3 -2
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { Position } from '../core/position.js';
|
|
2
|
+
import { Range } from '../core/range.js';
|
|
3
|
+
import { countEOL } from '../core/misc/eolCounter.js';
|
|
4
|
+
import { RateLimiter } from './common.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
|
+
* Represents sparse tokens over a contiguous range of lines.
|
|
12
|
+
*/
|
|
13
|
+
class SparseMultilineTokens {
|
|
14
|
+
static create(startLineNumber, tokens) {
|
|
15
|
+
return new SparseMultilineTokens(startLineNumber, new SparseMultilineTokensStorage(tokens));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* (Inclusive) start line number for these tokens.
|
|
19
|
+
*/
|
|
20
|
+
get startLineNumber() {
|
|
21
|
+
return this._startLineNumber;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* (Inclusive) end line number for these tokens.
|
|
25
|
+
*/
|
|
26
|
+
get endLineNumber() {
|
|
27
|
+
return this._endLineNumber;
|
|
28
|
+
}
|
|
29
|
+
constructor(startLineNumber, tokens) {
|
|
30
|
+
this._startLineNumber = startLineNumber;
|
|
31
|
+
this._tokens = tokens;
|
|
32
|
+
this._endLineNumber = this._startLineNumber + this._tokens.getMaxDeltaLine();
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this._tokens.toString(this._startLineNumber);
|
|
36
|
+
}
|
|
37
|
+
_updateEndLineNumber() {
|
|
38
|
+
this._endLineNumber = this._startLineNumber + this._tokens.getMaxDeltaLine();
|
|
39
|
+
}
|
|
40
|
+
isEmpty() {
|
|
41
|
+
return this._tokens.isEmpty();
|
|
42
|
+
}
|
|
43
|
+
getLineTokens(lineNumber) {
|
|
44
|
+
if (this._startLineNumber <= lineNumber && lineNumber <= this._endLineNumber) {
|
|
45
|
+
return this._tokens.getLineTokens(lineNumber - this._startLineNumber);
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
getRange() {
|
|
50
|
+
const deltaRange = this._tokens.getRange();
|
|
51
|
+
if (!deltaRange) {
|
|
52
|
+
return deltaRange;
|
|
53
|
+
}
|
|
54
|
+
return new Range(this._startLineNumber + deltaRange.startLineNumber, deltaRange.startColumn, this._startLineNumber + deltaRange.endLineNumber, deltaRange.endColumn);
|
|
55
|
+
}
|
|
56
|
+
removeTokens(range) {
|
|
57
|
+
const startLineIndex = range.startLineNumber - this._startLineNumber;
|
|
58
|
+
const endLineIndex = range.endLineNumber - this._startLineNumber;
|
|
59
|
+
this._startLineNumber += this._tokens.removeTokens(startLineIndex, range.startColumn - 1, endLineIndex, range.endColumn - 1);
|
|
60
|
+
this._updateEndLineNumber();
|
|
61
|
+
}
|
|
62
|
+
split(range) {
|
|
63
|
+
// split tokens to two:
|
|
64
|
+
// a) all the tokens before `range`
|
|
65
|
+
// b) all the tokens after `range`
|
|
66
|
+
const startLineIndex = range.startLineNumber - this._startLineNumber;
|
|
67
|
+
const endLineIndex = range.endLineNumber - this._startLineNumber;
|
|
68
|
+
const [a, b, bDeltaLine] = this._tokens.split(startLineIndex, range.startColumn - 1, endLineIndex, range.endColumn - 1);
|
|
69
|
+
return [new SparseMultilineTokens(this._startLineNumber, a), new SparseMultilineTokens(this._startLineNumber + bDeltaLine, b)];
|
|
70
|
+
}
|
|
71
|
+
applyEdit(range, text) {
|
|
72
|
+
const [eolCount, firstLineLength, lastLineLength] = countEOL(text);
|
|
73
|
+
this.acceptEdit(range, eolCount, firstLineLength, lastLineLength, text.length > 0 ? text.charCodeAt(0) : 0 /* CharCode.Null */);
|
|
74
|
+
}
|
|
75
|
+
acceptEdit(range, eolCount, firstLineLength, lastLineLength, firstCharCode) {
|
|
76
|
+
this._acceptDeleteRange(range);
|
|
77
|
+
this._acceptInsertText(new Position(range.startLineNumber, range.startColumn), eolCount, firstLineLength, lastLineLength, firstCharCode);
|
|
78
|
+
this._updateEndLineNumber();
|
|
79
|
+
}
|
|
80
|
+
_acceptDeleteRange(range) {
|
|
81
|
+
if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
|
|
82
|
+
// Nothing to delete
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const firstLineIndex = range.startLineNumber - this._startLineNumber;
|
|
86
|
+
const lastLineIndex = range.endLineNumber - this._startLineNumber;
|
|
87
|
+
if (lastLineIndex < 0) {
|
|
88
|
+
// this deletion occurs entirely before this block, so we only need to adjust line numbers
|
|
89
|
+
const deletedLinesCount = lastLineIndex - firstLineIndex;
|
|
90
|
+
this._startLineNumber -= deletedLinesCount;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const tokenMaxDeltaLine = this._tokens.getMaxDeltaLine();
|
|
94
|
+
if (firstLineIndex >= tokenMaxDeltaLine + 1) {
|
|
95
|
+
// this deletion occurs entirely after this block, so there is nothing to do
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (firstLineIndex < 0 && lastLineIndex >= tokenMaxDeltaLine + 1) {
|
|
99
|
+
// this deletion completely encompasses this block
|
|
100
|
+
this._startLineNumber = 0;
|
|
101
|
+
this._tokens.clear();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (firstLineIndex < 0) {
|
|
105
|
+
const deletedBefore = -firstLineIndex;
|
|
106
|
+
this._startLineNumber -= deletedBefore;
|
|
107
|
+
this._tokens.acceptDeleteRange(range.startColumn - 1, 0, 0, lastLineIndex, range.endColumn - 1);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this._tokens.acceptDeleteRange(0, firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_acceptInsertText(position, eolCount, firstLineLength, lastLineLength, firstCharCode) {
|
|
114
|
+
if (eolCount === 0 && firstLineLength === 0) {
|
|
115
|
+
// Nothing to insert
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const lineIndex = position.lineNumber - this._startLineNumber;
|
|
119
|
+
if (lineIndex < 0) {
|
|
120
|
+
// this insertion occurs before this block, so we only need to adjust line numbers
|
|
121
|
+
this._startLineNumber += eolCount;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const tokenMaxDeltaLine = this._tokens.getMaxDeltaLine();
|
|
125
|
+
if (lineIndex >= tokenMaxDeltaLine + 1) {
|
|
126
|
+
// this insertion occurs after this block, so there is nothing to do
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this._tokens.acceptInsertText(lineIndex, position.column - 1, eolCount, firstLineLength, lastLineLength, firstCharCode);
|
|
130
|
+
}
|
|
131
|
+
reportIfInvalid(model) {
|
|
132
|
+
this._tokens.reportIfInvalid(model, this._startLineNumber);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class SparseMultilineTokensStorage {
|
|
136
|
+
constructor(tokens) {
|
|
137
|
+
this._tokens = tokens;
|
|
138
|
+
this._tokenCount = tokens.length / 4;
|
|
139
|
+
}
|
|
140
|
+
toString(startLineNumber) {
|
|
141
|
+
const pieces = [];
|
|
142
|
+
for (let i = 0; i < this._tokenCount; i++) {
|
|
143
|
+
pieces.push(`(${this._getDeltaLine(i) + startLineNumber},${this._getStartCharacter(i)}-${this._getEndCharacter(i)})`);
|
|
144
|
+
}
|
|
145
|
+
return `[${pieces.join(',')}]`;
|
|
146
|
+
}
|
|
147
|
+
getMaxDeltaLine() {
|
|
148
|
+
const tokenCount = this._getTokenCount();
|
|
149
|
+
if (tokenCount === 0) {
|
|
150
|
+
return -1;
|
|
151
|
+
}
|
|
152
|
+
return this._getDeltaLine(tokenCount - 1);
|
|
153
|
+
}
|
|
154
|
+
getRange() {
|
|
155
|
+
const tokenCount = this._getTokenCount();
|
|
156
|
+
if (tokenCount === 0) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const startChar = this._getStartCharacter(0);
|
|
160
|
+
const maxDeltaLine = this._getDeltaLine(tokenCount - 1);
|
|
161
|
+
const endChar = this._getEndCharacter(tokenCount - 1);
|
|
162
|
+
return new Range(0, startChar + 1, maxDeltaLine, endChar + 1);
|
|
163
|
+
}
|
|
164
|
+
_getTokenCount() {
|
|
165
|
+
return this._tokenCount;
|
|
166
|
+
}
|
|
167
|
+
_getDeltaLine(tokenIndex) {
|
|
168
|
+
return this._tokens[4 * tokenIndex];
|
|
169
|
+
}
|
|
170
|
+
_getStartCharacter(tokenIndex) {
|
|
171
|
+
return this._tokens[4 * tokenIndex + 1];
|
|
172
|
+
}
|
|
173
|
+
_getEndCharacter(tokenIndex) {
|
|
174
|
+
return this._tokens[4 * tokenIndex + 2];
|
|
175
|
+
}
|
|
176
|
+
isEmpty() {
|
|
177
|
+
return (this._getTokenCount() === 0);
|
|
178
|
+
}
|
|
179
|
+
getLineTokens(deltaLine) {
|
|
180
|
+
let low = 0;
|
|
181
|
+
let high = this._getTokenCount() - 1;
|
|
182
|
+
while (low < high) {
|
|
183
|
+
const mid = low + Math.floor((high - low) / 2);
|
|
184
|
+
const midDeltaLine = this._getDeltaLine(mid);
|
|
185
|
+
if (midDeltaLine < deltaLine) {
|
|
186
|
+
low = mid + 1;
|
|
187
|
+
}
|
|
188
|
+
else if (midDeltaLine > deltaLine) {
|
|
189
|
+
high = mid - 1;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
let min = mid;
|
|
193
|
+
while (min > low && this._getDeltaLine(min - 1) === deltaLine) {
|
|
194
|
+
min--;
|
|
195
|
+
}
|
|
196
|
+
let max = mid;
|
|
197
|
+
while (max < high && this._getDeltaLine(max + 1) === deltaLine) {
|
|
198
|
+
max++;
|
|
199
|
+
}
|
|
200
|
+
return new SparseLineTokens(this._tokens.subarray(4 * min, 4 * max + 4));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (this._getDeltaLine(low) === deltaLine) {
|
|
204
|
+
return new SparseLineTokens(this._tokens.subarray(4 * low, 4 * low + 4));
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
clear() {
|
|
209
|
+
this._tokenCount = 0;
|
|
210
|
+
}
|
|
211
|
+
removeTokens(startDeltaLine, startChar, endDeltaLine, endChar) {
|
|
212
|
+
const tokens = this._tokens;
|
|
213
|
+
const tokenCount = this._tokenCount;
|
|
214
|
+
let newTokenCount = 0;
|
|
215
|
+
let hasDeletedTokens = false;
|
|
216
|
+
let firstDeltaLine = 0;
|
|
217
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
218
|
+
const srcOffset = 4 * i;
|
|
219
|
+
const tokenDeltaLine = tokens[srcOffset];
|
|
220
|
+
const tokenStartCharacter = tokens[srcOffset + 1];
|
|
221
|
+
const tokenEndCharacter = tokens[srcOffset + 2];
|
|
222
|
+
const tokenMetadata = tokens[srcOffset + 3];
|
|
223
|
+
if ((tokenDeltaLine > startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter >= startChar))
|
|
224
|
+
&& (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter <= endChar))) {
|
|
225
|
+
hasDeletedTokens = true;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
if (newTokenCount === 0) {
|
|
229
|
+
firstDeltaLine = tokenDeltaLine;
|
|
230
|
+
}
|
|
231
|
+
if (hasDeletedTokens) {
|
|
232
|
+
// must move the token to the left
|
|
233
|
+
const destOffset = 4 * newTokenCount;
|
|
234
|
+
tokens[destOffset] = tokenDeltaLine - firstDeltaLine;
|
|
235
|
+
tokens[destOffset + 1] = tokenStartCharacter;
|
|
236
|
+
tokens[destOffset + 2] = tokenEndCharacter;
|
|
237
|
+
tokens[destOffset + 3] = tokenMetadata;
|
|
238
|
+
}
|
|
239
|
+
else if (firstDeltaLine !== 0) {
|
|
240
|
+
// must adjust the delta line in place
|
|
241
|
+
tokens[srcOffset] = tokenDeltaLine - firstDeltaLine;
|
|
242
|
+
}
|
|
243
|
+
newTokenCount++;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
this._tokenCount = newTokenCount;
|
|
247
|
+
return firstDeltaLine;
|
|
248
|
+
}
|
|
249
|
+
split(startDeltaLine, startChar, endDeltaLine, endChar) {
|
|
250
|
+
const tokens = this._tokens;
|
|
251
|
+
const tokenCount = this._tokenCount;
|
|
252
|
+
const aTokens = [];
|
|
253
|
+
const bTokens = [];
|
|
254
|
+
let destTokens = aTokens;
|
|
255
|
+
let destOffset = 0;
|
|
256
|
+
let destFirstDeltaLine = 0;
|
|
257
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
258
|
+
const srcOffset = 4 * i;
|
|
259
|
+
const tokenDeltaLine = tokens[srcOffset];
|
|
260
|
+
const tokenStartCharacter = tokens[srcOffset + 1];
|
|
261
|
+
const tokenEndCharacter = tokens[srcOffset + 2];
|
|
262
|
+
const tokenMetadata = tokens[srcOffset + 3];
|
|
263
|
+
if ((tokenDeltaLine > startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter >= startChar))) {
|
|
264
|
+
if ((tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter <= endChar))) {
|
|
265
|
+
// this token is touching the range
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// this token is after the range
|
|
270
|
+
if (destTokens !== bTokens) {
|
|
271
|
+
// this token is the first token after the range
|
|
272
|
+
destTokens = bTokens;
|
|
273
|
+
destOffset = 0;
|
|
274
|
+
destFirstDeltaLine = tokenDeltaLine;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
destTokens[destOffset++] = tokenDeltaLine - destFirstDeltaLine;
|
|
279
|
+
destTokens[destOffset++] = tokenStartCharacter;
|
|
280
|
+
destTokens[destOffset++] = tokenEndCharacter;
|
|
281
|
+
destTokens[destOffset++] = tokenMetadata;
|
|
282
|
+
}
|
|
283
|
+
return [new SparseMultilineTokensStorage(new Uint32Array(aTokens)), new SparseMultilineTokensStorage(new Uint32Array(bTokens)), destFirstDeltaLine];
|
|
284
|
+
}
|
|
285
|
+
acceptDeleteRange(horizontalShiftForFirstLineTokens, startDeltaLine, startCharacter, endDeltaLine, endCharacter) {
|
|
286
|
+
// This is a bit complex, here are the cases I used to think about this:
|
|
287
|
+
//
|
|
288
|
+
// 1. The token starts before the deletion range
|
|
289
|
+
// 1a. The token is completely before the deletion range
|
|
290
|
+
// -----------
|
|
291
|
+
// xxxxxxxxxxx
|
|
292
|
+
// 1b. The token starts before, the deletion range ends after the token
|
|
293
|
+
// -----------
|
|
294
|
+
// xxxxxxxxxxx
|
|
295
|
+
// 1c. The token starts before, the deletion range ends precisely with the token
|
|
296
|
+
// ---------------
|
|
297
|
+
// xxxxxxxx
|
|
298
|
+
// 1d. The token starts before, the deletion range is inside the token
|
|
299
|
+
// ---------------
|
|
300
|
+
// xxxxx
|
|
301
|
+
//
|
|
302
|
+
// 2. The token starts at the same position with the deletion range
|
|
303
|
+
// 2a. The token starts at the same position, and ends inside the deletion range
|
|
304
|
+
// -------
|
|
305
|
+
// xxxxxxxxxxx
|
|
306
|
+
// 2b. The token starts at the same position, and ends at the same position as the deletion range
|
|
307
|
+
// ----------
|
|
308
|
+
// xxxxxxxxxx
|
|
309
|
+
// 2c. The token starts at the same position, and ends after the deletion range
|
|
310
|
+
// -------------
|
|
311
|
+
// xxxxxxx
|
|
312
|
+
//
|
|
313
|
+
// 3. The token starts inside the deletion range
|
|
314
|
+
// 3a. The token is inside the deletion range
|
|
315
|
+
// -------
|
|
316
|
+
// xxxxxxxxxxxxx
|
|
317
|
+
// 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
|
|
318
|
+
// ----------
|
|
319
|
+
// xxxxxxxxxxxxx
|
|
320
|
+
// 3c. The token starts inside the deletion range, and ends after the deletion range
|
|
321
|
+
// ------------
|
|
322
|
+
// xxxxxxxxxxx
|
|
323
|
+
//
|
|
324
|
+
// 4. The token starts after the deletion range
|
|
325
|
+
// -----------
|
|
326
|
+
// xxxxxxxx
|
|
327
|
+
//
|
|
328
|
+
const tokens = this._tokens;
|
|
329
|
+
const tokenCount = this._tokenCount;
|
|
330
|
+
const deletedLineCount = (endDeltaLine - startDeltaLine);
|
|
331
|
+
let newTokenCount = 0;
|
|
332
|
+
let hasDeletedTokens = false;
|
|
333
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
334
|
+
const srcOffset = 4 * i;
|
|
335
|
+
let tokenDeltaLine = tokens[srcOffset];
|
|
336
|
+
let tokenStartCharacter = tokens[srcOffset + 1];
|
|
337
|
+
let tokenEndCharacter = tokens[srcOffset + 2];
|
|
338
|
+
const tokenMetadata = tokens[srcOffset + 3];
|
|
339
|
+
if (tokenDeltaLine < startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter <= startCharacter)) {
|
|
340
|
+
// 1a. The token is completely before the deletion range
|
|
341
|
+
// => nothing to do
|
|
342
|
+
newTokenCount++;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter < startCharacter) {
|
|
346
|
+
// 1b, 1c, 1d
|
|
347
|
+
// => the token survives, but it needs to shrink
|
|
348
|
+
if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
|
|
349
|
+
// 1d. The token starts before, the deletion range is inside the token
|
|
350
|
+
// => the token shrinks by the deletion character count
|
|
351
|
+
tokenEndCharacter -= (endCharacter - startCharacter);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// 1b. The token starts before, the deletion range ends after the token
|
|
355
|
+
// 1c. The token starts before, the deletion range ends precisely with the token
|
|
356
|
+
// => the token shrinks its ending to the deletion start
|
|
357
|
+
tokenEndCharacter = startCharacter;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter === startCharacter) {
|
|
361
|
+
// 2a, 2b, 2c
|
|
362
|
+
if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
|
|
363
|
+
// 2c. The token starts at the same position, and ends after the deletion range
|
|
364
|
+
// => the token shrinks by the deletion character count
|
|
365
|
+
tokenEndCharacter -= (endCharacter - startCharacter);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// 2a. The token starts at the same position, and ends inside the deletion range
|
|
369
|
+
// 2b. The token starts at the same position, and ends at the same position as the deletion range
|
|
370
|
+
// => the token is deleted
|
|
371
|
+
hasDeletedTokens = true;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else if (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter < endCharacter)) {
|
|
376
|
+
// 3a, 3b, 3c
|
|
377
|
+
if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
|
|
378
|
+
// 3c. The token starts inside the deletion range, and ends after the deletion range
|
|
379
|
+
// => the token moves to continue right after the deletion
|
|
380
|
+
tokenDeltaLine = startDeltaLine;
|
|
381
|
+
tokenStartCharacter = startCharacter;
|
|
382
|
+
tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
// 3a. The token is inside the deletion range
|
|
386
|
+
// 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
|
|
387
|
+
// => the token is deleted
|
|
388
|
+
hasDeletedTokens = true;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else if (tokenDeltaLine > endDeltaLine) {
|
|
393
|
+
// 4. (partial) The token starts after the deletion range, on a line below...
|
|
394
|
+
if (deletedLineCount === 0 && !hasDeletedTokens) {
|
|
395
|
+
// early stop, there is no need to walk all the tokens and do nothing...
|
|
396
|
+
newTokenCount = tokenCount;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
tokenDeltaLine -= deletedLineCount;
|
|
400
|
+
}
|
|
401
|
+
else if (tokenDeltaLine === endDeltaLine && tokenStartCharacter >= endCharacter) {
|
|
402
|
+
// 4. (continued) The token starts after the deletion range, on the last line where a deletion occurs
|
|
403
|
+
if (horizontalShiftForFirstLineTokens && tokenDeltaLine === 0) {
|
|
404
|
+
tokenStartCharacter += horizontalShiftForFirstLineTokens;
|
|
405
|
+
tokenEndCharacter += horizontalShiftForFirstLineTokens;
|
|
406
|
+
}
|
|
407
|
+
tokenDeltaLine -= deletedLineCount;
|
|
408
|
+
tokenStartCharacter -= (endCharacter - startCharacter);
|
|
409
|
+
tokenEndCharacter -= (endCharacter - startCharacter);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
throw new Error(`Not possible!`);
|
|
413
|
+
}
|
|
414
|
+
const destOffset = 4 * newTokenCount;
|
|
415
|
+
tokens[destOffset] = tokenDeltaLine;
|
|
416
|
+
tokens[destOffset + 1] = tokenStartCharacter;
|
|
417
|
+
tokens[destOffset + 2] = tokenEndCharacter;
|
|
418
|
+
tokens[destOffset + 3] = tokenMetadata;
|
|
419
|
+
newTokenCount++;
|
|
420
|
+
}
|
|
421
|
+
this._tokenCount = newTokenCount;
|
|
422
|
+
}
|
|
423
|
+
acceptInsertText(deltaLine, character, eolCount, firstLineLength, lastLineLength, firstCharCode) {
|
|
424
|
+
// Here are the cases I used to think about this:
|
|
425
|
+
//
|
|
426
|
+
// 1. The token is completely before the insertion point
|
|
427
|
+
// ----------- |
|
|
428
|
+
// 2. The token ends precisely at the insertion point
|
|
429
|
+
// -----------|
|
|
430
|
+
// 3. The token contains the insertion point
|
|
431
|
+
// -----|------
|
|
432
|
+
// 4. The token starts precisely at the insertion point
|
|
433
|
+
// |-----------
|
|
434
|
+
// 5. The token is completely after the insertion point
|
|
435
|
+
// | -----------
|
|
436
|
+
//
|
|
437
|
+
const isInsertingPreciselyOneWordCharacter = (eolCount === 0
|
|
438
|
+
&& firstLineLength === 1
|
|
439
|
+
&& ((firstCharCode >= 48 /* CharCode.Digit0 */ && firstCharCode <= 57 /* CharCode.Digit9 */)
|
|
440
|
+
|| (firstCharCode >= 65 /* CharCode.A */ && firstCharCode <= 90 /* CharCode.Z */)
|
|
441
|
+
|| (firstCharCode >= 97 /* CharCode.a */ && firstCharCode <= 122 /* CharCode.z */)));
|
|
442
|
+
const tokens = this._tokens;
|
|
443
|
+
const tokenCount = this._tokenCount;
|
|
444
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
445
|
+
const offset = 4 * i;
|
|
446
|
+
let tokenDeltaLine = tokens[offset];
|
|
447
|
+
let tokenStartCharacter = tokens[offset + 1];
|
|
448
|
+
let tokenEndCharacter = tokens[offset + 2];
|
|
449
|
+
if (tokenDeltaLine < deltaLine || (tokenDeltaLine === deltaLine && tokenEndCharacter < character)) {
|
|
450
|
+
// 1. The token is completely before the insertion point
|
|
451
|
+
// => nothing to do
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
else if (tokenDeltaLine === deltaLine && tokenEndCharacter === character) {
|
|
455
|
+
// 2. The token ends precisely at the insertion point
|
|
456
|
+
// => expand the end character only if inserting precisely one character that is a word character
|
|
457
|
+
if (isInsertingPreciselyOneWordCharacter) {
|
|
458
|
+
tokenEndCharacter += 1;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else if (tokenDeltaLine === deltaLine && tokenStartCharacter < character && character < tokenEndCharacter) {
|
|
465
|
+
// 3. The token contains the insertion point
|
|
466
|
+
if (eolCount === 0) {
|
|
467
|
+
// => just expand the end character
|
|
468
|
+
tokenEndCharacter += firstLineLength;
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
// => cut off the token
|
|
472
|
+
tokenEndCharacter = character;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// 4. or 5.
|
|
477
|
+
if (tokenDeltaLine === deltaLine && tokenStartCharacter === character) {
|
|
478
|
+
// 4. The token starts precisely at the insertion point
|
|
479
|
+
// => grow the token (by keeping its start constant) only if inserting precisely one character that is a word character
|
|
480
|
+
// => otherwise behave as in case 5.
|
|
481
|
+
if (isInsertingPreciselyOneWordCharacter) {
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
// => the token must move and keep its size constant
|
|
486
|
+
if (tokenDeltaLine === deltaLine) {
|
|
487
|
+
tokenDeltaLine += eolCount;
|
|
488
|
+
// this token is on the line where the insertion is taking place
|
|
489
|
+
if (eolCount === 0) {
|
|
490
|
+
tokenStartCharacter += firstLineLength;
|
|
491
|
+
tokenEndCharacter += firstLineLength;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
const tokenLength = tokenEndCharacter - tokenStartCharacter;
|
|
495
|
+
tokenStartCharacter = lastLineLength + (tokenStartCharacter - character);
|
|
496
|
+
tokenEndCharacter = tokenStartCharacter + tokenLength;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
tokenDeltaLine += eolCount;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
tokens[offset] = tokenDeltaLine;
|
|
504
|
+
tokens[offset + 1] = tokenStartCharacter;
|
|
505
|
+
tokens[offset + 2] = tokenEndCharacter;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
static { this._rateLimiter = new RateLimiter(10 / 60); } // limit to 10 times per minute
|
|
509
|
+
reportIfInvalid(model, startLineNumber) {
|
|
510
|
+
for (let i = 0; i < this._tokenCount; i++) {
|
|
511
|
+
const lineNumber = this._getDeltaLine(i) + startLineNumber;
|
|
512
|
+
if (lineNumber < 1) {
|
|
513
|
+
SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
|
|
514
|
+
console.error('Invalid Semantic Tokens Data From Extension: lineNumber < 1');
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
else if (lineNumber > model.getLineCount()) {
|
|
518
|
+
SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
|
|
519
|
+
console.error('Invalid Semantic Tokens Data From Extension: lineNumber > model.getLineCount()');
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
else if (this._getEndCharacter(i) > model.getLineLength(lineNumber)) {
|
|
523
|
+
SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
|
|
524
|
+
console.error('Invalid Semantic Tokens Data From Extension: end character > model.getLineLength(lineNumber)');
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
class SparseLineTokens {
|
|
531
|
+
constructor(tokens) {
|
|
532
|
+
this._tokens = tokens;
|
|
533
|
+
}
|
|
534
|
+
getCount() {
|
|
535
|
+
return this._tokens.length / 4;
|
|
536
|
+
}
|
|
537
|
+
getStartCharacter(tokenIndex) {
|
|
538
|
+
return this._tokens[4 * tokenIndex + 1];
|
|
539
|
+
}
|
|
540
|
+
getEndCharacter(tokenIndex) {
|
|
541
|
+
return this._tokens[4 * tokenIndex + 2];
|
|
542
|
+
}
|
|
543
|
+
getMetadata(tokenIndex) {
|
|
544
|
+
return this._tokens[4 * tokenIndex + 3];
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export { SparseLineTokens, SparseMultilineTokens };
|