monaco-editor11 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/css.worker-C7FogG4G.js +93 -0
- package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
- package/dist/assets/html.worker-C8VxctEJ.js +470 -0
- package/dist/assets/json.worker-CMC9kgPL.js +58 -0
- package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
- package/dist/index.d.ts +0 -6
- package/dist/monaco-editor11.es.js +49 -78
- package/dist/monaco-editor11.umd.js +1 -50
- package/dist/monaco.d.ts +8 -0
- package/dist/workers/common/initialize.js +16 -0
- package/dist/workers/common/workers.js +141 -0
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
- package/dist/workers/editor/common/abstractText.js +89 -0
- package/dist/workers/editor/common/ast.js +485 -0
- package/dist/workers/editor/common/autoIndent.js +390 -0
- package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
- package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
- package/dist/workers/editor/common/bracketPairsTree.js +343 -0
- package/dist/workers/editor/common/brackets.js +108 -0
- package/dist/workers/editor/common/characterClassifier.js +59 -0
- package/dist/workers/editor/common/characterPair.js +40 -0
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
- package/dist/workers/editor/common/columnRange.js +35 -0
- package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
- package/dist/workers/editor/common/common.js +20 -0
- package/dist/workers/editor/common/computeMovedLines.js +249 -0
- package/dist/workers/editor/common/concat23Trees.js +192 -0
- package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
- package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
- package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
- package/dist/workers/editor/common/coordinatesConverter.js +51 -0
- package/dist/workers/editor/common/cursor.js +899 -0
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
- package/dist/workers/editor/common/cursorCollection.js +194 -0
- package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
- package/dist/workers/editor/common/cursorColumns.js +112 -0
- package/dist/workers/editor/common/cursorCommon.js +250 -0
- package/dist/workers/editor/common/cursorContext.js +15 -0
- package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
- package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
- package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
- package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
- package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
- package/dist/workers/editor/common/cursorUtils.js +75 -0
- package/dist/workers/editor/common/cursorWordOperations.js +720 -0
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
- package/dist/workers/editor/common/diffAlgorithm.js +139 -0
- package/dist/workers/editor/common/diffEditor.js +38 -0
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
- package/dist/workers/editor/common/edit.js +183 -0
- package/dist/workers/editor/common/editOperation.js +36 -0
- package/dist/workers/editor/common/editStack.js +363 -0
- package/dist/workers/editor/common/editorAction.js +26 -0
- package/dist/workers/editor/common/editorBaseApi.js +43 -0
- package/dist/workers/editor/common/editorColorRegistry.js +102 -0
- package/dist/workers/editor/common/editorCommon.js +13 -0
- package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
- package/dist/workers/editor/common/editorContextKeys.js +84 -0
- package/dist/workers/editor/common/editorFeatures.js +17 -0
- package/dist/workers/editor/common/editorOptions.js +3440 -0
- package/dist/workers/editor/common/editorTheme.js +23 -0
- package/dist/workers/editor/common/editorWebWorker.js +299 -0
- package/dist/workers/editor/common/editorWorker.js +9 -0
- package/dist/workers/editor/common/editorWorkerHost.js +15 -0
- package/dist/workers/editor/common/editorZoom.js +26 -0
- package/dist/workers/editor/common/electricCharacter.js +55 -0
- package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
- package/dist/workers/editor/common/enterAction.js +53 -0
- package/dist/workers/editor/common/eolCounter.js +44 -0
- package/dist/workers/editor/common/findSectionHeaders.js +128 -0
- package/dist/workers/editor/common/fixBrackets.js +67 -0
- package/dist/workers/editor/common/fixedArray.js +70 -0
- package/dist/workers/editor/common/fontInfo.js +172 -0
- package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
- package/dist/workers/editor/common/getIconClasses.js +106 -0
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
- package/dist/workers/editor/common/glyphLanesModel.js +61 -0
- package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
- package/dist/workers/editor/common/indentRules.js +63 -0
- package/dist/workers/editor/common/indentation.js +39 -0
- package/dist/workers/editor/common/indentationGuesser.js +178 -0
- package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
- package/dist/workers/editor/common/inlineDecorations.js +26 -0
- package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
- package/dist/workers/editor/common/inputMode.js +22 -0
- package/dist/workers/editor/common/intervalTree.js +1002 -0
- package/dist/workers/editor/common/language.js +9 -0
- package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
- package/dist/workers/editor/common/languageConfiguration.js +138 -0
- package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
- package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
- package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
- package/dist/workers/editor/common/languageFeatures.js +9 -0
- package/dist/workers/editor/common/languageFeaturesService.js +47 -0
- package/dist/workers/editor/common/languageSelector.js +112 -0
- package/dist/workers/editor/common/languageService.js +92 -0
- package/dist/workers/editor/common/languages.js +522 -0
- package/dist/workers/editor/common/languagesAssociations.js +193 -0
- package/dist/workers/editor/common/languagesRegistry.js +237 -0
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
- package/dist/workers/editor/common/length.js +129 -0
- package/dist/workers/editor/common/lineDecorations.js +208 -0
- package/dist/workers/editor/common/lineEdit.js +75 -0
- package/dist/workers/editor/common/lineHeights.js +370 -0
- package/dist/workers/editor/common/linePart.js +25 -0
- package/dist/workers/editor/common/lineRange.js +312 -0
- package/dist/workers/editor/common/lineSequence.js +36 -0
- package/dist/workers/editor/common/lineTokens.js +405 -0
- package/dist/workers/editor/common/linesDiffComputer.js +29 -0
- package/dist/workers/editor/common/linesDiffComputers.js +13 -0
- package/dist/workers/editor/common/linesLayout.js +765 -0
- package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
- package/dist/workers/editor/common/linkComputer.js +269 -0
- package/dist/workers/editor/common/markerDecorations.js +9 -0
- package/dist/workers/editor/common/markerDecorationsService.js +248 -0
- package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
- package/dist/workers/editor/common/mirrorTextModel.js +117 -0
- package/dist/workers/editor/common/model.js +9 -0
- package/dist/workers/editor/common/modelLineProjection.js +350 -0
- package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
- package/dist/workers/editor/common/modelService.js +413 -0
- package/dist/workers/editor/common/modesRegistry.js +75 -0
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
- package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
- package/dist/workers/editor/common/nodeReader.js +127 -0
- package/dist/workers/editor/common/nullTokenize.js +29 -0
- package/dist/workers/editor/common/offsetRange.js +225 -0
- package/dist/workers/editor/common/onEnter.js +109 -0
- package/dist/workers/editor/common/oneCursor.js +117 -0
- package/dist/workers/editor/common/overviewZoneManager.js +176 -0
- package/dist/workers/editor/common/parser.js +121 -0
- package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
- package/dist/workers/editor/common/point.js +50 -0
- package/dist/workers/editor/common/position.js +142 -0
- package/dist/workers/editor/common/positionToOffset.js +17 -0
- package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
- package/dist/workers/editor/common/prefixSumComputer.js +226 -0
- package/dist/workers/editor/common/range.js +421 -0
- package/dist/workers/editor/common/rangeMapping.js +229 -0
- package/dist/workers/editor/common/rangeSingleLine.js +17 -0
- package/dist/workers/editor/common/rbTreeBase.js +362 -0
- package/dist/workers/editor/common/rect.js +163 -0
- package/dist/workers/editor/common/replaceCommand.js +158 -0
- package/dist/workers/editor/common/resolverService.js +5 -0
- package/dist/workers/editor/common/rgba.js +35 -0
- package/dist/workers/editor/common/richEditBrackets.js +356 -0
- package/dist/workers/editor/common/selection.js +145 -0
- package/dist/workers/editor/common/semanticTokensDto.js +82 -0
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
- package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
- package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
- package/dist/workers/editor/common/shiftCommand.js +241 -0
- package/dist/workers/editor/common/smallImmutableSet.js +108 -0
- package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
- package/dist/workers/editor/common/sparseTokensStore.js +210 -0
- package/dist/workers/editor/common/standaloneEnums.js +1017 -0
- package/dist/workers/editor/common/standaloneStrings.js +42 -0
- package/dist/workers/editor/common/stringBuilder.js +122 -0
- package/dist/workers/editor/common/stringEdit.js +165 -0
- package/dist/workers/editor/common/supports.js +58 -0
- package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
- package/dist/workers/editor/common/textChange.js +248 -0
- package/dist/workers/editor/common/textEdit.js +269 -0
- package/dist/workers/editor/common/textLength.js +87 -0
- package/dist/workers/editor/common/textModel.js +2031 -0
- package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
- package/dist/workers/editor/common/textModelDefaults.js +18 -0
- package/dist/workers/editor/common/textModelEditSource.js +166 -0
- package/dist/workers/editor/common/textModelEvents.js +216 -0
- package/dist/workers/editor/common/textModelGuides.js +40 -0
- package/dist/workers/editor/common/textModelPart.js +23 -0
- package/dist/workers/editor/common/textModelSearch.js +455 -0
- package/dist/workers/editor/common/textModelStringEdit.js +11 -0
- package/dist/workers/editor/common/textModelSync.impl.js +307 -0
- package/dist/workers/editor/common/textModelText.js +26 -0
- package/dist/workers/editor/common/textModelTokens.js +436 -0
- package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
- package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
- package/dist/workers/editor/common/tokenStore.js +407 -0
- package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
- package/dist/workers/editor/common/tokenization.js +287 -0
- package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
- package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
- package/dist/workers/editor/common/tokenizer.js +301 -0
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
- package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
- package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
- package/dist/workers/editor/common/treeSitterTree.js +395 -0
- package/dist/workers/editor/common/treeViewsDnd.js +24 -0
- package/dist/workers/editor/common/treeViewsDndService.js +12 -0
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
- package/dist/workers/editor/common/utils.js +62 -0
- package/dist/workers/editor/common/viewContext.js +22 -0
- package/dist/workers/editor/common/viewEventHandler.js +186 -0
- package/dist/workers/editor/common/viewEvents.js +180 -0
- package/dist/workers/editor/common/viewLayout.js +368 -0
- package/dist/workers/editor/common/viewLineRenderer.js +948 -0
- package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
- package/dist/workers/editor/common/viewModel.js +98 -0
- package/dist/workers/editor/common/viewModelDecoration.js +55 -0
- package/dist/workers/editor/common/viewModelDecorations.js +132 -0
- package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
- package/dist/workers/editor/common/viewModelImpl.js +1163 -0
- package/dist/workers/editor/common/viewModelLines.js +938 -0
- package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
- package/dist/workers/editor/common/wordHelper.js +127 -0
- package/dist/workers/editor/editor.worker.js +11 -0
- package/dist/workers/language/css.worker.js +8 -0
- package/dist/workers/language/cssMode.js +198 -0
- package/dist/workers/language/cssWorker.js +183 -0
- package/dist/workers/language/html.worker.js +8 -0
- package/dist/workers/language/htmlMode.js +213 -0
- package/dist/workers/language/htmlWorker.js +126 -0
- package/dist/workers/language/json.worker.js +8 -0
- package/dist/workers/language/jsonMode.js +224 -0
- package/dist/workers/language/jsonWorker.js +187 -0
- package/dist/workers/language/languageFeatures.js +1009 -0
- package/dist/workers/language/lib.index.js +103 -0
- package/dist/workers/language/lib.js +1107 -0
- package/dist/workers/language/lspLanguageFeatures.js +716 -0
- package/dist/workers/language/monaco.contribution.js +144 -0
- package/dist/workers/language/tokenization.js +189 -0
- package/dist/workers/language/ts.worker.js +14 -0
- package/dist/workers/language/tsMode.js +212 -0
- package/dist/workers/language/tsWorker.js +352 -0
- package/dist/workers/language/typescriptServices.js +210154 -0
- package/dist/workers/language/typescriptServicesMetadata.js +3 -0
- package/dist/workers/language/workerManager.js +65 -0
- package/package.json +3 -2
|
@@ -0,0 +1,87 @@
|
|
|
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 };
|
|
@@ -0,0 +1,127 @@
|
|
|
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 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isWorkerInitialized } from '../common/initialize.js';
|
|
2
|
+
export { initialize } from '../common/initialize.js';
|
|
3
|
+
import { start } from './editor.worker.start.js';
|
|
4
|
+
|
|
5
|
+
self.onmessage = () => {
|
|
6
|
+
if (!isWorkerInitialized()) {
|
|
7
|
+
start(() => {
|
|
8
|
+
return {};
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
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 };
|
|
@@ -0,0 +1,183 @@
|
|
|
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 };
|