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,436 +0,0 @@
|
|
|
1
|
-
import { runWhenGlobalIdle } from '../../../base/common/async.js';
|
|
2
|
-
import { BugIndicatingError, onUnexpectedError } from '../../../base/common/errors.js';
|
|
3
|
-
import { setTimeout0 } from '../../../base/common/platform.js';
|
|
4
|
-
import { StopWatch } from '../../../base/common/stopwatch.js';
|
|
5
|
-
import { countEOL } from '../core/misc/eolCounter.js';
|
|
6
|
-
import { LineRange } from '../core/ranges/lineRange.js';
|
|
7
|
-
import { OffsetRange } from '../core/ranges/offsetRange.js';
|
|
8
|
-
import { nullTokenizeEncoded } from '../languages/nullTokenize.js';
|
|
9
|
-
import { FixedArray } from './fixedArray.js';
|
|
10
|
-
import { ContiguousMultilineTokensBuilder } from '../tokens/contiguousMultilineTokensBuilder.js';
|
|
11
|
-
import { LineTokens } from '../tokens/lineTokens.js';
|
|
12
|
-
|
|
13
|
-
/*---------------------------------------------------------------------------------------------
|
|
14
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
16
|
-
*--------------------------------------------------------------------------------------------*/
|
|
17
|
-
class TokenizerWithStateStore {
|
|
18
|
-
constructor(lineCount, tokenizationSupport) {
|
|
19
|
-
this.tokenizationSupport = tokenizationSupport;
|
|
20
|
-
this.initialState = this.tokenizationSupport.getInitialState();
|
|
21
|
-
this.store = new TrackingTokenizationStateStore(lineCount);
|
|
22
|
-
}
|
|
23
|
-
getStartState(lineNumber) {
|
|
24
|
-
return this.store.getStartState(lineNumber, this.initialState);
|
|
25
|
-
}
|
|
26
|
-
getFirstInvalidLine() {
|
|
27
|
-
return this.store.getFirstInvalidLine(this.initialState);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class TokenizerWithStateStoreAndTextModel extends TokenizerWithStateStore {
|
|
31
|
-
constructor(lineCount, tokenizationSupport, _textModel, _languageIdCodec) {
|
|
32
|
-
super(lineCount, tokenizationSupport);
|
|
33
|
-
this._textModel = _textModel;
|
|
34
|
-
this._languageIdCodec = _languageIdCodec;
|
|
35
|
-
}
|
|
36
|
-
updateTokensUntilLine(builder, lineNumber) {
|
|
37
|
-
const languageId = this._textModel.getLanguageId();
|
|
38
|
-
while (true) {
|
|
39
|
-
const lineToTokenize = this.getFirstInvalidLine();
|
|
40
|
-
if (!lineToTokenize || lineToTokenize.lineNumber > lineNumber) {
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
const text = this._textModel.getLineContent(lineToTokenize.lineNumber);
|
|
44
|
-
const r = safeTokenize(this._languageIdCodec, languageId, this.tokenizationSupport, text, true, lineToTokenize.startState);
|
|
45
|
-
builder.add(lineToTokenize.lineNumber, r.tokens);
|
|
46
|
-
this.store.setEndState(lineToTokenize.lineNumber, r.endState);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/** assumes state is up to date */
|
|
50
|
-
getTokenTypeIfInsertingCharacter(position, character) {
|
|
51
|
-
// TODO@hediet: use tokenizeLineWithEdit
|
|
52
|
-
const lineStartState = this.getStartState(position.lineNumber);
|
|
53
|
-
if (!lineStartState) {
|
|
54
|
-
return 0 /* StandardTokenType.Other */;
|
|
55
|
-
}
|
|
56
|
-
const languageId = this._textModel.getLanguageId();
|
|
57
|
-
const lineContent = this._textModel.getLineContent(position.lineNumber);
|
|
58
|
-
// Create the text as if `character` was inserted
|
|
59
|
-
const text = (lineContent.substring(0, position.column - 1)
|
|
60
|
-
+ character
|
|
61
|
-
+ lineContent.substring(position.column - 1));
|
|
62
|
-
const r = safeTokenize(this._languageIdCodec, languageId, this.tokenizationSupport, text, true, lineStartState);
|
|
63
|
-
const lineTokens = new LineTokens(r.tokens, text, this._languageIdCodec);
|
|
64
|
-
if (lineTokens.getCount() === 0) {
|
|
65
|
-
return 0 /* StandardTokenType.Other */;
|
|
66
|
-
}
|
|
67
|
-
const tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
|
|
68
|
-
return lineTokens.getStandardTokenType(tokenIndex);
|
|
69
|
-
}
|
|
70
|
-
/** assumes state is up to date */
|
|
71
|
-
tokenizeLinesAt(lineNumber, lines) {
|
|
72
|
-
const lineStartState = this.getStartState(lineNumber);
|
|
73
|
-
if (!lineStartState) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
const languageId = this._textModel.getLanguageId();
|
|
77
|
-
const result = [];
|
|
78
|
-
let state = lineStartState;
|
|
79
|
-
for (const line of lines) {
|
|
80
|
-
const r = safeTokenize(this._languageIdCodec, languageId, this.tokenizationSupport, line, true, state);
|
|
81
|
-
result.push(new LineTokens(r.tokens, line, this._languageIdCodec));
|
|
82
|
-
state = r.endState;
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
hasAccurateTokensForLine(lineNumber) {
|
|
87
|
-
const firstInvalidLineNumber = this.store.getFirstInvalidEndStateLineNumberOrMax();
|
|
88
|
-
return (lineNumber < firstInvalidLineNumber);
|
|
89
|
-
}
|
|
90
|
-
isCheapToTokenize(lineNumber) {
|
|
91
|
-
const firstInvalidLineNumber = this.store.getFirstInvalidEndStateLineNumberOrMax();
|
|
92
|
-
if (lineNumber < firstInvalidLineNumber) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
if (lineNumber === firstInvalidLineNumber
|
|
96
|
-
&& this._textModel.getLineLength(lineNumber) < 2048 /* Constants.CHEAP_TOKENIZATION_LENGTH_LIMIT */) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* The result is not cached.
|
|
103
|
-
*/
|
|
104
|
-
tokenizeHeuristically(builder, startLineNumber, endLineNumber) {
|
|
105
|
-
if (endLineNumber <= this.store.getFirstInvalidEndStateLineNumberOrMax()) {
|
|
106
|
-
// nothing to do
|
|
107
|
-
return { heuristicTokens: false };
|
|
108
|
-
}
|
|
109
|
-
if (startLineNumber <= this.store.getFirstInvalidEndStateLineNumberOrMax()) {
|
|
110
|
-
// tokenization has reached the viewport start...
|
|
111
|
-
this.updateTokensUntilLine(builder, endLineNumber);
|
|
112
|
-
return { heuristicTokens: false };
|
|
113
|
-
}
|
|
114
|
-
let state = this.guessStartState(startLineNumber);
|
|
115
|
-
const languageId = this._textModel.getLanguageId();
|
|
116
|
-
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
|
|
117
|
-
const text = this._textModel.getLineContent(lineNumber);
|
|
118
|
-
const r = safeTokenize(this._languageIdCodec, languageId, this.tokenizationSupport, text, true, state);
|
|
119
|
-
builder.add(lineNumber, r.tokens);
|
|
120
|
-
state = r.endState;
|
|
121
|
-
}
|
|
122
|
-
return { heuristicTokens: true };
|
|
123
|
-
}
|
|
124
|
-
guessStartState(lineNumber) {
|
|
125
|
-
let { likelyRelevantLines, initialState } = findLikelyRelevantLines(this._textModel, lineNumber, this);
|
|
126
|
-
if (!initialState) {
|
|
127
|
-
initialState = this.tokenizationSupport.getInitialState();
|
|
128
|
-
}
|
|
129
|
-
const languageId = this._textModel.getLanguageId();
|
|
130
|
-
let state = initialState;
|
|
131
|
-
for (const line of likelyRelevantLines) {
|
|
132
|
-
const r = safeTokenize(this._languageIdCodec, languageId, this.tokenizationSupport, line, false, state);
|
|
133
|
-
state = r.endState;
|
|
134
|
-
}
|
|
135
|
-
return state;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function findLikelyRelevantLines(model, lineNumber, store) {
|
|
139
|
-
let nonWhitespaceColumn = model.getLineFirstNonWhitespaceColumn(lineNumber);
|
|
140
|
-
const likelyRelevantLines = [];
|
|
141
|
-
let initialState = null;
|
|
142
|
-
for (let i = lineNumber - 1; nonWhitespaceColumn > 1 && i >= 1; i--) {
|
|
143
|
-
const newNonWhitespaceIndex = model.getLineFirstNonWhitespaceColumn(i);
|
|
144
|
-
// Ignore lines full of whitespace
|
|
145
|
-
if (newNonWhitespaceIndex === 0) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (newNonWhitespaceIndex < nonWhitespaceColumn) {
|
|
149
|
-
likelyRelevantLines.push(model.getLineContent(i));
|
|
150
|
-
nonWhitespaceColumn = newNonWhitespaceIndex;
|
|
151
|
-
initialState = store?.getStartState(i);
|
|
152
|
-
if (initialState) {
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
likelyRelevantLines.reverse();
|
|
158
|
-
return { likelyRelevantLines, initialState: initialState ?? undefined };
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* **Invariant:**
|
|
162
|
-
* If the text model is retokenized from line 1 to {@link getFirstInvalidEndStateLineNumber}() - 1,
|
|
163
|
-
* then the recomputed end state for line l will be equal to {@link getEndState}(l).
|
|
164
|
-
*/
|
|
165
|
-
class TrackingTokenizationStateStore {
|
|
166
|
-
constructor(lineCount) {
|
|
167
|
-
this.lineCount = lineCount;
|
|
168
|
-
this._tokenizationStateStore = new TokenizationStateStore();
|
|
169
|
-
this._invalidEndStatesLineNumbers = new RangePriorityQueueImpl();
|
|
170
|
-
this._invalidEndStatesLineNumbers.addRange(new OffsetRange(1, lineCount + 1));
|
|
171
|
-
}
|
|
172
|
-
getEndState(lineNumber) {
|
|
173
|
-
return this._tokenizationStateStore.getEndState(lineNumber);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @returns if the end state has changed.
|
|
177
|
-
*/
|
|
178
|
-
setEndState(lineNumber, state) {
|
|
179
|
-
if (!state) {
|
|
180
|
-
throw new BugIndicatingError('Cannot set null/undefined state');
|
|
181
|
-
}
|
|
182
|
-
this._invalidEndStatesLineNumbers.delete(lineNumber);
|
|
183
|
-
const r = this._tokenizationStateStore.setEndState(lineNumber, state);
|
|
184
|
-
if (r && lineNumber < this.lineCount) {
|
|
185
|
-
// because the state changed, we cannot trust the next state anymore and have to invalidate it.
|
|
186
|
-
this._invalidEndStatesLineNumbers.addRange(new OffsetRange(lineNumber + 1, lineNumber + 2));
|
|
187
|
-
}
|
|
188
|
-
return r;
|
|
189
|
-
}
|
|
190
|
-
acceptChange(range, newLineCount) {
|
|
191
|
-
this.lineCount += newLineCount - range.length;
|
|
192
|
-
this._tokenizationStateStore.acceptChange(range, newLineCount);
|
|
193
|
-
this._invalidEndStatesLineNumbers.addRangeAndResize(new OffsetRange(range.startLineNumber, range.endLineNumberExclusive), newLineCount);
|
|
194
|
-
}
|
|
195
|
-
acceptChanges(changes) {
|
|
196
|
-
for (const c of changes) {
|
|
197
|
-
const [eolCount] = countEOL(c.text);
|
|
198
|
-
this.acceptChange(new LineRange(c.range.startLineNumber, c.range.endLineNumber + 1), eolCount + 1);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
invalidateEndStateRange(range) {
|
|
202
|
-
this._invalidEndStatesLineNumbers.addRange(new OffsetRange(range.startLineNumber, range.endLineNumberExclusive));
|
|
203
|
-
}
|
|
204
|
-
getFirstInvalidEndStateLineNumber() { return this._invalidEndStatesLineNumbers.min; }
|
|
205
|
-
getFirstInvalidEndStateLineNumberOrMax() {
|
|
206
|
-
return this.getFirstInvalidEndStateLineNumber() || Number.MAX_SAFE_INTEGER;
|
|
207
|
-
}
|
|
208
|
-
allStatesValid() { return this._invalidEndStatesLineNumbers.min === null; }
|
|
209
|
-
getStartState(lineNumber, initialState) {
|
|
210
|
-
if (lineNumber === 1) {
|
|
211
|
-
return initialState;
|
|
212
|
-
}
|
|
213
|
-
return this.getEndState(lineNumber - 1);
|
|
214
|
-
}
|
|
215
|
-
getFirstInvalidLine(initialState) {
|
|
216
|
-
const lineNumber = this.getFirstInvalidEndStateLineNumber();
|
|
217
|
-
if (lineNumber === null) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
const startState = this.getStartState(lineNumber, initialState);
|
|
221
|
-
if (!startState) {
|
|
222
|
-
throw new BugIndicatingError('Start state must be defined');
|
|
223
|
-
}
|
|
224
|
-
return { lineNumber, startState };
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
class TokenizationStateStore {
|
|
228
|
-
constructor() {
|
|
229
|
-
this._lineEndStates = new FixedArray(null);
|
|
230
|
-
}
|
|
231
|
-
getEndState(lineNumber) {
|
|
232
|
-
return this._lineEndStates.get(lineNumber);
|
|
233
|
-
}
|
|
234
|
-
setEndState(lineNumber, state) {
|
|
235
|
-
const oldState = this._lineEndStates.get(lineNumber);
|
|
236
|
-
if (oldState && oldState.equals(state)) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
this._lineEndStates.set(lineNumber, state);
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
acceptChange(range, newLineCount) {
|
|
243
|
-
let length = range.length;
|
|
244
|
-
if (newLineCount > 0 && length > 0) {
|
|
245
|
-
// Keep the last state, even though it is unrelated.
|
|
246
|
-
// But if the new state happens to agree with this last state, then we know we can stop tokenizing.
|
|
247
|
-
length--;
|
|
248
|
-
newLineCount--;
|
|
249
|
-
}
|
|
250
|
-
this._lineEndStates.replace(range.startLineNumber, length, newLineCount);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
class RangePriorityQueueImpl {
|
|
254
|
-
constructor() {
|
|
255
|
-
this._ranges = [];
|
|
256
|
-
}
|
|
257
|
-
get min() {
|
|
258
|
-
if (this._ranges.length === 0) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
return this._ranges[0].start;
|
|
262
|
-
}
|
|
263
|
-
delete(value) {
|
|
264
|
-
const idx = this._ranges.findIndex(r => r.contains(value));
|
|
265
|
-
if (idx !== -1) {
|
|
266
|
-
const range = this._ranges[idx];
|
|
267
|
-
if (range.start === value) {
|
|
268
|
-
if (range.endExclusive === value + 1) {
|
|
269
|
-
this._ranges.splice(idx, 1);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
this._ranges[idx] = new OffsetRange(value + 1, range.endExclusive);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
if (range.endExclusive === value + 1) {
|
|
277
|
-
this._ranges[idx] = new OffsetRange(range.start, value);
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
this._ranges.splice(idx, 1, new OffsetRange(range.start, value), new OffsetRange(value + 1, range.endExclusive));
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
addRange(range) {
|
|
286
|
-
OffsetRange.addRange(range, this._ranges);
|
|
287
|
-
}
|
|
288
|
-
addRangeAndResize(range, newLength) {
|
|
289
|
-
let idxFirstMightBeIntersecting = 0;
|
|
290
|
-
while (!(idxFirstMightBeIntersecting >= this._ranges.length || range.start <= this._ranges[idxFirstMightBeIntersecting].endExclusive)) {
|
|
291
|
-
idxFirstMightBeIntersecting++;
|
|
292
|
-
}
|
|
293
|
-
let idxFirstIsAfter = idxFirstMightBeIntersecting;
|
|
294
|
-
while (!(idxFirstIsAfter >= this._ranges.length || range.endExclusive < this._ranges[idxFirstIsAfter].start)) {
|
|
295
|
-
idxFirstIsAfter++;
|
|
296
|
-
}
|
|
297
|
-
const delta = newLength - range.length;
|
|
298
|
-
for (let i = idxFirstIsAfter; i < this._ranges.length; i++) {
|
|
299
|
-
this._ranges[i] = this._ranges[i].delta(delta);
|
|
300
|
-
}
|
|
301
|
-
if (idxFirstMightBeIntersecting === idxFirstIsAfter) {
|
|
302
|
-
const newRange = new OffsetRange(range.start, range.start + newLength);
|
|
303
|
-
if (!newRange.isEmpty) {
|
|
304
|
-
this._ranges.splice(idxFirstMightBeIntersecting, 0, newRange);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
const start = Math.min(range.start, this._ranges[idxFirstMightBeIntersecting].start);
|
|
309
|
-
const endEx = Math.max(range.endExclusive, this._ranges[idxFirstIsAfter - 1].endExclusive);
|
|
310
|
-
const newRange = new OffsetRange(start, endEx + delta);
|
|
311
|
-
if (!newRange.isEmpty) {
|
|
312
|
-
this._ranges.splice(idxFirstMightBeIntersecting, idxFirstIsAfter - idxFirstMightBeIntersecting, newRange);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
this._ranges.splice(idxFirstMightBeIntersecting, idxFirstIsAfter - idxFirstMightBeIntersecting);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
toString() {
|
|
320
|
-
return this._ranges.map(r => r.toString()).join(' + ');
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function safeTokenize(languageIdCodec, languageId, tokenizationSupport, text, hasEOL, state) {
|
|
324
|
-
let r = null;
|
|
325
|
-
if (tokenizationSupport) {
|
|
326
|
-
try {
|
|
327
|
-
r = tokenizationSupport.tokenizeEncoded(text, hasEOL, state.clone());
|
|
328
|
-
}
|
|
329
|
-
catch (e) {
|
|
330
|
-
onUnexpectedError(e);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
if (!r) {
|
|
334
|
-
r = nullTokenizeEncoded(languageIdCodec.encodeLanguageId(languageId), state);
|
|
335
|
-
}
|
|
336
|
-
LineTokens.convertToEndOffset(r.tokens, text.length);
|
|
337
|
-
return r;
|
|
338
|
-
}
|
|
339
|
-
class DefaultBackgroundTokenizer {
|
|
340
|
-
constructor(_tokenizerWithStateStore, _backgroundTokenStore) {
|
|
341
|
-
this._tokenizerWithStateStore = _tokenizerWithStateStore;
|
|
342
|
-
this._backgroundTokenStore = _backgroundTokenStore;
|
|
343
|
-
this._isDisposed = false;
|
|
344
|
-
this._isScheduled = false;
|
|
345
|
-
}
|
|
346
|
-
dispose() {
|
|
347
|
-
this._isDisposed = true;
|
|
348
|
-
}
|
|
349
|
-
handleChanges() {
|
|
350
|
-
this._beginBackgroundTokenization();
|
|
351
|
-
}
|
|
352
|
-
_beginBackgroundTokenization() {
|
|
353
|
-
if (this._isScheduled || !this._tokenizerWithStateStore._textModel.isAttachedToEditor() || !this._hasLinesToTokenize()) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
this._isScheduled = true;
|
|
357
|
-
runWhenGlobalIdle((deadline) => {
|
|
358
|
-
this._isScheduled = false;
|
|
359
|
-
this._backgroundTokenizeWithDeadline(deadline);
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Tokenize until the deadline occurs, but try to yield every 1-2ms.
|
|
364
|
-
*/
|
|
365
|
-
_backgroundTokenizeWithDeadline(deadline) {
|
|
366
|
-
// Read the time remaining from the `deadline` immediately because it is unclear
|
|
367
|
-
// if the `deadline` object will be valid after execution leaves this function.
|
|
368
|
-
const endTime = Date.now() + deadline.timeRemaining();
|
|
369
|
-
const execute = () => {
|
|
370
|
-
if (this._isDisposed || !this._tokenizerWithStateStore._textModel.isAttachedToEditor() || !this._hasLinesToTokenize()) {
|
|
371
|
-
// disposed in the meantime or detached or finished
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
this._backgroundTokenizeForAtLeast1ms();
|
|
375
|
-
if (Date.now() < endTime) {
|
|
376
|
-
// There is still time before reaching the deadline, so yield to the browser and then
|
|
377
|
-
// continue execution
|
|
378
|
-
setTimeout0(execute);
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
// The deadline has been reached, so schedule a new idle callback if necessary
|
|
382
|
-
this._beginBackgroundTokenization();
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
execute();
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Tokenize for at least 1ms.
|
|
389
|
-
*/
|
|
390
|
-
_backgroundTokenizeForAtLeast1ms() {
|
|
391
|
-
const lineCount = this._tokenizerWithStateStore._textModel.getLineCount();
|
|
392
|
-
const builder = new ContiguousMultilineTokensBuilder();
|
|
393
|
-
const sw = StopWatch.create(false);
|
|
394
|
-
do {
|
|
395
|
-
if (sw.elapsed() > 1) {
|
|
396
|
-
// the comparison is intentionally > 1 and not >= 1 to ensure that
|
|
397
|
-
// a full millisecond has elapsed, given how microseconds are rounded
|
|
398
|
-
// to milliseconds
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
const tokenizedLineNumber = this._tokenizeOneInvalidLine(builder);
|
|
402
|
-
if (tokenizedLineNumber >= lineCount) {
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
} while (this._hasLinesToTokenize());
|
|
406
|
-
this._backgroundTokenStore.setTokens(builder.finalize());
|
|
407
|
-
this.checkFinished();
|
|
408
|
-
}
|
|
409
|
-
_hasLinesToTokenize() {
|
|
410
|
-
if (!this._tokenizerWithStateStore) {
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
return !this._tokenizerWithStateStore.store.allStatesValid();
|
|
414
|
-
}
|
|
415
|
-
_tokenizeOneInvalidLine(builder) {
|
|
416
|
-
const firstInvalidLine = this._tokenizerWithStateStore?.getFirstInvalidLine();
|
|
417
|
-
if (!firstInvalidLine) {
|
|
418
|
-
return this._tokenizerWithStateStore._textModel.getLineCount() + 1;
|
|
419
|
-
}
|
|
420
|
-
this._tokenizerWithStateStore.updateTokensUntilLine(builder, firstInvalidLine.lineNumber);
|
|
421
|
-
return firstInvalidLine.lineNumber;
|
|
422
|
-
}
|
|
423
|
-
checkFinished() {
|
|
424
|
-
if (this._isDisposed) {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
if (this._tokenizerWithStateStore.store.allStatesValid()) {
|
|
428
|
-
this._backgroundTokenStore.backgroundTokenizationFinished();
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
requestTokens(startLineNumber, endLineNumberExclusive) {
|
|
432
|
-
this._tokenizerWithStateStore.store.invalidateEndStateRange(new LineRange(startLineNumber, endLineNumberExclusive));
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export { DefaultBackgroundTokenizer, RangePriorityQueueImpl, TokenizationStateStore, TokenizerWithStateStore, TokenizerWithStateStoreAndTextModel, TrackingTokenizationStateStore, findLikelyRelevantLines };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';
|
|
2
|
-
|
|
3
|
-
const ITextResourceConfigurationService = createDecorator('textResourceConfigurationService');
|
|
4
|
-
const ITextResourcePropertiesService = createDecorator('textResourcePropertiesService');
|
|
5
|
-
|
|
6
|
-
export { ITextResourceConfigurationService, ITextResourcePropertiesService };
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { splitLines, escape, isFullWidthCharacter } from '../../../base/common/strings.js';
|
|
2
|
-
import { LineTokens } from '../tokens/lineTokens.js';
|
|
3
|
-
import { TokenizationRegistry } from '../languages.js';
|
|
4
|
-
import { nullTokenizeEncoded, NullState } from './nullTokenize.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
|
-
const fallback = {
|
|
11
|
-
getInitialState: () => NullState,
|
|
12
|
-
tokenizeEncoded: (buffer, hasEOL, state) => nullTokenizeEncoded(0 /* LanguageId.Null */, state)
|
|
13
|
-
};
|
|
14
|
-
async function tokenizeToString(languageService, text, languageId) {
|
|
15
|
-
if (!languageId) {
|
|
16
|
-
return _tokenizeToString(text, languageService.languageIdCodec, fallback);
|
|
17
|
-
}
|
|
18
|
-
const tokenizationSupport = await TokenizationRegistry.getOrCreate(languageId);
|
|
19
|
-
return _tokenizeToString(text, languageService.languageIdCodec, tokenizationSupport || fallback);
|
|
20
|
-
}
|
|
21
|
-
function tokenizeLineToHTML(text, viewLineTokens, colorMap, startOffset, endOffset, tabSize, useNbsp) {
|
|
22
|
-
let result = `<div>`;
|
|
23
|
-
let charIndex = 0;
|
|
24
|
-
let width = 0;
|
|
25
|
-
let prevIsSpace = true;
|
|
26
|
-
for (let tokenIndex = 0, tokenCount = viewLineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
|
|
27
|
-
const tokenEndIndex = viewLineTokens.getEndOffset(tokenIndex);
|
|
28
|
-
let partContent = '';
|
|
29
|
-
for (; charIndex < tokenEndIndex && charIndex < endOffset; charIndex++) {
|
|
30
|
-
const charCode = text.charCodeAt(charIndex);
|
|
31
|
-
const isTab = charCode === 9 /* CharCode.Tab */;
|
|
32
|
-
width += isFullWidthCharacter(charCode) ? 2 : (isTab ? 0 : 1);
|
|
33
|
-
if (charIndex < startOffset) {
|
|
34
|
-
if (isTab) {
|
|
35
|
-
const remainder = width % tabSize;
|
|
36
|
-
width += remainder === 0 ? tabSize : tabSize - remainder;
|
|
37
|
-
}
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
switch (charCode) {
|
|
41
|
-
case 9 /* CharCode.Tab */: {
|
|
42
|
-
const remainder = width % tabSize;
|
|
43
|
-
const insertSpacesCount = remainder === 0 ? tabSize : tabSize - remainder;
|
|
44
|
-
width += insertSpacesCount;
|
|
45
|
-
let spacesRemaining = insertSpacesCount;
|
|
46
|
-
while (spacesRemaining > 0) {
|
|
47
|
-
if (useNbsp && prevIsSpace) {
|
|
48
|
-
partContent += ' ';
|
|
49
|
-
prevIsSpace = false;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
partContent += ' ';
|
|
53
|
-
prevIsSpace = true;
|
|
54
|
-
}
|
|
55
|
-
spacesRemaining--;
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case 60 /* CharCode.LessThan */:
|
|
60
|
-
partContent += '<';
|
|
61
|
-
prevIsSpace = false;
|
|
62
|
-
break;
|
|
63
|
-
case 62 /* CharCode.GreaterThan */:
|
|
64
|
-
partContent += '>';
|
|
65
|
-
prevIsSpace = false;
|
|
66
|
-
break;
|
|
67
|
-
case 38 /* CharCode.Ampersand */:
|
|
68
|
-
partContent += '&';
|
|
69
|
-
prevIsSpace = false;
|
|
70
|
-
break;
|
|
71
|
-
case 0 /* CharCode.Null */:
|
|
72
|
-
partContent += '�';
|
|
73
|
-
prevIsSpace = false;
|
|
74
|
-
break;
|
|
75
|
-
case 65279 /* CharCode.UTF8_BOM */:
|
|
76
|
-
case 8232 /* CharCode.LINE_SEPARATOR */:
|
|
77
|
-
case 8233 /* CharCode.PARAGRAPH_SEPARATOR */:
|
|
78
|
-
case 133 /* CharCode.NEXT_LINE */:
|
|
79
|
-
partContent += '\ufffd';
|
|
80
|
-
prevIsSpace = false;
|
|
81
|
-
break;
|
|
82
|
-
case 13 /* CharCode.CarriageReturn */:
|
|
83
|
-
// zero width space, because carriage return would introduce a line break
|
|
84
|
-
partContent += '​';
|
|
85
|
-
prevIsSpace = false;
|
|
86
|
-
break;
|
|
87
|
-
case 32 /* CharCode.Space */:
|
|
88
|
-
if (useNbsp && prevIsSpace) {
|
|
89
|
-
partContent += ' ';
|
|
90
|
-
prevIsSpace = false;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
partContent += ' ';
|
|
94
|
-
prevIsSpace = true;
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
default:
|
|
98
|
-
partContent += String.fromCharCode(charCode);
|
|
99
|
-
prevIsSpace = false;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (tokenEndIndex <= startOffset) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
result += `<span style="${viewLineTokens.getInlineStyle(tokenIndex, colorMap)}">${partContent}</span>`;
|
|
106
|
-
if (tokenEndIndex > endOffset || charIndex >= endOffset || startOffset >= endOffset) {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
result += `</div>`;
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
function _tokenizeToString(text, languageIdCodec, tokenizationSupport) {
|
|
114
|
-
let result = `<div class="monaco-tokenized-source">`;
|
|
115
|
-
const lines = splitLines(text);
|
|
116
|
-
let currentState = tokenizationSupport.getInitialState();
|
|
117
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
118
|
-
const line = lines[i];
|
|
119
|
-
if (i > 0) {
|
|
120
|
-
result += `<br/>`;
|
|
121
|
-
}
|
|
122
|
-
const tokenizationResult = tokenizationSupport.tokenizeEncoded(line, true, currentState);
|
|
123
|
-
LineTokens.convertToEndOffset(tokenizationResult.tokens, line.length);
|
|
124
|
-
const lineTokens = new LineTokens(tokenizationResult.tokens, line, languageIdCodec);
|
|
125
|
-
const viewLineTokens = lineTokens.inflate();
|
|
126
|
-
let startOffset = 0;
|
|
127
|
-
for (let j = 0, lenJ = viewLineTokens.getCount(); j < lenJ; j++) {
|
|
128
|
-
const type = viewLineTokens.getClassName(j);
|
|
129
|
-
const endIndex = viewLineTokens.getEndOffset(j);
|
|
130
|
-
result += `<span class="${type}">${escape(line.substring(startOffset, endIndex))}</span>`;
|
|
131
|
-
startOffset = endIndex;
|
|
132
|
-
}
|
|
133
|
-
currentState = tokenizationResult.endState;
|
|
134
|
-
}
|
|
135
|
-
result += `</div>`;
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export { _tokenizeToString, tokenizeLineToHTML, tokenizeToString };
|