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,716 @@
|
|
|
1
|
+
import { InsertTextFormat, CompletionItemKind, DocumentHighlightKind, SymbolKind, FoldingRangeKind, DiagnosticSeverity } from '../../../external/vscode-languageserver-types/lib/esm/main.js';
|
|
2
|
+
import '../../editor/browser/coreCommands.js';
|
|
3
|
+
import '../../editor/browser/widget/codeEditor/codeEditorWidget.js';
|
|
4
|
+
import '../../editor/browser/widget/diffEditor/diffEditor.contribution.js';
|
|
5
|
+
import '../../editor/contrib/anchorSelect/browser/anchorSelect.js';
|
|
6
|
+
import '../../editor/contrib/bracketMatching/browser/bracketMatching.js';
|
|
7
|
+
import '../../editor/contrib/caretOperations/browser/caretOperations.js';
|
|
8
|
+
import '../../editor/contrib/caretOperations/browser/transpose.js';
|
|
9
|
+
import '../../editor/contrib/clipboard/browser/clipboard.js';
|
|
10
|
+
import '../../editor/contrib/codeAction/browser/codeActionContributions.js';
|
|
11
|
+
import '../../editor/contrib/codelens/browser/codelensController.js';
|
|
12
|
+
import '../../editor/contrib/colorPicker/browser/colorPickerContribution.js';
|
|
13
|
+
import '../../editor/contrib/comment/browser/comment.js';
|
|
14
|
+
import '../../editor/contrib/contextmenu/browser/contextmenu.js';
|
|
15
|
+
import '../../editor/contrib/cursorUndo/browser/cursorUndo.js';
|
|
16
|
+
import '../../editor/contrib/dnd/browser/dnd.js';
|
|
17
|
+
import '../../editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js';
|
|
18
|
+
import '../../editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js';
|
|
19
|
+
import '../../editor/contrib/find/browser/findController.js';
|
|
20
|
+
import '../../editor/contrib/folding/browser/folding.js';
|
|
21
|
+
import '../../editor/contrib/fontZoom/browser/fontZoom.js';
|
|
22
|
+
import '../../editor/contrib/format/browser/formatActions.js';
|
|
23
|
+
import '../../editor/contrib/documentSymbols/browser/documentSymbols.js';
|
|
24
|
+
import '../../editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js';
|
|
25
|
+
import '../../editor/contrib/inlineProgress/browser/inlineProgress.js';
|
|
26
|
+
import '../../editor/contrib/gotoSymbol/browser/goToCommands.js';
|
|
27
|
+
import '../../editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js';
|
|
28
|
+
import '../../editor/contrib/gotoError/browser/gotoError.js';
|
|
29
|
+
import '../../editor/contrib/gpu/browser/gpuActions.js';
|
|
30
|
+
import '../../editor/contrib/hover/browser/hoverContribution.js';
|
|
31
|
+
import '../../editor/contrib/indentation/browser/indentation.js';
|
|
32
|
+
import '../../editor/contrib/inlayHints/browser/inlayHintsContribution.js';
|
|
33
|
+
import '../../editor/contrib/inPlaceReplace/browser/inPlaceReplace.js';
|
|
34
|
+
import '../../editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js';
|
|
35
|
+
import '../../editor/contrib/lineSelection/browser/lineSelection.js';
|
|
36
|
+
import '../../editor/contrib/linesOperations/browser/linesOperations.js';
|
|
37
|
+
import '../../editor/contrib/linkedEditing/browser/linkedEditing.js';
|
|
38
|
+
import '../../editor/contrib/links/browser/links.js';
|
|
39
|
+
import '../../editor/contrib/longLinesHelper/browser/longLinesHelper.js';
|
|
40
|
+
import '../../editor/contrib/middleScroll/browser/middleScroll.contribution.js';
|
|
41
|
+
import '../../editor/contrib/multicursor/browser/multicursor.js';
|
|
42
|
+
import '../../editor/contrib/parameterHints/browser/parameterHints.js';
|
|
43
|
+
import '../../editor/contrib/placeholderText/browser/placeholderText.contribution.js';
|
|
44
|
+
import '../../editor/contrib/rename/browser/rename.js';
|
|
45
|
+
import '../../editor/contrib/sectionHeaders/browser/sectionHeaders.js';
|
|
46
|
+
import '../../editor/contrib/semanticTokens/browser/documentSemanticTokens.js';
|
|
47
|
+
import '../../editor/contrib/semanticTokens/browser/viewportSemanticTokens.js';
|
|
48
|
+
import '../../editor/contrib/smartSelect/browser/smartSelect.js';
|
|
49
|
+
import '../../editor/contrib/snippet/browser/snippetController2.js';
|
|
50
|
+
import '../../editor/contrib/stickyScroll/browser/stickyScrollContribution.js';
|
|
51
|
+
import '../../editor/contrib/suggest/browser/suggestController.js';
|
|
52
|
+
import '../../editor/contrib/suggest/browser/suggestInlineCompletions.js';
|
|
53
|
+
import '../../editor/contrib/tokenization/browser/tokenization.js';
|
|
54
|
+
import '../../editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js';
|
|
55
|
+
import '../../editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js';
|
|
56
|
+
import '../../editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js';
|
|
57
|
+
import '../../editor/contrib/wordHighlighter/browser/wordHighlighter.js';
|
|
58
|
+
import '../../editor/contrib/wordOperations/browser/wordOperations.js';
|
|
59
|
+
import '../../editor/contrib/wordPartOperations/browser/wordPartOperations.js';
|
|
60
|
+
import '../../editor/contrib/readOnlyMessage/browser/contribution.js';
|
|
61
|
+
import '../../editor/contrib/diffEditorBreadcrumbs/browser/contribution.js';
|
|
62
|
+
import '../../editor/contrib/floatingMenu/browser/floatingMenu.contribution.js';
|
|
63
|
+
import '../../editor/common/standaloneStrings.js';
|
|
64
|
+
import '../../base/browser/ui/codicons/codicon/codicon.css';
|
|
65
|
+
import '../../base/browser/ui/codicons/codicon/codicon-modifiers.css';
|
|
66
|
+
import '../../editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js';
|
|
67
|
+
import '../../editor/standalone/browser/inspectTokens/inspectTokens.js';
|
|
68
|
+
import '../../editor/standalone/browser/quickAccess/standaloneHelpQuickAccess.js';
|
|
69
|
+
import '../../editor/standalone/browser/quickAccess/standaloneGotoLineQuickAccess.js';
|
|
70
|
+
import '../../editor/standalone/browser/quickAccess/standaloneGotoSymbolQuickAccess.js';
|
|
71
|
+
import '../../editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess.js';
|
|
72
|
+
import '../../editor/standalone/browser/referenceSearch/standaloneReferenceSearch.js';
|
|
73
|
+
import '../../editor/standalone/browser/toggleHighContrast/toggleHighContrast.js';
|
|
74
|
+
import { editor, Range, languages, Uri, MarkerSeverity } from '../../editor/editor.api2.js';
|
|
75
|
+
|
|
76
|
+
class DiagnosticsAdapter {
|
|
77
|
+
constructor(_languageId, _worker, configChangeEvent) {
|
|
78
|
+
this._languageId = _languageId;
|
|
79
|
+
this._worker = _worker;
|
|
80
|
+
this._disposables = [];
|
|
81
|
+
this._listener = /* @__PURE__ */ Object.create(null);
|
|
82
|
+
const onModelAdd = (model) => {
|
|
83
|
+
let modeId = model.getLanguageId();
|
|
84
|
+
if (modeId !== this._languageId) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let handle;
|
|
88
|
+
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
|
89
|
+
window.clearTimeout(handle);
|
|
90
|
+
handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
|
|
91
|
+
});
|
|
92
|
+
this._doValidate(model.uri, modeId);
|
|
93
|
+
};
|
|
94
|
+
const onModelRemoved = (model) => {
|
|
95
|
+
editor.setModelMarkers(model, this._languageId, []);
|
|
96
|
+
let uriStr = model.uri.toString();
|
|
97
|
+
let listener = this._listener[uriStr];
|
|
98
|
+
if (listener) {
|
|
99
|
+
listener.dispose();
|
|
100
|
+
delete this._listener[uriStr];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
this._disposables.push(editor.onDidCreateModel(onModelAdd));
|
|
104
|
+
this._disposables.push(editor.onWillDisposeModel(onModelRemoved));
|
|
105
|
+
this._disposables.push(
|
|
106
|
+
editor.onDidChangeModelLanguage((event) => {
|
|
107
|
+
onModelRemoved(event.model);
|
|
108
|
+
onModelAdd(event.model);
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
this._disposables.push(
|
|
112
|
+
configChangeEvent((_) => {
|
|
113
|
+
editor.getModels().forEach((model) => {
|
|
114
|
+
if (model.getLanguageId() === this._languageId) {
|
|
115
|
+
onModelRemoved(model);
|
|
116
|
+
onModelAdd(model);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
this._disposables.push({
|
|
122
|
+
dispose: () => {
|
|
123
|
+
editor.getModels().forEach(onModelRemoved);
|
|
124
|
+
for (let key in this._listener) {
|
|
125
|
+
this._listener[key].dispose();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
editor.getModels().forEach(onModelAdd);
|
|
130
|
+
}
|
|
131
|
+
dispose() {
|
|
132
|
+
this._disposables.forEach((d) => d && d.dispose());
|
|
133
|
+
this._disposables.length = 0;
|
|
134
|
+
}
|
|
135
|
+
_doValidate(resource, languageId) {
|
|
136
|
+
this._worker(resource).then((worker) => {
|
|
137
|
+
return worker.doValidation(resource.toString());
|
|
138
|
+
}).then((diagnostics) => {
|
|
139
|
+
const markers = diagnostics.map((d) => toDiagnostics(resource, d));
|
|
140
|
+
let model = editor.getModel(resource);
|
|
141
|
+
if (model && model.getLanguageId() === languageId) {
|
|
142
|
+
editor.setModelMarkers(model, languageId, markers);
|
|
143
|
+
}
|
|
144
|
+
}).then(void 0, (err) => {
|
|
145
|
+
console.error(err);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function toSeverity(lsSeverity) {
|
|
150
|
+
switch (lsSeverity) {
|
|
151
|
+
case DiagnosticSeverity.Error:
|
|
152
|
+
return MarkerSeverity.Error;
|
|
153
|
+
case DiagnosticSeverity.Warning:
|
|
154
|
+
return MarkerSeverity.Warning;
|
|
155
|
+
case DiagnosticSeverity.Information:
|
|
156
|
+
return MarkerSeverity.Info;
|
|
157
|
+
case DiagnosticSeverity.Hint:
|
|
158
|
+
return MarkerSeverity.Hint;
|
|
159
|
+
default:
|
|
160
|
+
return MarkerSeverity.Info;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function toDiagnostics(resource, diag) {
|
|
164
|
+
let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
|
|
165
|
+
return {
|
|
166
|
+
severity: toSeverity(diag.severity),
|
|
167
|
+
startLineNumber: diag.range.start.line + 1,
|
|
168
|
+
startColumn: diag.range.start.character + 1,
|
|
169
|
+
endLineNumber: diag.range.end.line + 1,
|
|
170
|
+
endColumn: diag.range.end.character + 1,
|
|
171
|
+
message: diag.message,
|
|
172
|
+
code,
|
|
173
|
+
source: diag.source
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
class CompletionAdapter {
|
|
177
|
+
constructor(_worker, _triggerCharacters) {
|
|
178
|
+
this._worker = _worker;
|
|
179
|
+
this._triggerCharacters = _triggerCharacters;
|
|
180
|
+
}
|
|
181
|
+
get triggerCharacters() {
|
|
182
|
+
return this._triggerCharacters;
|
|
183
|
+
}
|
|
184
|
+
provideCompletionItems(model, position, context, token) {
|
|
185
|
+
const resource = model.uri;
|
|
186
|
+
return this._worker(resource).then((worker) => {
|
|
187
|
+
return worker.doComplete(resource.toString(), fromPosition(position));
|
|
188
|
+
}).then((info) => {
|
|
189
|
+
if (!info) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const wordInfo = model.getWordUntilPosition(position);
|
|
193
|
+
const wordRange = new Range(
|
|
194
|
+
position.lineNumber,
|
|
195
|
+
wordInfo.startColumn,
|
|
196
|
+
position.lineNumber,
|
|
197
|
+
wordInfo.endColumn
|
|
198
|
+
);
|
|
199
|
+
const items = info.items.map((entry) => {
|
|
200
|
+
const item = {
|
|
201
|
+
label: entry.label,
|
|
202
|
+
insertText: entry.insertText || entry.label,
|
|
203
|
+
sortText: entry.sortText,
|
|
204
|
+
filterText: entry.filterText,
|
|
205
|
+
documentation: entry.documentation,
|
|
206
|
+
detail: entry.detail,
|
|
207
|
+
command: toCommand(entry.command),
|
|
208
|
+
range: wordRange,
|
|
209
|
+
kind: toCompletionItemKind(entry.kind)
|
|
210
|
+
};
|
|
211
|
+
if (entry.textEdit) {
|
|
212
|
+
if (isInsertReplaceEdit(entry.textEdit)) {
|
|
213
|
+
item.range = {
|
|
214
|
+
insert: toRange(entry.textEdit.insert),
|
|
215
|
+
replace: toRange(entry.textEdit.replace)
|
|
216
|
+
};
|
|
217
|
+
} else {
|
|
218
|
+
item.range = toRange(entry.textEdit.range);
|
|
219
|
+
}
|
|
220
|
+
item.insertText = entry.textEdit.newText;
|
|
221
|
+
}
|
|
222
|
+
if (entry.additionalTextEdits) {
|
|
223
|
+
item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
|
|
224
|
+
}
|
|
225
|
+
if (entry.insertTextFormat === InsertTextFormat.Snippet) {
|
|
226
|
+
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
227
|
+
}
|
|
228
|
+
return item;
|
|
229
|
+
});
|
|
230
|
+
return {
|
|
231
|
+
isIncomplete: info.isIncomplete,
|
|
232
|
+
suggestions: items
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function fromPosition(position) {
|
|
238
|
+
if (!position) {
|
|
239
|
+
return void 0;
|
|
240
|
+
}
|
|
241
|
+
return { character: position.column - 1, line: position.lineNumber - 1 };
|
|
242
|
+
}
|
|
243
|
+
function fromRange(range) {
|
|
244
|
+
if (!range) {
|
|
245
|
+
return void 0;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
start: {
|
|
249
|
+
line: range.startLineNumber - 1,
|
|
250
|
+
character: range.startColumn - 1
|
|
251
|
+
},
|
|
252
|
+
end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function toRange(range) {
|
|
256
|
+
if (!range) {
|
|
257
|
+
return void 0;
|
|
258
|
+
}
|
|
259
|
+
return new Range(
|
|
260
|
+
range.start.line + 1,
|
|
261
|
+
range.start.character + 1,
|
|
262
|
+
range.end.line + 1,
|
|
263
|
+
range.end.character + 1
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function isInsertReplaceEdit(edit) {
|
|
267
|
+
return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
|
|
268
|
+
}
|
|
269
|
+
function toCompletionItemKind(kind) {
|
|
270
|
+
const mItemKind = languages.CompletionItemKind;
|
|
271
|
+
switch (kind) {
|
|
272
|
+
case CompletionItemKind.Text:
|
|
273
|
+
return mItemKind.Text;
|
|
274
|
+
case CompletionItemKind.Method:
|
|
275
|
+
return mItemKind.Method;
|
|
276
|
+
case CompletionItemKind.Function:
|
|
277
|
+
return mItemKind.Function;
|
|
278
|
+
case CompletionItemKind.Constructor:
|
|
279
|
+
return mItemKind.Constructor;
|
|
280
|
+
case CompletionItemKind.Field:
|
|
281
|
+
return mItemKind.Field;
|
|
282
|
+
case CompletionItemKind.Variable:
|
|
283
|
+
return mItemKind.Variable;
|
|
284
|
+
case CompletionItemKind.Class:
|
|
285
|
+
return mItemKind.Class;
|
|
286
|
+
case CompletionItemKind.Interface:
|
|
287
|
+
return mItemKind.Interface;
|
|
288
|
+
case CompletionItemKind.Module:
|
|
289
|
+
return mItemKind.Module;
|
|
290
|
+
case CompletionItemKind.Property:
|
|
291
|
+
return mItemKind.Property;
|
|
292
|
+
case CompletionItemKind.Unit:
|
|
293
|
+
return mItemKind.Unit;
|
|
294
|
+
case CompletionItemKind.Value:
|
|
295
|
+
return mItemKind.Value;
|
|
296
|
+
case CompletionItemKind.Enum:
|
|
297
|
+
return mItemKind.Enum;
|
|
298
|
+
case CompletionItemKind.Keyword:
|
|
299
|
+
return mItemKind.Keyword;
|
|
300
|
+
case CompletionItemKind.Snippet:
|
|
301
|
+
return mItemKind.Snippet;
|
|
302
|
+
case CompletionItemKind.Color:
|
|
303
|
+
return mItemKind.Color;
|
|
304
|
+
case CompletionItemKind.File:
|
|
305
|
+
return mItemKind.File;
|
|
306
|
+
case CompletionItemKind.Reference:
|
|
307
|
+
return mItemKind.Reference;
|
|
308
|
+
}
|
|
309
|
+
return mItemKind.Property;
|
|
310
|
+
}
|
|
311
|
+
function toTextEdit(textEdit) {
|
|
312
|
+
if (!textEdit) {
|
|
313
|
+
return void 0;
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
range: toRange(textEdit.range),
|
|
317
|
+
text: textEdit.newText
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function toCommand(c) {
|
|
321
|
+
return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
|
|
322
|
+
}
|
|
323
|
+
class HoverAdapter {
|
|
324
|
+
constructor(_worker) {
|
|
325
|
+
this._worker = _worker;
|
|
326
|
+
}
|
|
327
|
+
provideHover(model, position, token) {
|
|
328
|
+
let resource = model.uri;
|
|
329
|
+
return this._worker(resource).then((worker) => {
|
|
330
|
+
return worker.doHover(resource.toString(), fromPosition(position));
|
|
331
|
+
}).then((info) => {
|
|
332
|
+
if (!info) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
range: toRange(info.range),
|
|
337
|
+
contents: toMarkedStringArray(info.contents)
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function isMarkupContent(thing) {
|
|
343
|
+
return thing && typeof thing === "object" && typeof thing.kind === "string";
|
|
344
|
+
}
|
|
345
|
+
function toMarkdownString(entry) {
|
|
346
|
+
if (typeof entry === "string") {
|
|
347
|
+
return {
|
|
348
|
+
value: entry
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (isMarkupContent(entry)) {
|
|
352
|
+
if (entry.kind === "plaintext") {
|
|
353
|
+
return {
|
|
354
|
+
value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
value: entry.value
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
|
|
362
|
+
}
|
|
363
|
+
function toMarkedStringArray(contents) {
|
|
364
|
+
if (!contents) {
|
|
365
|
+
return void 0;
|
|
366
|
+
}
|
|
367
|
+
if (Array.isArray(contents)) {
|
|
368
|
+
return contents.map(toMarkdownString);
|
|
369
|
+
}
|
|
370
|
+
return [toMarkdownString(contents)];
|
|
371
|
+
}
|
|
372
|
+
class DocumentHighlightAdapter {
|
|
373
|
+
constructor(_worker) {
|
|
374
|
+
this._worker = _worker;
|
|
375
|
+
}
|
|
376
|
+
provideDocumentHighlights(model, position, token) {
|
|
377
|
+
const resource = model.uri;
|
|
378
|
+
return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
|
|
379
|
+
if (!entries) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
return entries.map((entry) => {
|
|
383
|
+
return {
|
|
384
|
+
range: toRange(entry.range),
|
|
385
|
+
kind: toDocumentHighlightKind(entry.kind)
|
|
386
|
+
};
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function toDocumentHighlightKind(kind) {
|
|
392
|
+
switch (kind) {
|
|
393
|
+
case DocumentHighlightKind.Read:
|
|
394
|
+
return languages.DocumentHighlightKind.Read;
|
|
395
|
+
case DocumentHighlightKind.Write:
|
|
396
|
+
return languages.DocumentHighlightKind.Write;
|
|
397
|
+
case DocumentHighlightKind.Text:
|
|
398
|
+
return languages.DocumentHighlightKind.Text;
|
|
399
|
+
}
|
|
400
|
+
return languages.DocumentHighlightKind.Text;
|
|
401
|
+
}
|
|
402
|
+
class DefinitionAdapter {
|
|
403
|
+
constructor(_worker) {
|
|
404
|
+
this._worker = _worker;
|
|
405
|
+
}
|
|
406
|
+
provideDefinition(model, position, token) {
|
|
407
|
+
const resource = model.uri;
|
|
408
|
+
return this._worker(resource).then((worker) => {
|
|
409
|
+
return worker.findDefinition(resource.toString(), fromPosition(position));
|
|
410
|
+
}).then((definition) => {
|
|
411
|
+
if (!definition) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
return [toLocation(definition)];
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function toLocation(location) {
|
|
419
|
+
return {
|
|
420
|
+
uri: Uri.parse(location.uri),
|
|
421
|
+
range: toRange(location.range)
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
class ReferenceAdapter {
|
|
425
|
+
constructor(_worker) {
|
|
426
|
+
this._worker = _worker;
|
|
427
|
+
}
|
|
428
|
+
provideReferences(model, position, context, token) {
|
|
429
|
+
const resource = model.uri;
|
|
430
|
+
return this._worker(resource).then((worker) => {
|
|
431
|
+
return worker.findReferences(resource.toString(), fromPosition(position));
|
|
432
|
+
}).then((entries) => {
|
|
433
|
+
if (!entries) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
return entries.map(toLocation);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
class RenameAdapter {
|
|
441
|
+
constructor(_worker) {
|
|
442
|
+
this._worker = _worker;
|
|
443
|
+
}
|
|
444
|
+
provideRenameEdits(model, position, newName, token) {
|
|
445
|
+
const resource = model.uri;
|
|
446
|
+
return this._worker(resource).then((worker) => {
|
|
447
|
+
return worker.doRename(resource.toString(), fromPosition(position), newName);
|
|
448
|
+
}).then((edit) => {
|
|
449
|
+
return toWorkspaceEdit(edit);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function toWorkspaceEdit(edit) {
|
|
454
|
+
if (!edit || !edit.changes) {
|
|
455
|
+
return void 0;
|
|
456
|
+
}
|
|
457
|
+
let resourceEdits = [];
|
|
458
|
+
for (let uri in edit.changes) {
|
|
459
|
+
const _uri = Uri.parse(uri);
|
|
460
|
+
for (let e of edit.changes[uri]) {
|
|
461
|
+
resourceEdits.push({
|
|
462
|
+
resource: _uri,
|
|
463
|
+
versionId: void 0,
|
|
464
|
+
textEdit: {
|
|
465
|
+
range: toRange(e.range),
|
|
466
|
+
text: e.newText
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
edits: resourceEdits
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
class DocumentSymbolAdapter {
|
|
476
|
+
constructor(_worker) {
|
|
477
|
+
this._worker = _worker;
|
|
478
|
+
}
|
|
479
|
+
provideDocumentSymbols(model, token) {
|
|
480
|
+
const resource = model.uri;
|
|
481
|
+
return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
|
|
482
|
+
if (!items) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
return items.map((item) => {
|
|
486
|
+
if (isDocumentSymbol(item)) {
|
|
487
|
+
return toDocumentSymbol(item);
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
name: item.name,
|
|
491
|
+
detail: "",
|
|
492
|
+
containerName: item.containerName,
|
|
493
|
+
kind: toSymbolKind(item.kind),
|
|
494
|
+
range: toRange(item.location.range),
|
|
495
|
+
selectionRange: toRange(item.location.range),
|
|
496
|
+
tags: []
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function isDocumentSymbol(symbol) {
|
|
503
|
+
return "children" in symbol;
|
|
504
|
+
}
|
|
505
|
+
function toDocumentSymbol(symbol) {
|
|
506
|
+
return {
|
|
507
|
+
name: symbol.name,
|
|
508
|
+
detail: symbol.detail ?? "",
|
|
509
|
+
kind: toSymbolKind(symbol.kind),
|
|
510
|
+
range: toRange(symbol.range),
|
|
511
|
+
selectionRange: toRange(symbol.selectionRange),
|
|
512
|
+
tags: symbol.tags ?? [],
|
|
513
|
+
children: (symbol.children ?? []).map((item) => toDocumentSymbol(item))
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function toSymbolKind(kind) {
|
|
517
|
+
let mKind = languages.SymbolKind;
|
|
518
|
+
switch (kind) {
|
|
519
|
+
case SymbolKind.File:
|
|
520
|
+
return mKind.File;
|
|
521
|
+
case SymbolKind.Module:
|
|
522
|
+
return mKind.Module;
|
|
523
|
+
case SymbolKind.Namespace:
|
|
524
|
+
return mKind.Namespace;
|
|
525
|
+
case SymbolKind.Package:
|
|
526
|
+
return mKind.Package;
|
|
527
|
+
case SymbolKind.Class:
|
|
528
|
+
return mKind.Class;
|
|
529
|
+
case SymbolKind.Method:
|
|
530
|
+
return mKind.Method;
|
|
531
|
+
case SymbolKind.Property:
|
|
532
|
+
return mKind.Property;
|
|
533
|
+
case SymbolKind.Field:
|
|
534
|
+
return mKind.Field;
|
|
535
|
+
case SymbolKind.Constructor:
|
|
536
|
+
return mKind.Constructor;
|
|
537
|
+
case SymbolKind.Enum:
|
|
538
|
+
return mKind.Enum;
|
|
539
|
+
case SymbolKind.Interface:
|
|
540
|
+
return mKind.Interface;
|
|
541
|
+
case SymbolKind.Function:
|
|
542
|
+
return mKind.Function;
|
|
543
|
+
case SymbolKind.Variable:
|
|
544
|
+
return mKind.Variable;
|
|
545
|
+
case SymbolKind.Constant:
|
|
546
|
+
return mKind.Constant;
|
|
547
|
+
case SymbolKind.String:
|
|
548
|
+
return mKind.String;
|
|
549
|
+
case SymbolKind.Number:
|
|
550
|
+
return mKind.Number;
|
|
551
|
+
case SymbolKind.Boolean:
|
|
552
|
+
return mKind.Boolean;
|
|
553
|
+
case SymbolKind.Array:
|
|
554
|
+
return mKind.Array;
|
|
555
|
+
}
|
|
556
|
+
return mKind.Function;
|
|
557
|
+
}
|
|
558
|
+
class DocumentLinkAdapter {
|
|
559
|
+
constructor(_worker) {
|
|
560
|
+
this._worker = _worker;
|
|
561
|
+
}
|
|
562
|
+
provideLinks(model, token) {
|
|
563
|
+
const resource = model.uri;
|
|
564
|
+
return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
|
|
565
|
+
if (!items) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
links: items.map((item) => ({
|
|
570
|
+
range: toRange(item.range),
|
|
571
|
+
url: item.target
|
|
572
|
+
}))
|
|
573
|
+
};
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
class DocumentFormattingEditProvider {
|
|
578
|
+
constructor(_worker) {
|
|
579
|
+
this._worker = _worker;
|
|
580
|
+
}
|
|
581
|
+
provideDocumentFormattingEdits(model, options, token) {
|
|
582
|
+
const resource = model.uri;
|
|
583
|
+
return this._worker(resource).then((worker) => {
|
|
584
|
+
return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
|
|
585
|
+
if (!edits || edits.length === 0) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
return edits.map(toTextEdit);
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
class DocumentRangeFormattingEditProvider {
|
|
594
|
+
constructor(_worker) {
|
|
595
|
+
this._worker = _worker;
|
|
596
|
+
this.canFormatMultipleRanges = false;
|
|
597
|
+
}
|
|
598
|
+
provideDocumentRangeFormattingEdits(model, range, options, token) {
|
|
599
|
+
const resource = model.uri;
|
|
600
|
+
return this._worker(resource).then((worker) => {
|
|
601
|
+
return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
|
|
602
|
+
if (!edits || edits.length === 0) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
return edits.map(toTextEdit);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function fromFormattingOptions(options) {
|
|
611
|
+
return {
|
|
612
|
+
tabSize: options.tabSize,
|
|
613
|
+
insertSpaces: options.insertSpaces
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
class DocumentColorAdapter {
|
|
617
|
+
constructor(_worker) {
|
|
618
|
+
this._worker = _worker;
|
|
619
|
+
}
|
|
620
|
+
provideDocumentColors(model, token) {
|
|
621
|
+
const resource = model.uri;
|
|
622
|
+
return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
|
|
623
|
+
if (!infos) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
return infos.map((item) => ({
|
|
627
|
+
color: item.color,
|
|
628
|
+
range: toRange(item.range)
|
|
629
|
+
}));
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
provideColorPresentations(model, info, token) {
|
|
633
|
+
const resource = model.uri;
|
|
634
|
+
return this._worker(resource).then(
|
|
635
|
+
(worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))
|
|
636
|
+
).then((presentations) => {
|
|
637
|
+
if (!presentations) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
return presentations.map((presentation) => {
|
|
641
|
+
let item = {
|
|
642
|
+
label: presentation.label
|
|
643
|
+
};
|
|
644
|
+
if (presentation.textEdit) {
|
|
645
|
+
item.textEdit = toTextEdit(presentation.textEdit);
|
|
646
|
+
}
|
|
647
|
+
if (presentation.additionalTextEdits) {
|
|
648
|
+
item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
|
|
649
|
+
}
|
|
650
|
+
return item;
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
class FoldingRangeAdapter {
|
|
656
|
+
constructor(_worker) {
|
|
657
|
+
this._worker = _worker;
|
|
658
|
+
}
|
|
659
|
+
provideFoldingRanges(model, context, token) {
|
|
660
|
+
const resource = model.uri;
|
|
661
|
+
return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
|
|
662
|
+
if (!ranges) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
return ranges.map((range) => {
|
|
666
|
+
const result = {
|
|
667
|
+
start: range.startLine + 1,
|
|
668
|
+
end: range.endLine + 1
|
|
669
|
+
};
|
|
670
|
+
if (typeof range.kind !== "undefined") {
|
|
671
|
+
result.kind = toFoldingRangeKind(range.kind);
|
|
672
|
+
}
|
|
673
|
+
return result;
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function toFoldingRangeKind(kind) {
|
|
679
|
+
switch (kind) {
|
|
680
|
+
case FoldingRangeKind.Comment:
|
|
681
|
+
return languages.FoldingRangeKind.Comment;
|
|
682
|
+
case FoldingRangeKind.Imports:
|
|
683
|
+
return languages.FoldingRangeKind.Imports;
|
|
684
|
+
case FoldingRangeKind.Region:
|
|
685
|
+
return languages.FoldingRangeKind.Region;
|
|
686
|
+
}
|
|
687
|
+
return void 0;
|
|
688
|
+
}
|
|
689
|
+
class SelectionRangeAdapter {
|
|
690
|
+
constructor(_worker) {
|
|
691
|
+
this._worker = _worker;
|
|
692
|
+
}
|
|
693
|
+
provideSelectionRanges(model, positions, token) {
|
|
694
|
+
const resource = model.uri;
|
|
695
|
+
return this._worker(resource).then(
|
|
696
|
+
(worker) => worker.getSelectionRanges(
|
|
697
|
+
resource.toString(),
|
|
698
|
+
positions.map(fromPosition)
|
|
699
|
+
)
|
|
700
|
+
).then((selectionRanges) => {
|
|
701
|
+
if (!selectionRanges) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
return selectionRanges.map((selectionRange) => {
|
|
705
|
+
const result = [];
|
|
706
|
+
while (selectionRange) {
|
|
707
|
+
result.push({ range: toRange(selectionRange.range) });
|
|
708
|
+
selectionRange = selectionRange.parent;
|
|
709
|
+
}
|
|
710
|
+
return result;
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export { CompletionAdapter, DefinitionAdapter, DiagnosticsAdapter, DocumentColorAdapter, DocumentFormattingEditProvider, DocumentHighlightAdapter, DocumentLinkAdapter, DocumentRangeFormattingEditProvider, DocumentSymbolAdapter, FoldingRangeAdapter, HoverAdapter, ReferenceAdapter, RenameAdapter, SelectionRangeAdapter, fromPosition, fromRange, toRange, toTextEdit };
|