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,35 +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
|
-
/**
|
|
6
|
-
* A very VM friendly rgba datastructure.
|
|
7
|
-
* Please don't touch unless you take a look at the IR.
|
|
8
|
-
*/
|
|
9
|
-
class RGBA8 {
|
|
10
|
-
static { this.Empty = new RGBA8(0, 0, 0, 0); }
|
|
11
|
-
constructor(r, g, b, a) {
|
|
12
|
-
this._rgba8Brand = undefined;
|
|
13
|
-
this.r = RGBA8._clamp(r);
|
|
14
|
-
this.g = RGBA8._clamp(g);
|
|
15
|
-
this.b = RGBA8._clamp(b);
|
|
16
|
-
this.a = RGBA8._clamp(a);
|
|
17
|
-
}
|
|
18
|
-
equals(other) {
|
|
19
|
-
return (this.r === other.r
|
|
20
|
-
&& this.g === other.g
|
|
21
|
-
&& this.b === other.b
|
|
22
|
-
&& this.a === other.a);
|
|
23
|
-
}
|
|
24
|
-
static _clamp(c) {
|
|
25
|
-
if (c < 0) {
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
if (c > 255) {
|
|
29
|
-
return 255;
|
|
30
|
-
}
|
|
31
|
-
return c | 0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { RGBA8 };
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import { createRegExp, escapeRegExpCharacters } from '../../../../base/common/strings.js';
|
|
2
|
-
import { getPlatformTextDecoder } from '../../core/stringBuilder.js';
|
|
3
|
-
import { Range } from '../../core/range.js';
|
|
4
|
-
|
|
5
|
-
/*---------------------------------------------------------------------------------------------
|
|
6
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
-
*--------------------------------------------------------------------------------------------*/
|
|
9
|
-
/**
|
|
10
|
-
* Represents a grouping of colliding bracket pairs.
|
|
11
|
-
*
|
|
12
|
-
* Most of the times this contains a single bracket pair,
|
|
13
|
-
* but sometimes this contains multiple bracket pairs in cases
|
|
14
|
-
* where the same string appears as a closing bracket for multiple
|
|
15
|
-
* bracket pairs, or the same string appears an opening bracket for
|
|
16
|
-
* multiple bracket pairs.
|
|
17
|
-
*
|
|
18
|
-
* e.g. of a group containing a single pair:
|
|
19
|
-
* open: ['{'], close: ['}']
|
|
20
|
-
*
|
|
21
|
-
* e.g. of a group containing multiple pairs:
|
|
22
|
-
* open: ['if', 'for'], close: ['end', 'end']
|
|
23
|
-
*/
|
|
24
|
-
class RichEditBracket {
|
|
25
|
-
constructor(languageId, index, open, close, forwardRegex, reversedRegex) {
|
|
26
|
-
this._richEditBracketBrand = undefined;
|
|
27
|
-
this.languageId = languageId;
|
|
28
|
-
this.index = index;
|
|
29
|
-
this.open = open;
|
|
30
|
-
this.close = close;
|
|
31
|
-
this.forwardRegex = forwardRegex;
|
|
32
|
-
this.reversedRegex = reversedRegex;
|
|
33
|
-
this._openSet = RichEditBracket._toSet(this.open);
|
|
34
|
-
this._closeSet = RichEditBracket._toSet(this.close);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Check if the provided `text` is an open bracket in this group.
|
|
38
|
-
*/
|
|
39
|
-
isOpen(text) {
|
|
40
|
-
return this._openSet.has(text);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check if the provided `text` is a close bracket in this group.
|
|
44
|
-
*/
|
|
45
|
-
isClose(text) {
|
|
46
|
-
return this._closeSet.has(text);
|
|
47
|
-
}
|
|
48
|
-
static _toSet(arr) {
|
|
49
|
-
const result = new Set();
|
|
50
|
-
for (const element of arr) {
|
|
51
|
-
result.add(element);
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Groups together brackets that have equal open or close sequences.
|
|
58
|
-
*
|
|
59
|
-
* For example, if the following brackets are defined:
|
|
60
|
-
* ['IF','END']
|
|
61
|
-
* ['for','end']
|
|
62
|
-
* ['{','}']
|
|
63
|
-
*
|
|
64
|
-
* Then the grouped brackets would be:
|
|
65
|
-
* { open: ['if', 'for'], close: ['end', 'end'] }
|
|
66
|
-
* { open: ['{'], close: ['}'] }
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
function groupFuzzyBrackets(brackets) {
|
|
70
|
-
const N = brackets.length;
|
|
71
|
-
brackets = brackets.map(b => [b[0].toLowerCase(), b[1].toLowerCase()]);
|
|
72
|
-
const group = [];
|
|
73
|
-
for (let i = 0; i < N; i++) {
|
|
74
|
-
group[i] = i;
|
|
75
|
-
}
|
|
76
|
-
const areOverlapping = (a, b) => {
|
|
77
|
-
const [aOpen, aClose] = a;
|
|
78
|
-
const [bOpen, bClose] = b;
|
|
79
|
-
return (aOpen === bOpen || aOpen === bClose || aClose === bOpen || aClose === bClose);
|
|
80
|
-
};
|
|
81
|
-
const mergeGroups = (g1, g2) => {
|
|
82
|
-
const newG = Math.min(g1, g2);
|
|
83
|
-
const oldG = Math.max(g1, g2);
|
|
84
|
-
for (let i = 0; i < N; i++) {
|
|
85
|
-
if (group[i] === oldG) {
|
|
86
|
-
group[i] = newG;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
// group together brackets that have the same open or the same close sequence
|
|
91
|
-
for (let i = 0; i < N; i++) {
|
|
92
|
-
const a = brackets[i];
|
|
93
|
-
for (let j = i + 1; j < N; j++) {
|
|
94
|
-
const b = brackets[j];
|
|
95
|
-
if (areOverlapping(a, b)) {
|
|
96
|
-
mergeGroups(group[i], group[j]);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const result = [];
|
|
101
|
-
for (let g = 0; g < N; g++) {
|
|
102
|
-
const currentOpen = [];
|
|
103
|
-
const currentClose = [];
|
|
104
|
-
for (let i = 0; i < N; i++) {
|
|
105
|
-
if (group[i] === g) {
|
|
106
|
-
const [open, close] = brackets[i];
|
|
107
|
-
currentOpen.push(open);
|
|
108
|
-
currentClose.push(close);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (currentOpen.length > 0) {
|
|
112
|
-
result.push({
|
|
113
|
-
open: currentOpen,
|
|
114
|
-
close: currentClose
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
class RichEditBrackets {
|
|
121
|
-
constructor(languageId, _brackets) {
|
|
122
|
-
this._richEditBracketsBrand = undefined;
|
|
123
|
-
const brackets = groupFuzzyBrackets(_brackets);
|
|
124
|
-
this.brackets = brackets.map((b, index) => {
|
|
125
|
-
return new RichEditBracket(languageId, index, b.open, b.close, getRegexForBracketPair(b.open, b.close, brackets, index), getReversedRegexForBracketPair(b.open, b.close, brackets, index));
|
|
126
|
-
});
|
|
127
|
-
this.forwardRegex = getRegexForBrackets(this.brackets);
|
|
128
|
-
this.reversedRegex = getReversedRegexForBrackets(this.brackets);
|
|
129
|
-
this.textIsBracket = {};
|
|
130
|
-
this.textIsOpenBracket = {};
|
|
131
|
-
this.maxBracketLength = 0;
|
|
132
|
-
for (const bracket of this.brackets) {
|
|
133
|
-
for (const open of bracket.open) {
|
|
134
|
-
this.textIsBracket[open] = bracket;
|
|
135
|
-
this.textIsOpenBracket[open] = true;
|
|
136
|
-
this.maxBracketLength = Math.max(this.maxBracketLength, open.length);
|
|
137
|
-
}
|
|
138
|
-
for (const close of bracket.close) {
|
|
139
|
-
this.textIsBracket[close] = bracket;
|
|
140
|
-
this.textIsOpenBracket[close] = false;
|
|
141
|
-
this.maxBracketLength = Math.max(this.maxBracketLength, close.length);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function collectSuperstrings(str, brackets, currentIndex, dest) {
|
|
147
|
-
for (let i = 0, len = brackets.length; i < len; i++) {
|
|
148
|
-
if (i === currentIndex) {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const bracket = brackets[i];
|
|
152
|
-
for (const open of bracket.open) {
|
|
153
|
-
if (open.indexOf(str) >= 0) {
|
|
154
|
-
dest.push(open);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
for (const close of bracket.close) {
|
|
158
|
-
if (close.indexOf(str) >= 0) {
|
|
159
|
-
dest.push(close);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function lengthcmp(a, b) {
|
|
165
|
-
return a.length - b.length;
|
|
166
|
-
}
|
|
167
|
-
function unique(arr) {
|
|
168
|
-
if (arr.length <= 1) {
|
|
169
|
-
return arr;
|
|
170
|
-
}
|
|
171
|
-
const result = [];
|
|
172
|
-
const seen = new Set();
|
|
173
|
-
for (const element of arr) {
|
|
174
|
-
if (seen.has(element)) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
result.push(element);
|
|
178
|
-
seen.add(element);
|
|
179
|
-
}
|
|
180
|
-
return result;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Create a regular expression that can be used to search forward in a piece of text
|
|
184
|
-
* for a group of bracket pairs. But this regex must be built in a way in which
|
|
185
|
-
* it is aware of the other bracket pairs defined for the language.
|
|
186
|
-
*
|
|
187
|
-
* For example, if a language contains the following bracket pairs:
|
|
188
|
-
* ['begin', 'end']
|
|
189
|
-
* ['if', 'end if']
|
|
190
|
-
* The two bracket pairs do not collide because no open or close brackets are equal.
|
|
191
|
-
* So the function getRegexForBracketPair is called twice, once with
|
|
192
|
-
* the ['begin'], ['end'] group consisting of one bracket pair, and once with
|
|
193
|
-
* the ['if'], ['end if'] group consiting of the other bracket pair.
|
|
194
|
-
*
|
|
195
|
-
* But there could be a situation where an occurrence of 'end if' is mistaken
|
|
196
|
-
* for an occurrence of 'end'.
|
|
197
|
-
*
|
|
198
|
-
* Therefore, for the bracket pair ['begin', 'end'], the regex will also
|
|
199
|
-
* target 'end if'. The regex will be something like:
|
|
200
|
-
* /(\bend if\b)|(\bend\b)|(\bif\b)/
|
|
201
|
-
*
|
|
202
|
-
* The regex also searches for "superstrings" (other brackets that might be mistaken with the current bracket).
|
|
203
|
-
*
|
|
204
|
-
*/
|
|
205
|
-
function getRegexForBracketPair(open, close, brackets, currentIndex) {
|
|
206
|
-
// search in all brackets for other brackets that are a superstring of these brackets
|
|
207
|
-
let pieces = [];
|
|
208
|
-
pieces = pieces.concat(open);
|
|
209
|
-
pieces = pieces.concat(close);
|
|
210
|
-
for (let i = 0, len = pieces.length; i < len; i++) {
|
|
211
|
-
collectSuperstrings(pieces[i], brackets, currentIndex, pieces);
|
|
212
|
-
}
|
|
213
|
-
pieces = unique(pieces);
|
|
214
|
-
pieces.sort(lengthcmp);
|
|
215
|
-
pieces.reverse();
|
|
216
|
-
return createBracketOrRegExp(pieces);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Matching a regular expression in JS can only be done "forwards". So JS offers natively only
|
|
220
|
-
* methods to find the first match of a regex in a string. But sometimes, it is useful to
|
|
221
|
-
* find the last match of a regex in a string. For such a situation, a nice solution is to
|
|
222
|
-
* simply reverse the string and then search for a reversed regex.
|
|
223
|
-
*
|
|
224
|
-
* This function also has the fine details of `getRegexForBracketPair`. For the same example
|
|
225
|
-
* given above, the regex produced here would look like:
|
|
226
|
-
* /(\bfi dne\b)|(\bdne\b)|(\bfi\b)/
|
|
227
|
-
*/
|
|
228
|
-
function getReversedRegexForBracketPair(open, close, brackets, currentIndex) {
|
|
229
|
-
// search in all brackets for other brackets that are a superstring of these brackets
|
|
230
|
-
let pieces = [];
|
|
231
|
-
pieces = pieces.concat(open);
|
|
232
|
-
pieces = pieces.concat(close);
|
|
233
|
-
for (let i = 0, len = pieces.length; i < len; i++) {
|
|
234
|
-
collectSuperstrings(pieces[i], brackets, currentIndex, pieces);
|
|
235
|
-
}
|
|
236
|
-
pieces = unique(pieces);
|
|
237
|
-
pieces.sort(lengthcmp);
|
|
238
|
-
pieces.reverse();
|
|
239
|
-
return createBracketOrRegExp(pieces.map(toReversedString));
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Creates a regular expression that targets all bracket pairs.
|
|
243
|
-
*
|
|
244
|
-
* e.g. for the bracket pairs:
|
|
245
|
-
* ['{','}']
|
|
246
|
-
* ['begin,'end']
|
|
247
|
-
* ['for','end']
|
|
248
|
-
* the regex would look like:
|
|
249
|
-
* /(\{)|(\})|(\bbegin\b)|(\bend\b)|(\bfor\b)/
|
|
250
|
-
*/
|
|
251
|
-
function getRegexForBrackets(brackets) {
|
|
252
|
-
let pieces = [];
|
|
253
|
-
for (const bracket of brackets) {
|
|
254
|
-
for (const open of bracket.open) {
|
|
255
|
-
pieces.push(open);
|
|
256
|
-
}
|
|
257
|
-
for (const close of bracket.close) {
|
|
258
|
-
pieces.push(close);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
pieces = unique(pieces);
|
|
262
|
-
return createBracketOrRegExp(pieces);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Matching a regular expression in JS can only be done "forwards". So JS offers natively only
|
|
266
|
-
* methods to find the first match of a regex in a string. But sometimes, it is useful to
|
|
267
|
-
* find the last match of a regex in a string. For such a situation, a nice solution is to
|
|
268
|
-
* simply reverse the string and then search for a reversed regex.
|
|
269
|
-
*
|
|
270
|
-
* e.g. for the bracket pairs:
|
|
271
|
-
* ['{','}']
|
|
272
|
-
* ['begin,'end']
|
|
273
|
-
* ['for','end']
|
|
274
|
-
* the regex would look like:
|
|
275
|
-
* /(\{)|(\})|(\bnigeb\b)|(\bdne\b)|(\brof\b)/
|
|
276
|
-
*/
|
|
277
|
-
function getReversedRegexForBrackets(brackets) {
|
|
278
|
-
let pieces = [];
|
|
279
|
-
for (const bracket of brackets) {
|
|
280
|
-
for (const open of bracket.open) {
|
|
281
|
-
pieces.push(open);
|
|
282
|
-
}
|
|
283
|
-
for (const close of bracket.close) {
|
|
284
|
-
pieces.push(close);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
pieces = unique(pieces);
|
|
288
|
-
return createBracketOrRegExp(pieces.map(toReversedString));
|
|
289
|
-
}
|
|
290
|
-
function prepareBracketForRegExp(str) {
|
|
291
|
-
// This bracket pair uses letters like e.g. "begin" - "end"
|
|
292
|
-
const insertWordBoundaries = (/^[\w ]+$/.test(str));
|
|
293
|
-
str = escapeRegExpCharacters(str);
|
|
294
|
-
return (insertWordBoundaries ? `\\b${str}\\b` : str);
|
|
295
|
-
}
|
|
296
|
-
function createBracketOrRegExp(pieces, options) {
|
|
297
|
-
const regexStr = `(${pieces.map(prepareBracketForRegExp).join(')|(')})`;
|
|
298
|
-
return createRegExp(regexStr, true, options);
|
|
299
|
-
}
|
|
300
|
-
const toReversedString = (function () {
|
|
301
|
-
function reverse(str) {
|
|
302
|
-
// create a Uint16Array and then use a TextDecoder to create a string
|
|
303
|
-
const arr = new Uint16Array(str.length);
|
|
304
|
-
let offset = 0;
|
|
305
|
-
for (let i = str.length - 1; i >= 0; i--) {
|
|
306
|
-
arr[offset++] = str.charCodeAt(i);
|
|
307
|
-
}
|
|
308
|
-
return getPlatformTextDecoder().decode(arr);
|
|
309
|
-
}
|
|
310
|
-
let lastInput = null;
|
|
311
|
-
let lastOutput = null;
|
|
312
|
-
return function toReversedString(str) {
|
|
313
|
-
if (lastInput !== str) {
|
|
314
|
-
lastInput = str;
|
|
315
|
-
lastOutput = reverse(lastInput);
|
|
316
|
-
}
|
|
317
|
-
return lastOutput;
|
|
318
|
-
};
|
|
319
|
-
})();
|
|
320
|
-
class BracketsUtils {
|
|
321
|
-
static _findPrevBracketInText(reversedBracketRegex, lineNumber, reversedText, offset) {
|
|
322
|
-
const m = reversedText.match(reversedBracketRegex);
|
|
323
|
-
if (!m) {
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
const matchOffset = reversedText.length - (m.index || 0);
|
|
327
|
-
const matchLength = m[0].length;
|
|
328
|
-
const absoluteMatchOffset = offset + matchOffset;
|
|
329
|
-
return new Range(lineNumber, absoluteMatchOffset - matchLength + 1, lineNumber, absoluteMatchOffset + 1);
|
|
330
|
-
}
|
|
331
|
-
static findPrevBracketInRange(reversedBracketRegex, lineNumber, lineText, startOffset, endOffset) {
|
|
332
|
-
// Because JS does not support backwards regex search, we search forwards in a reversed string with a reversed regex ;)
|
|
333
|
-
const reversedLineText = toReversedString(lineText);
|
|
334
|
-
const reversedSubstr = reversedLineText.substring(lineText.length - endOffset, lineText.length - startOffset);
|
|
335
|
-
return this._findPrevBracketInText(reversedBracketRegex, lineNumber, reversedSubstr, startOffset);
|
|
336
|
-
}
|
|
337
|
-
static findNextBracketInText(bracketRegex, lineNumber, text, offset) {
|
|
338
|
-
const m = text.match(bracketRegex);
|
|
339
|
-
if (!m) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
const matchOffset = m.index || 0;
|
|
343
|
-
const matchLength = m[0].length;
|
|
344
|
-
if (matchLength === 0) {
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
const absoluteMatchOffset = offset + matchOffset;
|
|
348
|
-
return new Range(lineNumber, absoluteMatchOffset + 1, lineNumber, absoluteMatchOffset + 1 + matchLength);
|
|
349
|
-
}
|
|
350
|
-
static findNextBracketInRange(bracketRegex, lineNumber, lineText, startOffset, endOffset) {
|
|
351
|
-
const substr = lineText.substring(startOffset, endOffset);
|
|
352
|
-
return this.findNextBracketInText(bracketRegex, lineNumber, substr, startOffset);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export { BracketsUtils, RichEditBracket, RichEditBrackets, createBracketOrRegExp };
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { Position } from './position.js';
|
|
2
|
-
import { Range } from './range.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
|
-
* A selection in the editor.
|
|
10
|
-
* The selection is a range that has an orientation.
|
|
11
|
-
*/
|
|
12
|
-
class Selection extends Range {
|
|
13
|
-
constructor(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) {
|
|
14
|
-
super(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn);
|
|
15
|
-
this.selectionStartLineNumber = selectionStartLineNumber;
|
|
16
|
-
this.selectionStartColumn = selectionStartColumn;
|
|
17
|
-
this.positionLineNumber = positionLineNumber;
|
|
18
|
-
this.positionColumn = positionColumn;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Transform to a human-readable representation.
|
|
22
|
-
*/
|
|
23
|
-
toString() {
|
|
24
|
-
return '[' + this.selectionStartLineNumber + ',' + this.selectionStartColumn + ' -> ' + this.positionLineNumber + ',' + this.positionColumn + ']';
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Test if equals other selection.
|
|
28
|
-
*/
|
|
29
|
-
equalsSelection(other) {
|
|
30
|
-
return (Selection.selectionsEqual(this, other));
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Test if the two selections are equal.
|
|
34
|
-
*/
|
|
35
|
-
static selectionsEqual(a, b) {
|
|
36
|
-
return (a.selectionStartLineNumber === b.selectionStartLineNumber &&
|
|
37
|
-
a.selectionStartColumn === b.selectionStartColumn &&
|
|
38
|
-
a.positionLineNumber === b.positionLineNumber &&
|
|
39
|
-
a.positionColumn === b.positionColumn);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get directions (LTR or RTL).
|
|
43
|
-
*/
|
|
44
|
-
getDirection() {
|
|
45
|
-
if (this.selectionStartLineNumber === this.startLineNumber && this.selectionStartColumn === this.startColumn) {
|
|
46
|
-
return 0 /* SelectionDirection.LTR */;
|
|
47
|
-
}
|
|
48
|
-
return 1 /* SelectionDirection.RTL */;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create a new selection with a different `positionLineNumber` and `positionColumn`.
|
|
52
|
-
*/
|
|
53
|
-
setEndPosition(endLineNumber, endColumn) {
|
|
54
|
-
if (this.getDirection() === 0 /* SelectionDirection.LTR */) {
|
|
55
|
-
return new Selection(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
|
|
56
|
-
}
|
|
57
|
-
return new Selection(endLineNumber, endColumn, this.startLineNumber, this.startColumn);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get the position at `positionLineNumber` and `positionColumn`.
|
|
61
|
-
*/
|
|
62
|
-
getPosition() {
|
|
63
|
-
return new Position(this.positionLineNumber, this.positionColumn);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get the position at the start of the selection.
|
|
67
|
-
*/
|
|
68
|
-
getSelectionStart() {
|
|
69
|
-
return new Position(this.selectionStartLineNumber, this.selectionStartColumn);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
|
|
73
|
-
*/
|
|
74
|
-
setStartPosition(startLineNumber, startColumn) {
|
|
75
|
-
if (this.getDirection() === 0 /* SelectionDirection.LTR */) {
|
|
76
|
-
return new Selection(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
|
|
77
|
-
}
|
|
78
|
-
return new Selection(this.endLineNumber, this.endColumn, startLineNumber, startColumn);
|
|
79
|
-
}
|
|
80
|
-
// ----
|
|
81
|
-
/**
|
|
82
|
-
* Create a `Selection` from one or two positions
|
|
83
|
-
*/
|
|
84
|
-
static fromPositions(start, end = start) {
|
|
85
|
-
return new Selection(start.lineNumber, start.column, end.lineNumber, end.column);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates a `Selection` from a range, given a direction.
|
|
89
|
-
*/
|
|
90
|
-
static fromRange(range, direction) {
|
|
91
|
-
if (direction === 0 /* SelectionDirection.LTR */) {
|
|
92
|
-
return new Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
return new Selection(range.endLineNumber, range.endColumn, range.startLineNumber, range.startColumn);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Create a `Selection` from an `ISelection`.
|
|
100
|
-
*/
|
|
101
|
-
static liftSelection(sel) {
|
|
102
|
-
return new Selection(sel.selectionStartLineNumber, sel.selectionStartColumn, sel.positionLineNumber, sel.positionColumn);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* `a` equals `b`.
|
|
106
|
-
*/
|
|
107
|
-
static selectionsArrEqual(a, b) {
|
|
108
|
-
if (a && !b || !a && b) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (!a && !b) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
if (a.length !== b.length) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
for (let i = 0, len = a.length; i < len; i++) {
|
|
118
|
-
if (!this.selectionsEqual(a[i], b[i])) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Test if `obj` is an `ISelection`.
|
|
126
|
-
*/
|
|
127
|
-
static isISelection(obj) {
|
|
128
|
-
return (!!obj
|
|
129
|
-
&& (typeof obj.selectionStartLineNumber === 'number')
|
|
130
|
-
&& (typeof obj.selectionStartColumn === 'number')
|
|
131
|
-
&& (typeof obj.positionLineNumber === 'number')
|
|
132
|
-
&& (typeof obj.positionColumn === 'number'));
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Create with a direction.
|
|
136
|
-
*/
|
|
137
|
-
static createWithDirection(startLineNumber, startColumn, endLineNumber, endColumn, direction) {
|
|
138
|
-
if (direction === 0 /* SelectionDirection.LTR */) {
|
|
139
|
-
return new Selection(startLineNumber, startColumn, endLineNumber, endColumn);
|
|
140
|
-
}
|
|
141
|
-
return new Selection(endLineNumber, endColumn, startLineNumber, startColumn);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export { Selection };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { VSBuffer } from '../../../base/common/buffer.js';
|
|
2
|
-
import { isLittleEndian } from '../../../base/common/platform.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
|
-
function reverseEndianness(arr) {
|
|
9
|
-
for (let i = 0, len = arr.length; i < len; i += 4) {
|
|
10
|
-
// flip bytes 0<->3 and 1<->2
|
|
11
|
-
const b0 = arr[i + 0];
|
|
12
|
-
const b1 = arr[i + 1];
|
|
13
|
-
const b2 = arr[i + 2];
|
|
14
|
-
const b3 = arr[i + 3];
|
|
15
|
-
arr[i + 0] = b3;
|
|
16
|
-
arr[i + 1] = b2;
|
|
17
|
-
arr[i + 2] = b1;
|
|
18
|
-
arr[i + 3] = b0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function toLittleEndianBuffer(arr) {
|
|
22
|
-
const uint8Arr = new Uint8Array(arr.buffer, arr.byteOffset, arr.length * 4);
|
|
23
|
-
if (!isLittleEndian()) {
|
|
24
|
-
// the byte order must be changed
|
|
25
|
-
reverseEndianness(uint8Arr);
|
|
26
|
-
}
|
|
27
|
-
return VSBuffer.wrap(uint8Arr);
|
|
28
|
-
}
|
|
29
|
-
function encodeSemanticTokensDto(semanticTokens) {
|
|
30
|
-
const dest = new Uint32Array(encodeSemanticTokensDtoSize(semanticTokens));
|
|
31
|
-
let offset = 0;
|
|
32
|
-
dest[offset++] = semanticTokens.id;
|
|
33
|
-
if (semanticTokens.type === 'full') {
|
|
34
|
-
dest[offset++] = 1 /* EncodedSemanticTokensType.Full */;
|
|
35
|
-
dest[offset++] = semanticTokens.data.length;
|
|
36
|
-
dest.set(semanticTokens.data, offset);
|
|
37
|
-
offset += semanticTokens.data.length;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
dest[offset++] = 2 /* EncodedSemanticTokensType.Delta */;
|
|
41
|
-
dest[offset++] = semanticTokens.deltas.length;
|
|
42
|
-
for (const delta of semanticTokens.deltas) {
|
|
43
|
-
dest[offset++] = delta.start;
|
|
44
|
-
dest[offset++] = delta.deleteCount;
|
|
45
|
-
if (delta.data) {
|
|
46
|
-
dest[offset++] = delta.data.length;
|
|
47
|
-
dest.set(delta.data, offset);
|
|
48
|
-
offset += delta.data.length;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
dest[offset++] = 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return toLittleEndianBuffer(dest);
|
|
56
|
-
}
|
|
57
|
-
function encodeSemanticTokensDtoSize(semanticTokens) {
|
|
58
|
-
let result = 0;
|
|
59
|
-
result += (1 // id
|
|
60
|
-
+ 1 // type
|
|
61
|
-
);
|
|
62
|
-
if (semanticTokens.type === 'full') {
|
|
63
|
-
result += (1 // data length
|
|
64
|
-
+ semanticTokens.data.length);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
result += (1 // delta count
|
|
68
|
-
);
|
|
69
|
-
result += (1 // start
|
|
70
|
-
+ 1 // deleteCount
|
|
71
|
-
+ 1 // data length
|
|
72
|
-
) * semanticTokens.deltas.length;
|
|
73
|
-
for (const delta of semanticTokens.deltas) {
|
|
74
|
-
if (delta.data) {
|
|
75
|
-
result += delta.data.length;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { encodeSemanticTokensDto };
|