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,87 +0,0 @@
|
|
|
1
|
-
import { safeIntl } from '../../../base/common/date.js';
|
|
2
|
-
import { LRUCache } from '../../../base/common/map.js';
|
|
3
|
-
import { CharacterClassifier } from './characterClassifier.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
|
-
class WordCharacterClassifier extends CharacterClassifier {
|
|
10
|
-
constructor(wordSeparators, intlSegmenterLocales) {
|
|
11
|
-
super(0 /* WordCharacterClass.Regular */);
|
|
12
|
-
this._segmenter = null;
|
|
13
|
-
this._cachedLine = null;
|
|
14
|
-
this._cachedSegments = [];
|
|
15
|
-
this.intlSegmenterLocales = intlSegmenterLocales;
|
|
16
|
-
if (this.intlSegmenterLocales.length > 0) {
|
|
17
|
-
this._segmenter = safeIntl.Segmenter(this.intlSegmenterLocales, { granularity: 'word' });
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this._segmenter = null;
|
|
21
|
-
}
|
|
22
|
-
for (let i = 0, len = wordSeparators.length; i < len; i++) {
|
|
23
|
-
this.set(wordSeparators.charCodeAt(i), 2 /* WordCharacterClass.WordSeparator */);
|
|
24
|
-
}
|
|
25
|
-
this.set(32 /* CharCode.Space */, 1 /* WordCharacterClass.Whitespace */);
|
|
26
|
-
this.set(9 /* CharCode.Tab */, 1 /* WordCharacterClass.Whitespace */);
|
|
27
|
-
}
|
|
28
|
-
findPrevIntlWordBeforeOrAtOffset(line, offset) {
|
|
29
|
-
let candidate = null;
|
|
30
|
-
for (const segment of this._getIntlSegmenterWordsOnLine(line)) {
|
|
31
|
-
if (segment.index > offset) {
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
candidate = segment;
|
|
35
|
-
}
|
|
36
|
-
return candidate;
|
|
37
|
-
}
|
|
38
|
-
findNextIntlWordAtOrAfterOffset(lineContent, offset) {
|
|
39
|
-
for (const segment of this._getIntlSegmenterWordsOnLine(lineContent)) {
|
|
40
|
-
if (segment.index < offset) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
return segment;
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
_getIntlSegmenterWordsOnLine(line) {
|
|
48
|
-
if (!this._segmenter) {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
// Check if the line has changed from the previous call
|
|
52
|
-
if (this._cachedLine === line) {
|
|
53
|
-
return this._cachedSegments;
|
|
54
|
-
}
|
|
55
|
-
// Update the cache with the new line
|
|
56
|
-
this._cachedLine = line;
|
|
57
|
-
this._cachedSegments = this._filterWordSegments(this._segmenter.value.segment(line));
|
|
58
|
-
return this._cachedSegments;
|
|
59
|
-
}
|
|
60
|
-
_filterWordSegments(segments) {
|
|
61
|
-
const result = [];
|
|
62
|
-
for (const segment of segments) {
|
|
63
|
-
if (this._isWordLike(segment)) {
|
|
64
|
-
result.push(segment);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
_isWordLike(segment) {
|
|
70
|
-
if (segment.isWordLike) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const wordClassifierCache = new LRUCache(10);
|
|
77
|
-
function getMapForWordSeparators(wordSeparators, intlSegmenterLocales) {
|
|
78
|
-
const key = `${wordSeparators}/${intlSegmenterLocales.join(',')}`;
|
|
79
|
-
let result = wordClassifierCache.get(key);
|
|
80
|
-
if (!result) {
|
|
81
|
-
result = new WordCharacterClassifier(wordSeparators, intlSegmenterLocales);
|
|
82
|
-
wordClassifierCache.set(key, result);
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { WordCharacterClassifier, getMapForWordSeparators };
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Iterable } from '../../../base/common/iterator.js';
|
|
2
|
-
import { LinkedList } from '../../../base/common/linkedList.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
|
-
const USUAL_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?';
|
|
9
|
-
/**
|
|
10
|
-
* Create a word definition regular expression based on default word separators.
|
|
11
|
-
* Optionally provide allowed separators that should be included in words.
|
|
12
|
-
*
|
|
13
|
-
* The default would look like this:
|
|
14
|
-
* /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
|
|
15
|
-
*/
|
|
16
|
-
function createWordRegExp(allowInWords = '') {
|
|
17
|
-
let source = '(-?\\d*\\.\\d\\w*)|([^';
|
|
18
|
-
for (const sep of USUAL_WORD_SEPARATORS) {
|
|
19
|
-
if (allowInWords.indexOf(sep) >= 0) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
source += '\\' + sep;
|
|
23
|
-
}
|
|
24
|
-
source += '\\s]+)';
|
|
25
|
-
return new RegExp(source, 'g');
|
|
26
|
-
}
|
|
27
|
-
// catches numbers (including floating numbers) in the first group, and alphanum in the second
|
|
28
|
-
const DEFAULT_WORD_REGEXP = createWordRegExp();
|
|
29
|
-
function ensureValidWordDefinition(wordDefinition) {
|
|
30
|
-
let result = DEFAULT_WORD_REGEXP;
|
|
31
|
-
if (wordDefinition && (wordDefinition instanceof RegExp)) {
|
|
32
|
-
if (!wordDefinition.global) {
|
|
33
|
-
let flags = 'g';
|
|
34
|
-
if (wordDefinition.ignoreCase) {
|
|
35
|
-
flags += 'i';
|
|
36
|
-
}
|
|
37
|
-
if (wordDefinition.multiline) {
|
|
38
|
-
flags += 'm';
|
|
39
|
-
}
|
|
40
|
-
if (wordDefinition.unicode) {
|
|
41
|
-
flags += 'u';
|
|
42
|
-
}
|
|
43
|
-
result = new RegExp(wordDefinition.source, flags);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
result = wordDefinition;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
result.lastIndex = 0;
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
const _defaultConfig = new LinkedList();
|
|
53
|
-
_defaultConfig.unshift({
|
|
54
|
-
maxLen: 1000,
|
|
55
|
-
windowSize: 15,
|
|
56
|
-
timeBudget: 150
|
|
57
|
-
});
|
|
58
|
-
function getWordAtText(column, wordDefinition, text, textOffset, config) {
|
|
59
|
-
// Ensure the regex has the 'g' flag, otherwise this will loop forever
|
|
60
|
-
wordDefinition = ensureValidWordDefinition(wordDefinition);
|
|
61
|
-
if (!config) {
|
|
62
|
-
config = Iterable.first(_defaultConfig);
|
|
63
|
-
}
|
|
64
|
-
if (text.length > config.maxLen) {
|
|
65
|
-
// don't throw strings that long at the regexp
|
|
66
|
-
// but use a sub-string in which a word must occur
|
|
67
|
-
let start = column - config.maxLen / 2;
|
|
68
|
-
if (start < 0) {
|
|
69
|
-
start = 0;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
textOffset += start;
|
|
73
|
-
}
|
|
74
|
-
text = text.substring(start, column + config.maxLen / 2);
|
|
75
|
-
return getWordAtText(column, wordDefinition, text, textOffset, config);
|
|
76
|
-
}
|
|
77
|
-
const t1 = Date.now();
|
|
78
|
-
const pos = column - 1 - textOffset;
|
|
79
|
-
let prevRegexIndex = -1;
|
|
80
|
-
let match = null;
|
|
81
|
-
for (let i = 1;; i++) {
|
|
82
|
-
// check time budget
|
|
83
|
-
if (Date.now() - t1 >= config.timeBudget) {
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
// reset the index at which the regexp should start matching, also know where it
|
|
87
|
-
// should stop so that subsequent search don't repeat previous searches
|
|
88
|
-
const regexIndex = pos - config.windowSize * i;
|
|
89
|
-
wordDefinition.lastIndex = Math.max(0, regexIndex);
|
|
90
|
-
const thisMatch = _findRegexMatchEnclosingPosition(wordDefinition, text, pos, prevRegexIndex);
|
|
91
|
-
if (!thisMatch && match) {
|
|
92
|
-
// stop: we have something
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
match = thisMatch;
|
|
96
|
-
// stop: searched at start
|
|
97
|
-
if (regexIndex <= 0) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
prevRegexIndex = regexIndex;
|
|
101
|
-
}
|
|
102
|
-
if (match) {
|
|
103
|
-
const result = {
|
|
104
|
-
word: match[0],
|
|
105
|
-
startColumn: textOffset + 1 + match.index,
|
|
106
|
-
endColumn: textOffset + 1 + match.index + match[0].length
|
|
107
|
-
};
|
|
108
|
-
wordDefinition.lastIndex = 0;
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
function _findRegexMatchEnclosingPosition(wordDefinition, text, pos, stopPos) {
|
|
114
|
-
let match;
|
|
115
|
-
while (match = wordDefinition.exec(text)) {
|
|
116
|
-
const matchIndex = match.index || 0;
|
|
117
|
-
if (matchIndex <= pos && wordDefinition.lastIndex >= pos) {
|
|
118
|
-
return match;
|
|
119
|
-
}
|
|
120
|
-
else if (stopPos > 0 && matchIndex > stopPos) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { DEFAULT_WORD_REGEXP, USUAL_WORD_SEPARATORS, ensureValidWordDefinition, getWordAtText };
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { WorkerManager } from './workerManager.js';
|
|
2
|
-
import { CompletionAdapter, HoverAdapter, DocumentHighlightAdapter, DefinitionAdapter, ReferenceAdapter, DocumentSymbolAdapter, RenameAdapter, DocumentColorAdapter, FoldingRangeAdapter, DiagnosticsAdapter, SelectionRangeAdapter, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from '../common/lspLanguageFeatures.js';
|
|
3
|
-
export { DocumentLinkAdapter, fromPosition, fromRange, toRange, toTextEdit } from '../common/lspLanguageFeatures.js';
|
|
4
|
-
import '../../editor/browser/coreCommands.js';
|
|
5
|
-
import '../../editor/browser/widget/codeEditor/codeEditorWidget.js';
|
|
6
|
-
import '../../editor/browser/widget/diffEditor/diffEditor.contribution.js';
|
|
7
|
-
import '../../editor/contrib/anchorSelect/browser/anchorSelect.js';
|
|
8
|
-
import '../../editor/contrib/bracketMatching/browser/bracketMatching.js';
|
|
9
|
-
import '../../editor/contrib/caretOperations/browser/caretOperations.js';
|
|
10
|
-
import '../../editor/contrib/caretOperations/browser/transpose.js';
|
|
11
|
-
import '../../editor/contrib/clipboard/browser/clipboard.js';
|
|
12
|
-
import '../../editor/contrib/codeAction/browser/codeActionContributions.js';
|
|
13
|
-
import '../../editor/contrib/codelens/browser/codelensController.js';
|
|
14
|
-
import '../../editor/contrib/colorPicker/browser/colorPickerContribution.js';
|
|
15
|
-
import '../../editor/contrib/comment/browser/comment.js';
|
|
16
|
-
import '../../editor/contrib/contextmenu/browser/contextmenu.js';
|
|
17
|
-
import '../../editor/contrib/cursorUndo/browser/cursorUndo.js';
|
|
18
|
-
import '../../editor/contrib/dnd/browser/dnd.js';
|
|
19
|
-
import '../../editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js';
|
|
20
|
-
import '../../editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js';
|
|
21
|
-
import '../../editor/contrib/find/browser/findController.js';
|
|
22
|
-
import '../../editor/contrib/folding/browser/folding.js';
|
|
23
|
-
import '../../editor/contrib/fontZoom/browser/fontZoom.js';
|
|
24
|
-
import '../../editor/contrib/format/browser/formatActions.js';
|
|
25
|
-
import '../../editor/contrib/documentSymbols/browser/documentSymbols.js';
|
|
26
|
-
import '../../editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js';
|
|
27
|
-
import '../../editor/contrib/inlineProgress/browser/inlineProgress.js';
|
|
28
|
-
import '../../editor/contrib/gotoSymbol/browser/goToCommands.js';
|
|
29
|
-
import '../../editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js';
|
|
30
|
-
import '../../editor/contrib/gotoError/browser/gotoError.js';
|
|
31
|
-
import '../../editor/contrib/gpu/browser/gpuActions.js';
|
|
32
|
-
import '../../editor/contrib/hover/browser/hoverContribution.js';
|
|
33
|
-
import '../../editor/contrib/indentation/browser/indentation.js';
|
|
34
|
-
import '../../editor/contrib/inlayHints/browser/inlayHintsContribution.js';
|
|
35
|
-
import '../../editor/contrib/inPlaceReplace/browser/inPlaceReplace.js';
|
|
36
|
-
import '../../editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js';
|
|
37
|
-
import '../../editor/contrib/lineSelection/browser/lineSelection.js';
|
|
38
|
-
import '../../editor/contrib/linesOperations/browser/linesOperations.js';
|
|
39
|
-
import '../../editor/contrib/linkedEditing/browser/linkedEditing.js';
|
|
40
|
-
import '../../editor/contrib/links/browser/links.js';
|
|
41
|
-
import '../../editor/contrib/longLinesHelper/browser/longLinesHelper.js';
|
|
42
|
-
import '../../editor/contrib/middleScroll/browser/middleScroll.contribution.js';
|
|
43
|
-
import '../../editor/contrib/multicursor/browser/multicursor.js';
|
|
44
|
-
import '../../editor/contrib/parameterHints/browser/parameterHints.js';
|
|
45
|
-
import '../../editor/contrib/placeholderText/browser/placeholderText.contribution.js';
|
|
46
|
-
import '../../editor/contrib/rename/browser/rename.js';
|
|
47
|
-
import '../../editor/contrib/sectionHeaders/browser/sectionHeaders.js';
|
|
48
|
-
import '../../editor/contrib/semanticTokens/browser/documentSemanticTokens.js';
|
|
49
|
-
import '../../editor/contrib/semanticTokens/browser/viewportSemanticTokens.js';
|
|
50
|
-
import '../../editor/contrib/smartSelect/browser/smartSelect.js';
|
|
51
|
-
import '../../editor/contrib/snippet/browser/snippetController2.js';
|
|
52
|
-
import '../../editor/contrib/stickyScroll/browser/stickyScrollContribution.js';
|
|
53
|
-
import '../../editor/contrib/suggest/browser/suggestController.js';
|
|
54
|
-
import '../../editor/contrib/suggest/browser/suggestInlineCompletions.js';
|
|
55
|
-
import '../../editor/contrib/tokenization/browser/tokenization.js';
|
|
56
|
-
import '../../editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js';
|
|
57
|
-
import '../../editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js';
|
|
58
|
-
import '../../editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js';
|
|
59
|
-
import '../../editor/contrib/wordHighlighter/browser/wordHighlighter.js';
|
|
60
|
-
import '../../editor/contrib/wordOperations/browser/wordOperations.js';
|
|
61
|
-
import '../../editor/contrib/wordPartOperations/browser/wordPartOperations.js';
|
|
62
|
-
import '../../editor/contrib/readOnlyMessage/browser/contribution.js';
|
|
63
|
-
import '../../editor/contrib/diffEditorBreadcrumbs/browser/contribution.js';
|
|
64
|
-
import '../../editor/contrib/floatingMenu/browser/floatingMenu.contribution.js';
|
|
65
|
-
import '../../editor/common/standaloneStrings.js';
|
|
66
|
-
import '../../base/browser/ui/codicons/codicon/codicon.css';
|
|
67
|
-
import '../../base/browser/ui/codicons/codicon/codicon-modifiers.css';
|
|
68
|
-
import '../../editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js';
|
|
69
|
-
import '../../editor/standalone/browser/inspectTokens/inspectTokens.js';
|
|
70
|
-
import '../../editor/standalone/browser/quickAccess/standaloneHelpQuickAccess.js';
|
|
71
|
-
import '../../editor/standalone/browser/quickAccess/standaloneGotoLineQuickAccess.js';
|
|
72
|
-
import '../../editor/standalone/browser/quickAccess/standaloneGotoSymbolQuickAccess.js';
|
|
73
|
-
import '../../editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess.js';
|
|
74
|
-
import '../../editor/standalone/browser/referenceSearch/standaloneReferenceSearch.js';
|
|
75
|
-
import '../../editor/standalone/browser/toggleHighContrast/toggleHighContrast.js';
|
|
76
|
-
import { languages } from '../../editor/editor.api2.js';
|
|
77
|
-
|
|
78
|
-
function setupMode(defaults) {
|
|
79
|
-
const disposables = [];
|
|
80
|
-
const providers = [];
|
|
81
|
-
const client = new WorkerManager(defaults);
|
|
82
|
-
disposables.push(client);
|
|
83
|
-
const worker = (...uris) => {
|
|
84
|
-
return client.getLanguageServiceWorker(...uris);
|
|
85
|
-
};
|
|
86
|
-
function registerProviders() {
|
|
87
|
-
const { languageId, modeConfiguration } = defaults;
|
|
88
|
-
disposeAll(providers);
|
|
89
|
-
if (modeConfiguration.completionItems) {
|
|
90
|
-
providers.push(
|
|
91
|
-
languages.registerCompletionItemProvider(
|
|
92
|
-
languageId,
|
|
93
|
-
new CompletionAdapter(worker, ["/", "-", ":"])
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
if (modeConfiguration.hovers) {
|
|
98
|
-
providers.push(
|
|
99
|
-
languages.registerHoverProvider(languageId, new HoverAdapter(worker))
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
if (modeConfiguration.documentHighlights) {
|
|
103
|
-
providers.push(
|
|
104
|
-
languages.registerDocumentHighlightProvider(
|
|
105
|
-
languageId,
|
|
106
|
-
new DocumentHighlightAdapter(worker)
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
if (modeConfiguration.definitions) {
|
|
111
|
-
providers.push(
|
|
112
|
-
languages.registerDefinitionProvider(
|
|
113
|
-
languageId,
|
|
114
|
-
new DefinitionAdapter(worker)
|
|
115
|
-
)
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
if (modeConfiguration.references) {
|
|
119
|
-
providers.push(
|
|
120
|
-
languages.registerReferenceProvider(
|
|
121
|
-
languageId,
|
|
122
|
-
new ReferenceAdapter(worker)
|
|
123
|
-
)
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
if (modeConfiguration.documentSymbols) {
|
|
127
|
-
providers.push(
|
|
128
|
-
languages.registerDocumentSymbolProvider(
|
|
129
|
-
languageId,
|
|
130
|
-
new DocumentSymbolAdapter(worker)
|
|
131
|
-
)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
if (modeConfiguration.rename) {
|
|
135
|
-
providers.push(
|
|
136
|
-
languages.registerRenameProvider(languageId, new RenameAdapter(worker))
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
if (modeConfiguration.colors) {
|
|
140
|
-
providers.push(
|
|
141
|
-
languages.registerColorProvider(
|
|
142
|
-
languageId,
|
|
143
|
-
new DocumentColorAdapter(worker)
|
|
144
|
-
)
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
if (modeConfiguration.foldingRanges) {
|
|
148
|
-
providers.push(
|
|
149
|
-
languages.registerFoldingRangeProvider(
|
|
150
|
-
languageId,
|
|
151
|
-
new FoldingRangeAdapter(worker)
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (modeConfiguration.diagnostics) {
|
|
156
|
-
providers.push(
|
|
157
|
-
new DiagnosticsAdapter(languageId, worker, defaults.onDidChange)
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
if (modeConfiguration.selectionRanges) {
|
|
161
|
-
providers.push(
|
|
162
|
-
languages.registerSelectionRangeProvider(
|
|
163
|
-
languageId,
|
|
164
|
-
new SelectionRangeAdapter(worker)
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
if (modeConfiguration.documentFormattingEdits) {
|
|
169
|
-
providers.push(
|
|
170
|
-
languages.registerDocumentFormattingEditProvider(
|
|
171
|
-
languageId,
|
|
172
|
-
new DocumentFormattingEditProvider(worker)
|
|
173
|
-
)
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
if (modeConfiguration.documentRangeFormattingEdits) {
|
|
177
|
-
providers.push(
|
|
178
|
-
languages.registerDocumentRangeFormattingEditProvider(
|
|
179
|
-
languageId,
|
|
180
|
-
new DocumentRangeFormattingEditProvider(worker)
|
|
181
|
-
)
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
registerProviders();
|
|
186
|
-
disposables.push(asDisposable(providers));
|
|
187
|
-
return asDisposable(disposables);
|
|
188
|
-
}
|
|
189
|
-
function asDisposable(disposables) {
|
|
190
|
-
return { dispose: () => disposeAll(disposables) };
|
|
191
|
-
}
|
|
192
|
-
function disposeAll(disposables) {
|
|
193
|
-
while (disposables.length) {
|
|
194
|
-
disposables.pop().dispose();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export { CompletionAdapter, DefinitionAdapter, DiagnosticsAdapter, DocumentColorAdapter, DocumentFormattingEditProvider, DocumentHighlightAdapter, DocumentRangeFormattingEditProvider, DocumentSymbolAdapter, FoldingRangeAdapter, HoverAdapter, ReferenceAdapter, RenameAdapter, SelectionRangeAdapter, WorkerManager, setupMode };
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { newCSSDataProvider, getSCSSLanguageService, getLESSLanguageService, getCSSLanguageService } from '../../../external/vscode-css-languageservice/lib/esm/cssLanguageService.js';
|
|
2
|
-
import { TextDocument } from '../../../external/vscode-languageserver-textdocument/lib/esm/main.js';
|
|
3
|
-
|
|
4
|
-
class CSSWorker {
|
|
5
|
-
constructor(ctx, createData) {
|
|
6
|
-
this._ctx = ctx;
|
|
7
|
-
this._languageSettings = createData.options;
|
|
8
|
-
this._languageId = createData.languageId;
|
|
9
|
-
const data = createData.options.data;
|
|
10
|
-
const useDefaultDataProvider = data?.useDefaultDataProvider;
|
|
11
|
-
const customDataProviders = [];
|
|
12
|
-
if (data?.dataProviders) {
|
|
13
|
-
for (const id in data.dataProviders) {
|
|
14
|
-
customDataProviders.push(newCSSDataProvider(data.dataProviders[id]));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const lsOptions = {
|
|
18
|
-
customDataProviders,
|
|
19
|
-
useDefaultDataProvider
|
|
20
|
-
};
|
|
21
|
-
switch (this._languageId) {
|
|
22
|
-
case "css":
|
|
23
|
-
this._languageService = getCSSLanguageService(lsOptions);
|
|
24
|
-
break;
|
|
25
|
-
case "less":
|
|
26
|
-
this._languageService = getLESSLanguageService(lsOptions);
|
|
27
|
-
break;
|
|
28
|
-
case "scss":
|
|
29
|
-
this._languageService = getSCSSLanguageService(lsOptions);
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
throw new Error("Invalid language id: " + this._languageId);
|
|
33
|
-
}
|
|
34
|
-
this._languageService.configure(this._languageSettings);
|
|
35
|
-
}
|
|
36
|
-
// --- language service host ---------------
|
|
37
|
-
async doValidation(uri) {
|
|
38
|
-
const document = this._getTextDocument(uri);
|
|
39
|
-
if (document) {
|
|
40
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
41
|
-
const diagnostics = this._languageService.doValidation(document, stylesheet);
|
|
42
|
-
return Promise.resolve(diagnostics);
|
|
43
|
-
}
|
|
44
|
-
return Promise.resolve([]);
|
|
45
|
-
}
|
|
46
|
-
async doComplete(uri, position) {
|
|
47
|
-
const document = this._getTextDocument(uri);
|
|
48
|
-
if (!document) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
52
|
-
const completions = this._languageService.doComplete(document, position, stylesheet);
|
|
53
|
-
return Promise.resolve(completions);
|
|
54
|
-
}
|
|
55
|
-
async doHover(uri, position) {
|
|
56
|
-
const document = this._getTextDocument(uri);
|
|
57
|
-
if (!document) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
61
|
-
const hover = this._languageService.doHover(document, position, stylesheet);
|
|
62
|
-
return Promise.resolve(hover);
|
|
63
|
-
}
|
|
64
|
-
async findDefinition(uri, position) {
|
|
65
|
-
const document = this._getTextDocument(uri);
|
|
66
|
-
if (!document) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
70
|
-
const definition = this._languageService.findDefinition(document, position, stylesheet);
|
|
71
|
-
return Promise.resolve(definition);
|
|
72
|
-
}
|
|
73
|
-
async findReferences(uri, position) {
|
|
74
|
-
const document = this._getTextDocument(uri);
|
|
75
|
-
if (!document) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
79
|
-
const references = this._languageService.findReferences(document, position, stylesheet);
|
|
80
|
-
return Promise.resolve(references);
|
|
81
|
-
}
|
|
82
|
-
async findDocumentHighlights(uri, position) {
|
|
83
|
-
const document = this._getTextDocument(uri);
|
|
84
|
-
if (!document) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
88
|
-
const highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
|
|
89
|
-
return Promise.resolve(highlights);
|
|
90
|
-
}
|
|
91
|
-
async findDocumentSymbols(uri) {
|
|
92
|
-
const document = this._getTextDocument(uri);
|
|
93
|
-
if (!document) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
97
|
-
const symbols = this._languageService.findDocumentSymbols(document, stylesheet);
|
|
98
|
-
return Promise.resolve(symbols);
|
|
99
|
-
}
|
|
100
|
-
async doCodeActions(uri, range, context) {
|
|
101
|
-
const document = this._getTextDocument(uri);
|
|
102
|
-
if (!document) {
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
106
|
-
const actions = this._languageService.doCodeActions(document, range, context, stylesheet);
|
|
107
|
-
return Promise.resolve(actions);
|
|
108
|
-
}
|
|
109
|
-
async findDocumentColors(uri) {
|
|
110
|
-
const document = this._getTextDocument(uri);
|
|
111
|
-
if (!document) {
|
|
112
|
-
return [];
|
|
113
|
-
}
|
|
114
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
115
|
-
const colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
|
116
|
-
return Promise.resolve(colorSymbols);
|
|
117
|
-
}
|
|
118
|
-
async getColorPresentations(uri, color, range) {
|
|
119
|
-
const document = this._getTextDocument(uri);
|
|
120
|
-
if (!document) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
124
|
-
const colorPresentations = this._languageService.getColorPresentations(
|
|
125
|
-
document,
|
|
126
|
-
stylesheet,
|
|
127
|
-
color,
|
|
128
|
-
range
|
|
129
|
-
);
|
|
130
|
-
return Promise.resolve(colorPresentations);
|
|
131
|
-
}
|
|
132
|
-
async getFoldingRanges(uri, context) {
|
|
133
|
-
const document = this._getTextDocument(uri);
|
|
134
|
-
if (!document) {
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
const ranges = this._languageService.getFoldingRanges(document, context);
|
|
138
|
-
return Promise.resolve(ranges);
|
|
139
|
-
}
|
|
140
|
-
async getSelectionRanges(uri, positions) {
|
|
141
|
-
const document = this._getTextDocument(uri);
|
|
142
|
-
if (!document) {
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
145
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
146
|
-
const ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
|
|
147
|
-
return Promise.resolve(ranges);
|
|
148
|
-
}
|
|
149
|
-
async doRename(uri, position, newName) {
|
|
150
|
-
const document = this._getTextDocument(uri);
|
|
151
|
-
if (!document) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
const stylesheet = this._languageService.parseStylesheet(document);
|
|
155
|
-
const renames = this._languageService.doRename(document, position, newName, stylesheet);
|
|
156
|
-
return Promise.resolve(renames);
|
|
157
|
-
}
|
|
158
|
-
async format(uri, range, options) {
|
|
159
|
-
const document = this._getTextDocument(uri);
|
|
160
|
-
if (!document) {
|
|
161
|
-
return [];
|
|
162
|
-
}
|
|
163
|
-
const settings = { ...this._languageSettings.format, ...options };
|
|
164
|
-
const textEdits = this._languageService.format(document, range, settings);
|
|
165
|
-
return Promise.resolve(textEdits);
|
|
166
|
-
}
|
|
167
|
-
_getTextDocument(uri) {
|
|
168
|
-
const models = this._ctx.getMirrorModels();
|
|
169
|
-
for (const model of models) {
|
|
170
|
-
if (model.uri.toString() === uri) {
|
|
171
|
-
return TextDocument.create(
|
|
172
|
-
uri,
|
|
173
|
-
this._languageId,
|
|
174
|
-
model.version,
|
|
175
|
-
model.getValue()
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { CSSWorker };
|