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,193 +0,0 @@
|
|
|
1
|
-
import { parse } from '../../../base/common/glob.js';
|
|
2
|
-
import { Mimes } from '../../../base/common/mime.js';
|
|
3
|
-
import { Schemas } from '../../../base/common/network.js';
|
|
4
|
-
import { basename, posix } from '../../../base/common/path.js';
|
|
5
|
-
import { DataUri } from '../../../base/common/resources.js';
|
|
6
|
-
import { startsWithUTF8BOM } from '../../../base/common/strings.js';
|
|
7
|
-
import { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';
|
|
8
|
-
|
|
9
|
-
/*---------------------------------------------------------------------------------------------
|
|
10
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
12
|
-
*--------------------------------------------------------------------------------------------*/
|
|
13
|
-
let registeredAssociations = [];
|
|
14
|
-
let nonUserRegisteredAssociations = [];
|
|
15
|
-
let userRegisteredAssociations = [];
|
|
16
|
-
/**
|
|
17
|
-
* Associate a language to the registry (platform).
|
|
18
|
-
* * **NOTE**: This association will lose over associations registered using `registerConfiguredLanguageAssociation`.
|
|
19
|
-
* * **NOTE**: Use `clearPlatformLanguageAssociations` to remove all associations registered using this function.
|
|
20
|
-
*/
|
|
21
|
-
function registerPlatformLanguageAssociation(association, warnOnOverwrite = false) {
|
|
22
|
-
_registerLanguageAssociation(association, false, warnOnOverwrite);
|
|
23
|
-
}
|
|
24
|
-
function _registerLanguageAssociation(association, userConfigured, warnOnOverwrite) {
|
|
25
|
-
// Register
|
|
26
|
-
const associationItem = toLanguageAssociationItem(association, userConfigured);
|
|
27
|
-
registeredAssociations.push(associationItem);
|
|
28
|
-
if (!associationItem.userConfigured) {
|
|
29
|
-
nonUserRegisteredAssociations.push(associationItem);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
userRegisteredAssociations.push(associationItem);
|
|
33
|
-
}
|
|
34
|
-
// Check for conflicts unless this is a user configured association
|
|
35
|
-
if (warnOnOverwrite && !associationItem.userConfigured) {
|
|
36
|
-
registeredAssociations.forEach(a => {
|
|
37
|
-
if (a.mime === associationItem.mime || a.userConfigured) {
|
|
38
|
-
return; // same mime or userConfigured is ok
|
|
39
|
-
}
|
|
40
|
-
if (associationItem.extension && a.extension === associationItem.extension) {
|
|
41
|
-
console.warn(`Overwriting extension <<${associationItem.extension}>> to now point to mime <<${associationItem.mime}>>`);
|
|
42
|
-
}
|
|
43
|
-
if (associationItem.filename && a.filename === associationItem.filename) {
|
|
44
|
-
console.warn(`Overwriting filename <<${associationItem.filename}>> to now point to mime <<${associationItem.mime}>>`);
|
|
45
|
-
}
|
|
46
|
-
if (associationItem.filepattern && a.filepattern === associationItem.filepattern) {
|
|
47
|
-
console.warn(`Overwriting filepattern <<${associationItem.filepattern}>> to now point to mime <<${associationItem.mime}>>`);
|
|
48
|
-
}
|
|
49
|
-
if (associationItem.firstline && a.firstline === associationItem.firstline) {
|
|
50
|
-
console.warn(`Overwriting firstline <<${associationItem.firstline}>> to now point to mime <<${associationItem.mime}>>`);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function toLanguageAssociationItem(association, userConfigured) {
|
|
56
|
-
return {
|
|
57
|
-
id: association.id,
|
|
58
|
-
mime: association.mime,
|
|
59
|
-
filename: association.filename,
|
|
60
|
-
extension: association.extension,
|
|
61
|
-
filepattern: association.filepattern,
|
|
62
|
-
firstline: association.firstline,
|
|
63
|
-
userConfigured: userConfigured,
|
|
64
|
-
filenameLowercase: association.filename ? association.filename.toLowerCase() : undefined,
|
|
65
|
-
extensionLowercase: association.extension ? association.extension.toLowerCase() : undefined,
|
|
66
|
-
filepatternLowercase: association.filepattern ? parse(association.filepattern.toLowerCase()) : undefined,
|
|
67
|
-
filepatternOnPath: association.filepattern ? association.filepattern.indexOf(posix.sep) >= 0 : false
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Clear language associations from the registry (platform).
|
|
72
|
-
*/
|
|
73
|
-
function clearPlatformLanguageAssociations() {
|
|
74
|
-
registeredAssociations = registeredAssociations.filter(a => a.userConfigured);
|
|
75
|
-
nonUserRegisteredAssociations = [];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* @see `getMimeTypes`
|
|
79
|
-
*/
|
|
80
|
-
function getLanguageIds(resource, firstLine) {
|
|
81
|
-
return getAssociations(resource, firstLine).map(item => item.id);
|
|
82
|
-
}
|
|
83
|
-
function getAssociations(resource, firstLine) {
|
|
84
|
-
let path;
|
|
85
|
-
if (resource) {
|
|
86
|
-
switch (resource.scheme) {
|
|
87
|
-
case Schemas.file:
|
|
88
|
-
path = resource.fsPath;
|
|
89
|
-
break;
|
|
90
|
-
case Schemas.data: {
|
|
91
|
-
const metadata = DataUri.parseMetaData(resource);
|
|
92
|
-
path = metadata.get(DataUri.META_DATA_LABEL);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case Schemas.vscodeNotebookCell:
|
|
96
|
-
// File path not relevant for language detection of cell
|
|
97
|
-
path = undefined;
|
|
98
|
-
break;
|
|
99
|
-
default:
|
|
100
|
-
path = resource.path;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!path) {
|
|
104
|
-
return [{ id: 'unknown', mime: Mimes.unknown }];
|
|
105
|
-
}
|
|
106
|
-
path = path.toLowerCase();
|
|
107
|
-
const filename = basename(path);
|
|
108
|
-
// 1.) User configured mappings have highest priority
|
|
109
|
-
const configuredLanguage = getAssociationByPath(path, filename, userRegisteredAssociations);
|
|
110
|
-
if (configuredLanguage) {
|
|
111
|
-
return [configuredLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
|
|
112
|
-
}
|
|
113
|
-
// 2.) Registered mappings have middle priority
|
|
114
|
-
const registeredLanguage = getAssociationByPath(path, filename, nonUserRegisteredAssociations);
|
|
115
|
-
if (registeredLanguage) {
|
|
116
|
-
return [registeredLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
|
|
117
|
-
}
|
|
118
|
-
// 3.) Firstline has lowest priority
|
|
119
|
-
if (firstLine) {
|
|
120
|
-
const firstlineLanguage = getAssociationByFirstline(firstLine);
|
|
121
|
-
if (firstlineLanguage) {
|
|
122
|
-
return [firstlineLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return [{ id: 'unknown', mime: Mimes.unknown }];
|
|
126
|
-
}
|
|
127
|
-
function getAssociationByPath(path, filename, associations) {
|
|
128
|
-
let filenameMatch = undefined;
|
|
129
|
-
let patternMatch = undefined;
|
|
130
|
-
let extensionMatch = undefined;
|
|
131
|
-
// We want to prioritize associations based on the order they are registered so that the last registered
|
|
132
|
-
// association wins over all other. This is for https://github.com/microsoft/vscode/issues/20074
|
|
133
|
-
for (let i = associations.length - 1; i >= 0; i--) {
|
|
134
|
-
const association = associations[i];
|
|
135
|
-
// First exact name match
|
|
136
|
-
if (filename === association.filenameLowercase) {
|
|
137
|
-
filenameMatch = association;
|
|
138
|
-
break; // take it!
|
|
139
|
-
}
|
|
140
|
-
// Longest pattern match
|
|
141
|
-
if (association.filepattern) {
|
|
142
|
-
if (!patternMatch || association.filepattern.length > patternMatch.filepattern.length) {
|
|
143
|
-
const target = association.filepatternOnPath ? path : filename; // match on full path if pattern contains path separator
|
|
144
|
-
if (association.filepatternLowercase?.(target)) {
|
|
145
|
-
patternMatch = association;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Longest extension match
|
|
150
|
-
if (association.extension) {
|
|
151
|
-
if (!extensionMatch || association.extension.length > extensionMatch.extension.length) {
|
|
152
|
-
if (filename.endsWith(association.extensionLowercase)) {
|
|
153
|
-
extensionMatch = association;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// 1.) Exact name match has second highest priority
|
|
159
|
-
if (filenameMatch) {
|
|
160
|
-
return filenameMatch;
|
|
161
|
-
}
|
|
162
|
-
// 2.) Match on pattern
|
|
163
|
-
if (patternMatch) {
|
|
164
|
-
return patternMatch;
|
|
165
|
-
}
|
|
166
|
-
// 3.) Match on extension comes next
|
|
167
|
-
if (extensionMatch) {
|
|
168
|
-
return extensionMatch;
|
|
169
|
-
}
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
function getAssociationByFirstline(firstLine) {
|
|
173
|
-
if (startsWithUTF8BOM(firstLine)) {
|
|
174
|
-
firstLine = firstLine.substr(1);
|
|
175
|
-
}
|
|
176
|
-
if (firstLine.length > 0) {
|
|
177
|
-
// We want to prioritize associations based on the order they are registered so that the last registered
|
|
178
|
-
// association wins over all other. This is for https://github.com/microsoft/vscode/issues/20074
|
|
179
|
-
for (let i = registeredAssociations.length - 1; i >= 0; i--) {
|
|
180
|
-
const association = registeredAssociations[i];
|
|
181
|
-
if (!association.firstline) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const matches = firstLine.match(association.firstline);
|
|
185
|
-
if (matches && matches.length > 0) {
|
|
186
|
-
return association;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return undefined;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export { clearPlatformLanguageAssociations, getLanguageIds, registerPlatformLanguageAssociation };
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { Emitter } from '../../../base/common/event.js';
|
|
2
|
-
import { Disposable } from '../../../base/common/lifecycle.js';
|
|
3
|
-
import { regExpLeadsToEndlessLoop } from '../../../base/common/strings.js';
|
|
4
|
-
import { clearPlatformLanguageAssociations, registerPlatformLanguageAssociation, getLanguageIds } from './languagesAssociations.js';
|
|
5
|
-
import { ModesRegistry, PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';
|
|
6
|
-
import { Extensions } from '../../../platform/configuration/common/configurationRegistry.js';
|
|
7
|
-
import { Registry } from '../../../platform/registry/common/platform.js';
|
|
8
|
-
|
|
9
|
-
/*---------------------------------------------------------------------------------------------
|
|
10
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
12
|
-
*--------------------------------------------------------------------------------------------*/
|
|
13
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
-
const NULL_LANGUAGE_ID = 'vs.editor.nullLanguage';
|
|
15
|
-
class LanguageIdCodec {
|
|
16
|
-
constructor() {
|
|
17
|
-
this._languageIdToLanguage = [];
|
|
18
|
-
this._languageToLanguageId = new Map();
|
|
19
|
-
this._register(NULL_LANGUAGE_ID, 0 /* LanguageId.Null */);
|
|
20
|
-
this._register(PLAINTEXT_LANGUAGE_ID, 1 /* LanguageId.PlainText */);
|
|
21
|
-
this._nextLanguageId = 2;
|
|
22
|
-
}
|
|
23
|
-
_register(language, languageId) {
|
|
24
|
-
this._languageIdToLanguage[languageId] = language;
|
|
25
|
-
this._languageToLanguageId.set(language, languageId);
|
|
26
|
-
}
|
|
27
|
-
register(language) {
|
|
28
|
-
if (this._languageToLanguageId.has(language)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const languageId = this._nextLanguageId++;
|
|
32
|
-
this._register(language, languageId);
|
|
33
|
-
}
|
|
34
|
-
encodeLanguageId(languageId) {
|
|
35
|
-
return this._languageToLanguageId.get(languageId) || 0 /* LanguageId.Null */;
|
|
36
|
-
}
|
|
37
|
-
decodeLanguageId(languageId) {
|
|
38
|
-
return this._languageIdToLanguage[languageId] || NULL_LANGUAGE_ID;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class LanguagesRegistry extends Disposable {
|
|
42
|
-
static { this.instanceCount = 0; }
|
|
43
|
-
constructor(useModesRegistry = true, warnOnOverwrite = false) {
|
|
44
|
-
super();
|
|
45
|
-
this._onDidChange = this._register(new Emitter());
|
|
46
|
-
this.onDidChange = this._onDidChange.event;
|
|
47
|
-
LanguagesRegistry.instanceCount++;
|
|
48
|
-
this._warnOnOverwrite = warnOnOverwrite;
|
|
49
|
-
this.languageIdCodec = new LanguageIdCodec();
|
|
50
|
-
this._dynamicLanguages = [];
|
|
51
|
-
this._languages = {};
|
|
52
|
-
this._mimeTypesMap = {};
|
|
53
|
-
this._nameMap = {};
|
|
54
|
-
this._lowercaseNameMap = {};
|
|
55
|
-
if (useModesRegistry) {
|
|
56
|
-
this._initializeFromRegistry();
|
|
57
|
-
this._register(ModesRegistry.onDidChangeLanguages((m) => {
|
|
58
|
-
this._initializeFromRegistry();
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
dispose() {
|
|
63
|
-
LanguagesRegistry.instanceCount--;
|
|
64
|
-
super.dispose();
|
|
65
|
-
}
|
|
66
|
-
_initializeFromRegistry() {
|
|
67
|
-
this._languages = {};
|
|
68
|
-
this._mimeTypesMap = {};
|
|
69
|
-
this._nameMap = {};
|
|
70
|
-
this._lowercaseNameMap = {};
|
|
71
|
-
clearPlatformLanguageAssociations();
|
|
72
|
-
const desc = [].concat(ModesRegistry.getLanguages()).concat(this._dynamicLanguages);
|
|
73
|
-
this._registerLanguages(desc);
|
|
74
|
-
}
|
|
75
|
-
_registerLanguages(desc) {
|
|
76
|
-
for (const d of desc) {
|
|
77
|
-
this._registerLanguage(d);
|
|
78
|
-
}
|
|
79
|
-
// Rebuild fast path maps
|
|
80
|
-
this._mimeTypesMap = {};
|
|
81
|
-
this._nameMap = {};
|
|
82
|
-
this._lowercaseNameMap = {};
|
|
83
|
-
Object.keys(this._languages).forEach((langId) => {
|
|
84
|
-
const language = this._languages[langId];
|
|
85
|
-
if (language.name) {
|
|
86
|
-
this._nameMap[language.name] = language.identifier;
|
|
87
|
-
}
|
|
88
|
-
language.aliases.forEach((alias) => {
|
|
89
|
-
this._lowercaseNameMap[alias.toLowerCase()] = language.identifier;
|
|
90
|
-
});
|
|
91
|
-
language.mimetypes.forEach((mimetype) => {
|
|
92
|
-
this._mimeTypesMap[mimetype] = language.identifier;
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
Registry.as(Extensions.Configuration).registerOverrideIdentifiers(this.getRegisteredLanguageIds());
|
|
96
|
-
this._onDidChange.fire();
|
|
97
|
-
}
|
|
98
|
-
_registerLanguage(lang) {
|
|
99
|
-
const langId = lang.id;
|
|
100
|
-
let resolvedLanguage;
|
|
101
|
-
if (hasOwnProperty.call(this._languages, langId)) {
|
|
102
|
-
resolvedLanguage = this._languages[langId];
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
this.languageIdCodec.register(langId);
|
|
106
|
-
resolvedLanguage = {
|
|
107
|
-
identifier: langId,
|
|
108
|
-
name: null,
|
|
109
|
-
mimetypes: [],
|
|
110
|
-
aliases: [],
|
|
111
|
-
extensions: [],
|
|
112
|
-
filenames: [],
|
|
113
|
-
configurationFiles: [],
|
|
114
|
-
icons: []
|
|
115
|
-
};
|
|
116
|
-
this._languages[langId] = resolvedLanguage;
|
|
117
|
-
}
|
|
118
|
-
this._mergeLanguage(resolvedLanguage, lang);
|
|
119
|
-
}
|
|
120
|
-
_mergeLanguage(resolvedLanguage, lang) {
|
|
121
|
-
const langId = lang.id;
|
|
122
|
-
let primaryMime = null;
|
|
123
|
-
if (Array.isArray(lang.mimetypes) && lang.mimetypes.length > 0) {
|
|
124
|
-
resolvedLanguage.mimetypes.push(...lang.mimetypes);
|
|
125
|
-
primaryMime = lang.mimetypes[0];
|
|
126
|
-
}
|
|
127
|
-
if (!primaryMime) {
|
|
128
|
-
primaryMime = `text/x-${langId}`;
|
|
129
|
-
resolvedLanguage.mimetypes.push(primaryMime);
|
|
130
|
-
}
|
|
131
|
-
if (Array.isArray(lang.extensions)) {
|
|
132
|
-
if (lang.configuration) {
|
|
133
|
-
// insert first as this appears to be the 'primary' language definition
|
|
134
|
-
resolvedLanguage.extensions = lang.extensions.concat(resolvedLanguage.extensions);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
resolvedLanguage.extensions = resolvedLanguage.extensions.concat(lang.extensions);
|
|
138
|
-
}
|
|
139
|
-
for (const extension of lang.extensions) {
|
|
140
|
-
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, extension: extension }, this._warnOnOverwrite);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (Array.isArray(lang.filenames)) {
|
|
144
|
-
for (const filename of lang.filenames) {
|
|
145
|
-
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, filename: filename }, this._warnOnOverwrite);
|
|
146
|
-
resolvedLanguage.filenames.push(filename);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(lang.filenamePatterns)) {
|
|
150
|
-
for (const filenamePattern of lang.filenamePatterns) {
|
|
151
|
-
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, filepattern: filenamePattern }, this._warnOnOverwrite);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (typeof lang.firstLine === 'string' && lang.firstLine.length > 0) {
|
|
155
|
-
let firstLineRegexStr = lang.firstLine;
|
|
156
|
-
if (firstLineRegexStr.charAt(0) !== '^') {
|
|
157
|
-
firstLineRegexStr = '^' + firstLineRegexStr;
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
const firstLineRegex = new RegExp(firstLineRegexStr);
|
|
161
|
-
if (!regExpLeadsToEndlessLoop(firstLineRegex)) {
|
|
162
|
-
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, firstline: firstLineRegex }, this._warnOnOverwrite);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (err) {
|
|
166
|
-
// Most likely, the regex was bad
|
|
167
|
-
console.warn(`[${lang.id}]: Invalid regular expression \`${firstLineRegexStr}\`: `, err);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
resolvedLanguage.aliases.push(langId);
|
|
171
|
-
let langAliases = null;
|
|
172
|
-
if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
|
|
173
|
-
if (lang.aliases.length === 0) {
|
|
174
|
-
// signal that this language should not get a name
|
|
175
|
-
langAliases = [null];
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
langAliases = lang.aliases;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (langAliases !== null) {
|
|
182
|
-
for (const langAlias of langAliases) {
|
|
183
|
-
if (!langAlias || langAlias.length === 0) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
resolvedLanguage.aliases.push(langAlias);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const containsAliases = (langAliases !== null && langAliases.length > 0);
|
|
190
|
-
if (containsAliases && langAliases[0] === null) ;
|
|
191
|
-
else {
|
|
192
|
-
const bestName = (containsAliases ? langAliases[0] : null) || langId;
|
|
193
|
-
if (containsAliases || !resolvedLanguage.name) {
|
|
194
|
-
resolvedLanguage.name = bestName;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (lang.configuration) {
|
|
198
|
-
resolvedLanguage.configurationFiles.push(lang.configuration);
|
|
199
|
-
}
|
|
200
|
-
if (lang.icon) {
|
|
201
|
-
resolvedLanguage.icons.push(lang.icon);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
isRegisteredLanguageId(languageId) {
|
|
205
|
-
if (!languageId) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
return hasOwnProperty.call(this._languages, languageId);
|
|
209
|
-
}
|
|
210
|
-
getRegisteredLanguageIds() {
|
|
211
|
-
return Object.keys(this._languages);
|
|
212
|
-
}
|
|
213
|
-
getLanguageIdByLanguageName(languageName) {
|
|
214
|
-
const languageNameLower = languageName.toLowerCase();
|
|
215
|
-
if (!hasOwnProperty.call(this._lowercaseNameMap, languageNameLower)) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
return this._lowercaseNameMap[languageNameLower];
|
|
219
|
-
}
|
|
220
|
-
getLanguageIdByMimeType(mimeType) {
|
|
221
|
-
if (!mimeType) {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
if (hasOwnProperty.call(this._mimeTypesMap, mimeType)) {
|
|
225
|
-
return this._mimeTypesMap[mimeType];
|
|
226
|
-
}
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
guessLanguageIdByFilepathOrFirstLine(resource, firstLine) {
|
|
230
|
-
if (!resource && !firstLine) {
|
|
231
|
-
return [];
|
|
232
|
-
}
|
|
233
|
-
return getLanguageIds(resource, firstLine);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export { LanguageIdCodec, LanguagesRegistry };
|