monaco-editor 0.56.0-dev-20260113 → 0.56.0-dev-20260116
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/dev/vs/assets/{css.worker-B4u8BWhg.js → css.worker-C1mHXZTT.js} +55 -55
- package/dev/vs/assets/{editor.worker-BCw6uAjg.js → editor.worker-DMuwmZqI.js} +55 -55
- package/dev/vs/assets/{editorWebWorkerMain-CeIXdrW0.js → editorWebWorkerMain-BF9MKtzx.js} +55 -55
- package/dev/vs/assets/{html.worker-B-Jcoci3.js → html.worker-CnU9mi9l.js} +55 -55
- package/dev/vs/assets/{json.worker-BpmVTt7n.js → json.worker-CnKP0LWf.js} +55 -55
- package/dev/vs/assets/{ts.worker-CPlP8nZ0.js → ts.worker-Cw4JXdL0.js} +55 -55
- package/dev/vs/basic-languages/monaco.contribution.js +18 -18
- package/dev/vs/css.worker-B9TJsr2Z.js +5 -0
- package/dev/vs/{cssMode-BEukq5u0.js → cssMode-DHV9sMQi.js} +2 -6
- package/dev/vs/editor/editor.main.css +37 -23
- package/dev/vs/editor/editor.main.js +10 -3178
- package/dev/vs/editor/editor.worker.js +1 -1
- package/dev/vs/{editor-BD6q8TI1.js → editor-BTEbNxE2.js} +703 -586
- package/dev/vs/editor.js +1 -1
- package/dev/vs/{editorWorkerHost-C6qzpbiG.js → editorWorkerHost--0eDLpc-.js} +57 -57
- package/dev/vs/{freemarker2-lOxAB__C.js → freemarker2-Dq_j1fXA.js} +1 -1
- package/dev/vs/{handlebars-PlqQ1WFo.js → handlebars-DPZdWYjc.js} +1 -1
- package/dev/vs/{html-BHf3H_zO.js → html-DHy2Qtlf.js} +1 -1
- package/dev/vs/html.worker-B4TnFQEA.js +5 -0
- package/dev/vs/{htmlMode-CAbblI08.js → htmlMode-CK4CuwW5.js} +2 -6
- package/dev/vs/index-C4qZmtMk.js +3169 -0
- package/dev/vs/index.js +23 -0
- package/dev/vs/{initialize-BCWs-0Hl.js → initialize-Bfvoywyr.js} +1 -1
- package/dev/vs/{javascript-BfBKHXS5.js → javascript-Bbk-b6fJ.js} +1 -1
- package/dev/vs/json.worker-C2LEGBju.js +5 -0
- package/dev/vs/{jsonMode-DjCUBCJf.js → jsonMode-DZUKN9F2.js} +2 -6
- package/dev/vs/language/css/css.worker.js +1 -1
- package/dev/vs/language/css/monaco.contribution.js +1 -1
- package/dev/vs/language/html/html.worker.js +1 -1
- package/dev/vs/language/html/monaco.contribution.js +1 -1
- package/dev/vs/language/json/json.worker.js +1 -1
- package/dev/vs/language/json/monaco.contribution.js +1 -1
- package/dev/vs/language/typescript/monaco.contribution.js +1 -1
- package/dev/vs/language/typescript/ts.worker.js +1 -1
- package/dev/vs/{liquid-ru5qQvh3.js → liquid-DJoh8neA.js} +1 -1
- package/dev/vs/{lspLanguageFeatures-qP8Sjc4-.js → lspLanguageFeatures-C6AyKVlZ.js} +1 -1
- package/dev/vs/{mdx-LPJIIjTi.js → mdx-Bc9Wi7Yp.js} +1 -1
- package/dev/vs/{monaco.contribution-Cn4sp0rT.js → monaco.contribution-Dioy2gsL.js} +2 -2
- package/dev/vs/{monaco.contribution-BUS19PbW.js → monaco.contribution-Dp0abtES.js} +2 -2
- package/dev/vs/{monaco.contribution-Dh6bcJ62.js → monaco.contribution-QjKN2IAC.js} +2 -2
- package/dev/vs/{monaco.contribution-CAodrNii.js → monaco.contribution-ebA6cx7_.js} +2 -2
- package/dev/vs/nls/lang/cs.js +2 -2
- package/dev/vs/nls/lang/de.js +2 -2
- package/dev/vs/nls/lang/es.js +2 -2
- package/dev/vs/nls/lang/fr.js +2 -2
- package/dev/vs/nls/lang/it.js +2 -2
- package/dev/vs/nls/lang/ja.js +2 -2
- package/dev/vs/nls/lang/ko.js +2 -2
- package/dev/vs/nls/lang/pl.js +2 -2
- package/dev/vs/nls/lang/pt-br.js +2 -2
- package/dev/vs/nls/lang/ru.js +2 -2
- package/dev/vs/nls/lang/tr.js +2 -2
- package/dev/vs/nls/lang/zh-cn.js +2 -2
- package/dev/vs/nls/lang/zh-tw.js +2 -2
- package/dev/vs/{python-C3STc4Jq.js → python-T13bwMqv.js} +1 -1
- package/dev/vs/{razor-C_h91a99.js → razor-PnbkQS-a.js} +1 -1
- package/dev/vs/{toggleHighContrast-BYijNqvT.js → toggleHighContrast-BT_lXcSg.js} +792 -753
- package/dev/vs/ts.worker-CArJhH03.js +5 -0
- package/dev/vs/{tsMode-LmHd2bVJ.js → tsMode-dEZrXjQR.js} +2 -6
- package/dev/vs/{typescript-DrD88DNo.js → typescript-C7a_eRmw.js} +1 -1
- package/dev/vs/{workers-jwm1wsc0.js → workers-jA_HWRt3.js} +1 -1
- package/dev/vs/{xml-CIdZXDjG.js → xml-E9G9gloz.js} +1 -1
- package/dev/vs/{yaml-F0FhO8OI.js → yaml-2TR38CXi.js} +1 -1
- package/esm/vs/base/browser/domStylesheets.js +10 -19
- package/esm/vs/base/browser/ui/button/button.css +14 -5
- package/esm/vs/base/browser/ui/button/button.js +1 -0
- package/esm/vs/base/browser/ui/inputbox/inputBox.css +1 -1
- package/esm/vs/base/browser/ui/scrollbar/scrollbarArrow.js +1 -1
- package/esm/vs/base/browser/ui/selectBox/selectBox.css +2 -2
- package/esm/vs/base/browser/ui/selectBox/selectBoxCustom.css +1 -1
- package/esm/vs/base/browser/ui/toolbar/toolbar.css +14 -2
- package/esm/vs/base/browser/ui/toolbar/toolbar.js +42 -15
- package/esm/vs/base/common/async.js +1 -1
- package/esm/vs/base/common/network.js +2 -0
- package/esm/vs/base/common/observableInternal/reactions/autorun.js +1 -1
- package/esm/vs/base/common/validation.js +12 -1
- package/esm/vs/editor/browser/gpu/viewGpuContext.js +1 -1
- package/esm/vs/editor/browser/observableCodeEditor.js +3 -3
- package/esm/vs/editor/browser/view/viewController.js +66 -1
- package/esm/vs/editor/browser/viewParts/minimap/minimap.js +9 -9
- package/esm/vs/editor/browser/viewParts/rulers/rulers.css +1 -0
- package/esm/vs/editor/browser/viewParts/rulers/rulers.js +1 -1
- package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js +4 -0
- package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/diffEditorViewZones.js +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditor.contribution.js +1 -1
- package/esm/vs/editor/common/core/editorColorRegistry.js +35 -34
- package/esm/vs/editor/common/editorContextKeys.js +48 -48
- package/esm/vs/editor/common/languages/modesRegistry.js +1 -1
- package/esm/vs/editor/common/languages/supports/tokenization.js +12 -1
- package/esm/vs/editor/common/languages.js +56 -56
- package/esm/vs/editor/common/model/editStack.js +1 -1
- package/esm/vs/editor/common/model/textModelSearch.js +1 -1
- package/esm/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.js +4 -4
- package/esm/vs/editor/common/model/tokens/treeSitter/treeSitterTokenizationImpl.js +1 -1
- package/esm/vs/editor/common/standaloneStrings.js +11 -11
- package/esm/vs/editor/common/textModelEvents.js +2 -2
- package/esm/vs/editor/common/viewLayout/viewLineRenderer.js +2 -2
- package/esm/vs/editor/common/viewModel/viewModelImpl.js +3 -3
- package/esm/vs/editor/contrib/anchorSelect/browser/anchorSelect.js +6 -6
- package/esm/vs/editor/contrib/bracketMatching/browser/bracketMatching.js +20 -8
- package/esm/vs/editor/contrib/caretOperations/browser/caretOperations.js +2 -2
- package/esm/vs/editor/contrib/caretOperations/browser/transpose.js +1 -1
- package/esm/vs/editor/contrib/clipboard/browser/clipboard.js +17 -17
- package/esm/vs/editor/contrib/codeAction/browser/codeAction.js +1 -1
- package/esm/vs/editor/contrib/codeAction/browser/codeActionCommands.js +29 -29
- package/esm/vs/editor/contrib/codeAction/browser/codeActionContributions.js +3 -3
- package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js +3 -3
- package/esm/vs/editor/contrib/codeAction/browser/codeActionMenu.js +8 -8
- package/esm/vs/editor/contrib/codeAction/browser/lightBulbWidget.js +9 -9
- package/esm/vs/editor/contrib/codelens/browser/codelensController.js +2 -2
- package/esm/vs/editor/contrib/colorPicker/browser/colorPickerParts/colorPickerCloseButton.js +1 -1
- package/esm/vs/editor/contrib/colorPicker/browser/colorPickerParts/colorPickerHeader.js +1 -1
- package/esm/vs/editor/contrib/colorPicker/browser/hoverColorPicker/hoverColorPickerParticipant.js +1 -1
- package/esm/vs/editor/contrib/colorPicker/browser/standaloneColorPicker/standaloneColorPickerActions.js +7 -7
- package/esm/vs/editor/contrib/comment/browser/comment.js +6 -6
- package/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js +10 -10
- package/esm/vs/editor/contrib/cursorUndo/browser/cursorUndo.js +2 -2
- package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +4 -4
- package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +9 -9
- package/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +8 -8
- package/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +3 -3
- package/esm/vs/editor/contrib/dropOrPasteInto/browser/postEditWidget.js +2 -2
- package/esm/vs/editor/contrib/editorState/browser/keybindingCancellation.js +1 -1
- package/esm/vs/editor/contrib/find/browser/findController.js +16 -16
- package/esm/vs/editor/contrib/find/browser/findWidget.js +26 -26
- package/esm/vs/editor/contrib/folding/browser/folding.js +20 -20
- package/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +9 -9
- package/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +3 -3
- package/esm/vs/editor/contrib/format/browser/formatActions.js +2 -2
- package/esm/vs/editor/contrib/gotoError/browser/gotoError.js +8 -8
- package/esm/vs/editor/contrib/gotoError/browser/gotoErrorWidget.js +14 -14
- package/esm/vs/editor/contrib/gotoSymbol/browser/goToCommands.js +40 -40
- package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js +1 -1
- package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesController.js +3 -3
- package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesTree.js +3 -3
- package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.js +3 -3
- package/esm/vs/editor/contrib/gotoSymbol/browser/referencesModel.js +8 -8
- package/esm/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.js +3 -3
- package/esm/vs/editor/contrib/gpu/browser/gpuActions.js +4 -4
- package/esm/vs/editor/contrib/hover/browser/contentHoverController.js +8 -3
- package/esm/vs/editor/contrib/hover/browser/glyphHoverController.js +7 -1
- package/esm/vs/editor/contrib/hover/browser/hoverActionIds.js +2 -2
- package/esm/vs/editor/contrib/hover/browser/hoverActions.js +24 -24
- package/esm/vs/editor/contrib/hover/browser/hoverCopyButton.js +2 -2
- package/esm/vs/editor/contrib/hover/browser/hoverUtils.js +10 -5
- package/esm/vs/editor/contrib/hover/browser/markdownHoverParticipant.js +7 -7
- package/esm/vs/editor/contrib/hover/browser/markerHoverParticipant.js +5 -5
- package/esm/vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace.js +2 -2
- package/esm/vs/editor/contrib/indentation/browser/indentation.js +20 -20
- package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsHover.js +8 -8
- package/esm/vs/editor/contrib/inlineCompletions/browser/controller/commands.js +24 -22
- package/esm/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionContextKeys.js +13 -13
- package/esm/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.js +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/hintsWidget/hoverParticipant.js +2 -2
- package/esm/vs/editor/contrib/inlineCompletions/browser/hintsWidget/inlineCompletionsHintsWidget.js +6 -6
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +7 -4
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/renameSymbolProcessor.js +2 -2
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorMenu.js +6 -6
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsWordReplacementView.js +3 -3
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/theme.js +20 -20
- package/esm/vs/editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js +1 -1
- package/esm/vs/editor/contrib/lineSelection/browser/lineSelection.js +1 -1
- package/esm/vs/editor/contrib/linesOperations/browser/linesOperations.js +31 -31
- package/esm/vs/editor/contrib/linkedEditing/browser/linkedEditing.js +2 -2
- package/esm/vs/editor/contrib/links/browser/links.js +10 -10
- package/esm/vs/editor/contrib/message/browser/messageController.js +1 -1
- package/esm/vs/editor/contrib/multicursor/browser/multicursor.js +22 -22
- package/esm/vs/editor/contrib/parameterHints/browser/parameterHints.js +1 -1
- package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js +4 -4
- package/esm/vs/editor/contrib/peekView/browser/peekView.js +18 -18
- package/esm/vs/editor/contrib/placeholderText/browser/placeholderText.contribution.js +1 -1
- package/esm/vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess.js +10 -10
- package/esm/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess.js +32 -32
- package/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +2 -2
- package/esm/vs/editor/contrib/rename/browser/rename.js +11 -11
- package/esm/vs/editor/contrib/rename/browser/renameWidget.css +1 -1
- package/esm/vs/editor/contrib/rename/browser/renameWidget.js +7 -7
- package/esm/vs/editor/contrib/smartSelect/browser/smartSelect.js +4 -4
- package/esm/vs/editor/contrib/snippet/browser/snippetController2.js +4 -4
- package/esm/vs/editor/contrib/snippet/browser/snippetVariables.js +4 -4
- package/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollActions.js +11 -11
- package/esm/vs/editor/contrib/suggest/browser/suggest.js +9 -9
- package/esm/vs/editor/contrib/suggest/browser/suggestController.js +11 -11
- package/esm/vs/editor/contrib/suggest/browser/suggestWidget.js +17 -17
- package/esm/vs/editor/contrib/suggest/browser/suggestWidgetDetails.js +2 -2
- package/esm/vs/editor/contrib/suggest/browser/suggestWidgetRenderer.js +2 -2
- package/esm/vs/editor/contrib/suggest/browser/wordContextKey.js +1 -1
- package/esm/vs/editor/contrib/symbolIcons/browser/symbolIcons.js +33 -33
- package/esm/vs/editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js +4 -4
- package/esm/vs/editor/contrib/tokenization/browser/tokenization.js +1 -1
- package/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +1 -1
- package/esm/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js +24 -24
- package/esm/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js +5 -5
- package/esm/vs/editor/contrib/wordHighlighter/browser/highlightDecorations.js +9 -9
- package/esm/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.js +3 -3
- package/esm/vs/editor/contrib/wordOperations/browser/wordOperations.js +3 -3
- package/esm/vs/editor/editor.api.d.ts +23 -1
- package/esm/vs/editor/standalone/browser/services/standaloneWebWorkerService.js +4 -0
- package/esm/vs/features/anchorSelect/register.d.ts +2 -1
- package/esm/vs/features/bracketMatching/register.d.ts +2 -1
- package/esm/vs/features/caretOperations/register.d.ts +2 -1
- package/esm/vs/features/clipboard/register.d.ts +2 -1
- package/esm/vs/features/codeAction/register.d.ts +2 -1
- package/esm/vs/features/codeEditor/register.d.ts +2 -1
- package/esm/vs/features/codelens/register.d.ts +2 -1
- package/esm/vs/features/codicon/register.d.ts +2 -1
- package/esm/vs/features/colorPicker/register.d.ts +2 -1
- package/esm/vs/features/comment/register.d.ts +2 -1
- package/esm/vs/features/contextmenu/register.d.ts +2 -1
- package/esm/vs/features/cursorUndo/register.d.ts +2 -1
- package/esm/vs/features/diffEditor/register.d.ts +2 -1
- package/esm/vs/features/diffEditorBreadcrumbs/register.d.ts +2 -1
- package/esm/vs/features/dnd/register.d.ts +2 -1
- package/esm/vs/features/documentSymbols/register.d.ts +2 -1
- package/esm/vs/features/dropOrPasteInto/register.d.ts +2 -1
- package/esm/vs/features/find/register.d.ts +2 -1
- package/esm/vs/features/floatingMenu/register.d.ts +2 -1
- package/esm/vs/features/folding/register.d.ts +2 -1
- package/esm/vs/features/fontZoom/register.d.ts +2 -1
- package/esm/vs/features/format/register.d.ts +2 -1
- package/esm/vs/features/gotoError/register.d.ts +2 -1
- package/esm/vs/features/gotoLine/register.d.ts +2 -1
- package/esm/vs/features/gotoSymbol/register.d.ts +2 -1
- package/esm/vs/features/gpu/register.d.ts +2 -1
- package/esm/vs/features/hover/register.d.ts +2 -1
- package/esm/vs/features/iPadShowKeyboard/register.d.ts +2 -1
- package/esm/vs/features/inPlaceReplace/register.d.ts +2 -1
- package/esm/vs/features/indentation/register.d.ts +2 -1
- package/esm/vs/features/inlayHints/register.d.ts +2 -1
- package/esm/vs/features/inlineCompletions/register.d.ts +2 -1
- package/esm/vs/features/inlineProgress/register.d.ts +2 -1
- package/esm/vs/features/insertFinalNewLine/register.d.ts +2 -1
- package/esm/vs/features/inspectTokens/register.d.ts +2 -1
- package/esm/vs/features/lineSelection/register.d.ts +2 -1
- package/esm/vs/features/linesOperations/register.d.ts +2 -1
- package/esm/vs/features/linkedEditing/register.d.ts +2 -1
- package/esm/vs/features/links/register.d.ts +2 -1
- package/esm/vs/features/longLinesHelper/register.d.ts +2 -1
- package/esm/vs/features/middleScroll/register.d.ts +2 -1
- package/esm/vs/features/multicursor/register.d.ts +2 -1
- package/esm/vs/features/parameterHints/register.d.ts +2 -1
- package/esm/vs/features/placeholderText/register.d.ts +2 -1
- package/esm/vs/features/quickCommand/register.d.ts +2 -1
- package/esm/vs/features/quickHelp/register.d.ts +2 -1
- package/esm/vs/features/quickOutline/register.d.ts +2 -1
- package/esm/vs/features/readOnlyMessage/register.d.ts +2 -1
- package/esm/vs/features/referenceSearch/register.d.ts +2 -1
- package/esm/vs/features/rename/register.d.ts +2 -1
- package/esm/vs/features/sectionHeaders/register.d.ts +2 -1
- package/esm/vs/features/semanticTokens/register.d.ts +2 -1
- package/esm/vs/features/smartSelect/register.d.ts +2 -1
- package/esm/vs/features/snippet/register.d.ts +2 -1
- package/esm/vs/features/stickyScroll/register.d.ts +2 -1
- package/esm/vs/features/suggest/register.d.ts +2 -1
- package/esm/vs/features/toggleHighContrast/register.d.ts +2 -1
- package/esm/vs/features/toggleTabFocusMode/register.d.ts +2 -1
- package/esm/vs/features/tokenization/register.d.ts +2 -1
- package/esm/vs/features/unicodeHighlighter/register.d.ts +2 -1
- package/esm/vs/features/unusualLineTerminators/register.d.ts +2 -1
- package/esm/vs/features/wordHighlighter/register.d.ts +2 -1
- package/esm/vs/features/wordOperations/register.d.ts +2 -1
- package/esm/vs/features/wordPartOperations/register.d.ts +2 -1
- package/esm/vs/languages/definitions/abap/register.d.ts +2 -1
- package/esm/vs/languages/definitions/apex/register.d.ts +2 -1
- package/esm/vs/languages/definitions/azcli/register.d.ts +2 -1
- package/esm/vs/languages/definitions/bat/register.d.ts +2 -1
- package/esm/vs/languages/definitions/bicep/register.d.ts +2 -1
- package/esm/vs/languages/definitions/cameligo/register.d.ts +2 -1
- package/esm/vs/languages/definitions/clojure/register.d.ts +2 -1
- package/esm/vs/languages/definitions/coffee/register.d.ts +2 -1
- package/esm/vs/languages/definitions/cpp/register.d.ts +2 -1
- package/esm/vs/languages/definitions/csharp/register.d.ts +2 -1
- package/esm/vs/languages/definitions/csp/register.d.ts +2 -1
- package/esm/vs/languages/definitions/css/register.d.ts +2 -1
- package/esm/vs/languages/definitions/cypher/register.d.ts +2 -1
- package/esm/vs/languages/definitions/dart/register.d.ts +2 -1
- package/esm/vs/languages/definitions/dockerfile/register.d.ts +2 -1
- package/esm/vs/languages/definitions/ecl/register.d.ts +2 -1
- package/esm/vs/languages/definitions/elixir/register.d.ts +2 -1
- package/esm/vs/languages/definitions/flow9/register.d.ts +2 -1
- package/esm/vs/languages/definitions/freemarker2/register.d.ts +2 -1
- package/esm/vs/languages/definitions/fsharp/register.d.ts +2 -1
- package/esm/vs/languages/definitions/go/register.d.ts +2 -1
- package/esm/vs/languages/definitions/graphql/register.d.ts +2 -1
- package/esm/vs/languages/definitions/handlebars/register.d.ts +2 -1
- package/esm/vs/languages/definitions/hcl/register.d.ts +2 -1
- package/esm/vs/languages/definitions/html/register.d.ts +2 -1
- package/esm/vs/languages/definitions/ini/register.d.ts +2 -1
- package/esm/vs/languages/definitions/java/register.d.ts +2 -1
- package/esm/vs/languages/definitions/javascript/register.d.ts +2 -1
- package/esm/vs/languages/definitions/julia/register.d.ts +2 -1
- package/esm/vs/languages/definitions/kotlin/register.d.ts +2 -1
- package/esm/vs/languages/definitions/less/register.d.ts +2 -1
- package/esm/vs/languages/definitions/lexon/register.d.ts +2 -1
- package/esm/vs/languages/definitions/liquid/register.d.ts +2 -1
- package/esm/vs/languages/definitions/lua/register.d.ts +2 -1
- package/esm/vs/languages/definitions/m3/register.d.ts +2 -1
- package/esm/vs/languages/definitions/markdown/register.d.ts +2 -1
- package/esm/vs/languages/definitions/mdx/register.d.ts +2 -1
- package/esm/vs/languages/definitions/mips/register.d.ts +2 -1
- package/esm/vs/languages/definitions/msdax/register.d.ts +2 -1
- package/esm/vs/languages/definitions/mysql/register.d.ts +2 -1
- package/esm/vs/languages/definitions/objective-c/register.d.ts +2 -1
- package/esm/vs/languages/definitions/pascal/register.d.ts +2 -1
- package/esm/vs/languages/definitions/pascaligo/register.d.ts +2 -1
- package/esm/vs/languages/definitions/perl/register.d.ts +2 -1
- package/esm/vs/languages/definitions/pgsql/register.d.ts +2 -1
- package/esm/vs/languages/definitions/php/register.d.ts +2 -1
- package/esm/vs/languages/definitions/pla/register.d.ts +2 -1
- package/esm/vs/languages/definitions/postiats/register.d.ts +2 -1
- package/esm/vs/languages/definitions/powerquery/register.d.ts +2 -1
- package/esm/vs/languages/definitions/powershell/register.d.ts +2 -1
- package/esm/vs/languages/definitions/protobuf/register.d.ts +2 -1
- package/esm/vs/languages/definitions/pug/register.d.ts +2 -1
- package/esm/vs/languages/definitions/python/register.d.ts +2 -1
- package/esm/vs/languages/definitions/qsharp/register.d.ts +2 -1
- package/esm/vs/languages/definitions/r/register.d.ts +2 -1
- package/esm/vs/languages/definitions/razor/register.d.ts +2 -1
- package/esm/vs/languages/definitions/redis/register.d.ts +2 -1
- package/esm/vs/languages/definitions/redshift/register.d.ts +2 -1
- package/esm/vs/languages/definitions/restructuredtext/register.d.ts +2 -1
- package/esm/vs/languages/definitions/ruby/register.d.ts +2 -1
- package/esm/vs/languages/definitions/rust/register.d.ts +2 -1
- package/esm/vs/languages/definitions/sb/register.d.ts +2 -1
- package/esm/vs/languages/definitions/scala/register.d.ts +2 -1
- package/esm/vs/languages/definitions/scheme/register.d.ts +2 -1
- package/esm/vs/languages/definitions/scss/register.d.ts +2 -1
- package/esm/vs/languages/definitions/shell/register.d.ts +2 -1
- package/esm/vs/languages/definitions/solidity/register.d.ts +2 -1
- package/esm/vs/languages/definitions/sophia/register.d.ts +2 -1
- package/esm/vs/languages/definitions/sparql/register.d.ts +2 -1
- package/esm/vs/languages/definitions/sql/register.d.ts +2 -1
- package/esm/vs/languages/definitions/st/register.d.ts +2 -1
- package/esm/vs/languages/definitions/swift/register.d.ts +2 -1
- package/esm/vs/languages/definitions/systemverilog/register.d.ts +2 -1
- package/esm/vs/languages/definitions/tcl/register.d.ts +2 -1
- package/esm/vs/languages/definitions/twig/register.d.ts +2 -1
- package/esm/vs/languages/definitions/typescript/register.d.ts +2 -1
- package/esm/vs/languages/definitions/typespec/register.d.ts +2 -1
- package/esm/vs/languages/definitions/vb/register.d.ts +2 -1
- package/esm/vs/languages/definitions/wgsl/register.d.ts +2 -1
- package/esm/vs/languages/definitions/xml/register.d.ts +2 -1
- package/esm/vs/languages/definitions/yaml/register.d.ts +2 -1
- package/esm/vs/languages/features/css/register.d.ts +193 -1
- package/esm/vs/languages/features/css/workerManager.js +1 -1
- package/esm/vs/languages/features/html/register.d.ts +164 -1
- package/esm/vs/languages/features/html/workerManager.js +1 -1
- package/esm/vs/languages/features/json/register.d.ts +235 -1
- package/esm/vs/languages/features/json/workerManager.js +1 -1
- package/esm/vs/languages/features/typescript/register.d.ts +443 -1
- package/esm/vs/languages/features/typescript/workerManager.js +1 -1
- package/esm/vs/nls/lang/cs.js +2 -2
- package/esm/vs/nls/lang/de.js +2 -2
- package/esm/vs/nls/lang/es.js +2 -2
- package/esm/vs/nls/lang/fr.js +2 -2
- package/esm/vs/nls/lang/it.js +2 -2
- package/esm/vs/nls/lang/ja.js +2 -2
- package/esm/vs/nls/lang/ko.js +2 -2
- package/esm/vs/nls/lang/pl.js +2 -2
- package/esm/vs/nls/lang/pt-br.js +2 -2
- package/esm/vs/nls/lang/ru.js +2 -2
- package/esm/vs/nls/lang/tr.js +2 -2
- package/esm/vs/nls/lang/zh-cn.js +2 -2
- package/esm/vs/nls/lang/zh-tw.js +2 -2
- package/esm/vs/platform/accessibilitySignal/browser/accessibilitySignalService.js +62 -62
- package/esm/vs/platform/action/common/actionCommonCategories.js +6 -6
- package/esm/vs/platform/actionWidget/browser/actionList.js +4 -4
- package/esm/vs/platform/actionWidget/browser/actionWidget.js +8 -8
- package/esm/vs/platform/actions/browser/menuEntryActionViewItem.js +3 -3
- package/esm/vs/platform/actions/browser/toolbar.js +2 -2
- package/esm/vs/platform/actions/common/actions.js +1 -0
- package/esm/vs/platform/actions/common/menuService.js +2 -2
- package/esm/vs/platform/configuration/common/configurationRegistry.js +10 -10
- package/esm/vs/platform/contextkey/browser/contextKeyService.js +1 -1
- package/esm/vs/platform/contextkey/common/contextkey.js +9 -9
- package/esm/vs/platform/contextkey/common/contextkeys.js +9 -9
- package/esm/vs/platform/contextkey/common/scanner.js +5 -5
- package/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +1 -1
- package/esm/vs/platform/hover/browser/hoverWidget.js +1 -1
- package/esm/vs/platform/hover/browser/updatableHoverWidget.js +1 -1
- package/esm/vs/platform/keybinding/common/abstractKeybindingService.js +5 -5
- package/esm/vs/platform/list/browser/listService.js +27 -27
- package/esm/vs/platform/markers/common/markerService.js +2 -2
- package/esm/vs/platform/markers/common/markers.js +6 -6
- package/esm/vs/platform/observable/common/platformObservableUtils.js +1 -1
- package/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +8 -8
- package/esm/vs/platform/quickinput/browser/helpQuickAccess.js +1 -1
- package/esm/vs/platform/quickinput/browser/media/quickInput.css +3 -11
- package/esm/vs/platform/quickinput/browser/quickInput.js +10 -10
- package/esm/vs/platform/quickinput/browser/quickInputActions.js +5 -5
- package/esm/vs/platform/quickinput/browser/quickInputController.js +6 -6
- package/esm/vs/platform/quickinput/browser/quickInputList.js +1 -1
- package/esm/vs/platform/quickinput/browser/quickInputUtils.js +1 -1
- package/esm/vs/platform/quickinput/browser/tree/quickInputTreeAccessibilityProvider.js +1 -1
- package/esm/vs/platform/quickinput/browser/tree/quickTree.js +1 -1
- package/esm/vs/platform/theme/common/colorUtils.js +2 -2
- package/esm/vs/platform/theme/common/colors/baseColors.js +18 -18
- package/esm/vs/platform/theme/common/colors/chartsColors.js +8 -8
- package/esm/vs/platform/theme/common/colors/editorColors.js +95 -95
- package/esm/vs/platform/theme/common/colors/inputColors.js +47 -47
- package/esm/vs/platform/theme/common/colors/listColors.js +36 -36
- package/esm/vs/platform/theme/common/colors/menuColors.js +7 -7
- package/esm/vs/platform/theme/common/colors/minimapColors.js +11 -11
- package/esm/vs/platform/theme/common/colors/miscColors.js +16 -16
- package/esm/vs/platform/theme/common/colors/quickpickColors.js +9 -9
- package/esm/vs/platform/theme/common/colors/searchColors.js +3 -3
- package/esm/vs/platform/theme/common/iconRegistry.js +6 -6
- package/esm/vs/platform/undoRedo/common/undoRedoService.js +20 -20
- package/esm/vs/platform/webWorker/browser/webWorkerServiceImpl.js +7 -2
- package/esm/vs/platform/workspace/common/workspace.js +1 -1
- package/min/vs/assets/{css.worker-CTho1Z2s.js → css.worker-57ylMqdQ.js} +1 -1
- package/min/vs/assets/{editor.worker-Cj3y49Lu.js → editor.worker-C7rTzOHm.js} +1 -1
- package/min/vs/assets/{editorWebWorkerMain-N9BQrLTN.js → editorWebWorkerMain-CRWuSSWk.js} +1 -1
- package/min/vs/assets/{html.worker-B5eygcqw.js → html.worker-DUkJXKh4.js} +1 -1
- package/min/vs/assets/{json.worker-C6iI2Vxn.js → json.worker-DHFIjIvp.js} +1 -1
- package/min/vs/assets/{ts.worker-BAsDYLKY.js → ts.worker-CKcSPjM2.js} +1 -1
- package/min/vs/basic-languages/monaco.contribution.js +1 -1
- package/min/vs/css.worker-CkPP9VjP.js +1 -0
- package/min/vs/cssMode-D0C9OvuF.js +1 -0
- package/min/vs/editor/editor.main.css +1 -1
- package/min/vs/editor/editor.main.js +1 -5
- package/min/vs/editor/editor.worker.js +1 -1
- package/min/vs/{editor-_RCEdmvY.js → editor-BbF9z4be.js} +107 -106
- package/min/vs/editor.js +1 -1
- package/min/vs/{editorWorkerHost-CQ7aiWlF.js → editorWorkerHost-DnKHgOKB.js} +2 -2
- package/min/vs/{freemarker2-D4d_C6LW.js → freemarker2-D9E55wFi.js} +1 -1
- package/min/vs/{handlebars-C6NNUzyJ.js → handlebars-CKRX4i8S.js} +1 -1
- package/min/vs/{html-BABEugMf.js → html-BeyhNtRJ.js} +1 -1
- package/min/vs/html.worker-uHOusrcK.js +1 -0
- package/min/vs/htmlMode-BrA9UyCN.js +1 -0
- package/min/vs/{index-CNJX59UW.js → index-049xrXrp.js} +1 -1
- package/min/vs/index-hUpZwLg1.js +5 -0
- package/min/vs/index.js +1 -0
- package/min/vs/{initialize-B_j9nAKL.js → initialize-BZ6ciHHH.js} +1 -1
- package/min/vs/{javascript-NuiwrX-5.js → javascript-DfkW5xhQ.js} +1 -1
- package/min/vs/json.worker-DGsNKzKv.js +1 -0
- package/min/vs/jsonMode-7CSZcC7s.js +1 -0
- package/min/vs/language/css/css.worker.js +1 -1
- package/min/vs/language/css/monaco.contribution.js +1 -1
- package/min/vs/language/html/html.worker.js +1 -1
- package/min/vs/language/html/monaco.contribution.js +1 -1
- package/min/vs/language/json/json.worker.js +3 -3
- package/min/vs/language/json/monaco.contribution.js +1 -1
- package/min/vs/language/typescript/monaco.contribution.js +1 -1
- package/min/vs/language/typescript/ts.worker.js +1 -1
- package/min/vs/{liquid-Bguw2x1v.js → liquid-pyVMSu08.js} +1 -1
- package/min/vs/{lspLanguageFeatures-D6IPmlbJ.js → lspLanguageFeatures-VPBqCdCb.js} +1 -1
- package/min/vs/{mdx-t4SbqCJO.js → mdx-BXbm8amL.js} +1 -1
- package/min/vs/{monaco.contribution-B6PO-qMO.js → monaco.contribution-BKcbrDXE.js} +1 -1
- package/min/vs/{monaco.contribution-CS8nS4qi.js → monaco.contribution-BjMddBgJ.js} +1 -1
- package/min/vs/{monaco.contribution-DCqiCzUr.js → monaco.contribution-BwI5AUDz.js} +1 -1
- package/min/vs/{monaco.contribution-DxVLeGt5.js → monaco.contribution-DdP5lKVl.js} +1 -1
- package/min/vs/nls/lang/cs.js +2 -2
- package/min/vs/nls/lang/de.js +2 -2
- package/min/vs/nls/lang/es.js +2 -2
- package/min/vs/nls/lang/fr.js +2 -2
- package/min/vs/nls/lang/it.js +2 -2
- package/min/vs/nls/lang/ja.js +2 -2
- package/min/vs/nls/lang/ko.js +2 -2
- package/min/vs/nls/lang/pl.js +2 -2
- package/min/vs/nls/lang/pt-br.js +2 -2
- package/min/vs/nls/lang/ru.js +2 -2
- package/min/vs/nls/lang/tr.js +2 -2
- package/min/vs/nls/lang/zh-cn.js +2 -2
- package/min/vs/nls/lang/zh-tw.js +2 -2
- package/min/vs/{python-NI5xUoLf.js → python-Cpm6f5bx.js} +1 -1
- package/min/vs/{razor-DY059DxF.js → razor-D_lKrE4A.js} +1 -1
- package/min/vs/{toggleHighContrast-B_2Wj21t.js → toggleHighContrast-BIWKqxQU.js} +32 -32
- package/min/vs/ts.worker-DyDnfuDL.js +1 -0
- package/min/vs/{tsMode-BIyo5lcL.js → tsMode-Blo4JbIC.js} +4 -4
- package/min/vs/{typescript-Pa7G7GO1.js → typescript-Bzo8PSiy.js} +1 -1
- package/min/vs/{typespec-D-PIh9Xw.js → typespec-8OfoLt6R.js} +1 -1
- package/min/vs/{workers-BZfsJ0Zq.js → workers-1UKK1eiI.js} +1 -1
- package/min/vs/{xml-BOHwjsBh.js → xml-DqJ2UhAw.js} +1 -1
- package/min/vs/{yaml-VcxPd5Wl.js → yaml-D-e6Mk4S.js} +1 -1
- package/monaco.d.ts +23 -1
- package/package.json +12 -11
- package/min/vs/cssMode-DH3ZJTuM.js +0 -1
- package/min/vs/htmlMode-CZJida2w.js +0 -1
- package/min/vs/jsonMode-CD9KTNi5.js +0 -1
|
@@ -0,0 +1,3169 @@
|
|
|
1
|
+
define("vs/index-C4qZmtMk", ["exports", "./editor-BTEbNxE2", "./toggleHighContrast-BT_lXcSg", "./basic-languages/monaco.contribution", "./monaco.contribution-Dioy2gsL", "./monaco.contribution-ebA6cx7_", "./monaco.contribution-QjKN2IAC", "./monaco.contribution-Dp0abtES"], (function(exports, editor, toggleHighContrast, src_deprecated_basicLanguages_monaco_contribution_ts, src_deprecated_language_css_monaco_contribution_ts, src_deprecated_language_html_monaco_contribution_ts, src_deprecated_language_json_monaco_contribution_ts, src_deprecated_language_typescript_monaco_contribution_ts) {
|
|
2
|
+
"use strict";
|
|
3
|
+
function isRequestOrNotification(msg) {
|
|
4
|
+
return msg.method !== void 0;
|
|
5
|
+
}
|
|
6
|
+
var ErrorObject;
|
|
7
|
+
(function(ErrorObject$1) {
|
|
8
|
+
function create(obj) {
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
ErrorObject$1.create = create;
|
|
12
|
+
})(ErrorObject || (ErrorObject = {}));
|
|
13
|
+
var ErrorCode;
|
|
14
|
+
(function(ErrorCode$1) {
|
|
15
|
+
ErrorCode$1.parseError = -32700;
|
|
16
|
+
ErrorCode$1.invalidRequest = -32600;
|
|
17
|
+
ErrorCode$1.methodNotFound = -32601;
|
|
18
|
+
ErrorCode$1.invalidParams = -32602;
|
|
19
|
+
ErrorCode$1.internalError = -32603;
|
|
20
|
+
function isServerError(code) {
|
|
21
|
+
return -32099 <= code && code <= -32e3;
|
|
22
|
+
}
|
|
23
|
+
ErrorCode$1.isServerError = isServerError;
|
|
24
|
+
function serverError(code) {
|
|
25
|
+
if (!isServerError(code)) throw new Error("Invalid range for a server error.");
|
|
26
|
+
return code;
|
|
27
|
+
}
|
|
28
|
+
ErrorCode$1.serverError = serverError;
|
|
29
|
+
ErrorCode$1.unexpectedServerError = -32e3;
|
|
30
|
+
function isApplicationError(code) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
ErrorCode$1.isApplicationError = isApplicationError;
|
|
34
|
+
function applicationError(code) {
|
|
35
|
+
return code;
|
|
36
|
+
}
|
|
37
|
+
ErrorCode$1.applicationError = applicationError;
|
|
38
|
+
ErrorCode$1.genericApplicationError = -320100;
|
|
39
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
40
|
+
var EventEmitter = class {
|
|
41
|
+
listeners = /* @__PURE__ */ new Set();
|
|
42
|
+
event = (listener) => {
|
|
43
|
+
this.listeners.add(listener);
|
|
44
|
+
return { dispose: () => {
|
|
45
|
+
this.listeners.delete(listener);
|
|
46
|
+
} };
|
|
47
|
+
};
|
|
48
|
+
fire(args) {
|
|
49
|
+
this.listeners.forEach((listener) => listener(args));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var ValueWithChangeEvent = class {
|
|
53
|
+
_value;
|
|
54
|
+
eventEmitter;
|
|
55
|
+
constructor(initialValue) {
|
|
56
|
+
this._value = initialValue;
|
|
57
|
+
this.eventEmitter = new EventEmitter();
|
|
58
|
+
}
|
|
59
|
+
get value() {
|
|
60
|
+
return this._value;
|
|
61
|
+
}
|
|
62
|
+
set value(newValue) {
|
|
63
|
+
if (this._value !== newValue) {
|
|
64
|
+
this._value = newValue;
|
|
65
|
+
this.eventEmitter.fire(newValue);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
get onChange() {
|
|
69
|
+
return this.eventEmitter.event;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function createTimeout(delay, callback) {
|
|
73
|
+
const handle = setTimeout(callback, delay);
|
|
74
|
+
return { dispose: () => clearTimeout(handle) };
|
|
75
|
+
}
|
|
76
|
+
function setAndDeleteOnDispose(set, keyOrItem, item) {
|
|
77
|
+
if (set instanceof Set) {
|
|
78
|
+
set.add(keyOrItem);
|
|
79
|
+
return { dispose: () => set.delete(keyOrItem) };
|
|
80
|
+
} else {
|
|
81
|
+
set.set(keyOrItem, item);
|
|
82
|
+
return { dispose: () => set.delete(keyOrItem) };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
var Deferred = class {
|
|
86
|
+
_state = "none";
|
|
87
|
+
promise;
|
|
88
|
+
resolve = () => {
|
|
89
|
+
};
|
|
90
|
+
reject = () => {
|
|
91
|
+
};
|
|
92
|
+
constructor() {
|
|
93
|
+
this.promise = new Promise((resolve, reject) => {
|
|
94
|
+
this.resolve = resolve;
|
|
95
|
+
this.reject = reject;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
get state() {
|
|
99
|
+
return this._state;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var BaseMessageTransport = class BaseMessageTransport2 {
|
|
103
|
+
static id = 0;
|
|
104
|
+
_unprocessedMessages = [];
|
|
105
|
+
_messageListener;
|
|
106
|
+
id = BaseMessageTransport2.id++;
|
|
107
|
+
_state = new ValueWithChangeEvent({ state: "open" });
|
|
108
|
+
state = this._state;
|
|
109
|
+
/**
|
|
110
|
+
* Sets a callback for incoming messages.
|
|
111
|
+
*/
|
|
112
|
+
setListener(listener) {
|
|
113
|
+
this._messageListener = listener;
|
|
114
|
+
if (!listener) return;
|
|
115
|
+
while (this._unprocessedMessages.length > 0 && this._messageListener !== void 0) {
|
|
116
|
+
const msg = this._unprocessedMessages.shift();
|
|
117
|
+
this._messageListener(msg);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Writes a message to the stream.
|
|
122
|
+
*/
|
|
123
|
+
send(message) {
|
|
124
|
+
return this._sendImpl(message);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Call this in derived classes to signal a new message.
|
|
128
|
+
*/
|
|
129
|
+
_dispatchReceivedMessage(message) {
|
|
130
|
+
if (this._unprocessedMessages.length === 0 && this._messageListener) this._messageListener(message);
|
|
131
|
+
else this._unprocessedMessages.push(message);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Call this in derived classes to signal that the connection closed.
|
|
135
|
+
*/
|
|
136
|
+
_onConnectionClosed() {
|
|
137
|
+
this._state.value = {
|
|
138
|
+
state: "closed",
|
|
139
|
+
error: void 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
log(logger) {
|
|
143
|
+
return new StreamLogger(this, logger ?? new ConsoleMessageLogger());
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var StreamLogger = class {
|
|
147
|
+
baseStream;
|
|
148
|
+
logger;
|
|
149
|
+
constructor(baseStream, logger) {
|
|
150
|
+
this.baseStream = baseStream;
|
|
151
|
+
this.logger = logger;
|
|
152
|
+
}
|
|
153
|
+
get state() {
|
|
154
|
+
return this.baseStream.state;
|
|
155
|
+
}
|
|
156
|
+
setListener(listener) {
|
|
157
|
+
if (listener === void 0) {
|
|
158
|
+
this.baseStream.setListener(void 0);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this.baseStream.setListener((readMessage) => {
|
|
162
|
+
this.logger.log(this.baseStream, "incoming", readMessage);
|
|
163
|
+
listener(readMessage);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
send(message) {
|
|
167
|
+
this.logger.log(this.baseStream, "outgoing", message);
|
|
168
|
+
return this.baseStream.send(message);
|
|
169
|
+
}
|
|
170
|
+
toString() {
|
|
171
|
+
return `StreamLogger/${this.baseStream.toString()}`;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var ConsoleMessageLogger = class {
|
|
175
|
+
log(stream, type, message) {
|
|
176
|
+
const char = type === "incoming" ? "<-" : "->";
|
|
177
|
+
console.log(`${char} [${stream.toString()}] ${JSON.stringify(message)}`);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var Channel = class Channel2 {
|
|
181
|
+
connect;
|
|
182
|
+
constructor(connect) {
|
|
183
|
+
this.connect = connect;
|
|
184
|
+
}
|
|
185
|
+
mapContext(map) {
|
|
186
|
+
return new Channel2((listener) => this.connect(listener ? mapRequestHandlerContext(listener, map) : void 0));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
function mapRequestHandlerContext(messageHandler, map) {
|
|
190
|
+
return {
|
|
191
|
+
handleNotification: (request, context) => messageHandler.handleNotification(request, map(context)),
|
|
192
|
+
handleRequest: (request, requestId, context) => messageHandler.handleRequest(request, requestId, map(context))
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var StreamBasedChannel = class StreamBasedChannel2 {
|
|
196
|
+
_stream;
|
|
197
|
+
_listener;
|
|
198
|
+
_logger;
|
|
199
|
+
/**
|
|
200
|
+
* Creates a channel factory from a given stream and logger.
|
|
201
|
+
* This allows to delay specifying a `RequestHandler`.
|
|
202
|
+
* Once the channel is created, it processes incoming messages.
|
|
203
|
+
*/
|
|
204
|
+
static createChannel(stream, logger) {
|
|
205
|
+
let constructed = false;
|
|
206
|
+
return new Channel((listener) => {
|
|
207
|
+
if (constructed) throw new Error(`A channel to the stream ${stream} was already constructed!`);
|
|
208
|
+
else constructed = true;
|
|
209
|
+
return new StreamBasedChannel2(stream, listener, logger);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
_unprocessedResponses = /* @__PURE__ */ new Map();
|
|
213
|
+
_lastUsedRequestId = 0;
|
|
214
|
+
constructor(_stream, _listener, _logger) {
|
|
215
|
+
this._stream = _stream;
|
|
216
|
+
this._listener = _listener;
|
|
217
|
+
this._logger = _logger;
|
|
218
|
+
this._stream.setListener((message) => {
|
|
219
|
+
if (isRequestOrNotification(message)) if (message.id === void 0) this._processNotification(message);
|
|
220
|
+
else this._processRequest(message);
|
|
221
|
+
else this._processResponse(message);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
get state() {
|
|
225
|
+
return this._stream.state;
|
|
226
|
+
}
|
|
227
|
+
async _processNotification(message) {
|
|
228
|
+
if (message.id !== void 0) throw new Error();
|
|
229
|
+
if (!this._listener) {
|
|
230
|
+
if (this._logger) this._logger.debug({
|
|
231
|
+
text: "Notification ignored",
|
|
232
|
+
message
|
|
233
|
+
});
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
await this._listener.handleNotification({
|
|
238
|
+
method: message.method,
|
|
239
|
+
params: message.params || null
|
|
240
|
+
});
|
|
241
|
+
} catch (exception) {
|
|
242
|
+
if (this._logger) this._logger.warn({
|
|
243
|
+
text: `Exception was thrown while handling notification: ${exception}`,
|
|
244
|
+
exception,
|
|
245
|
+
message
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async _processRequest(message) {
|
|
250
|
+
if (message.id === void 0) throw new Error();
|
|
251
|
+
let result;
|
|
252
|
+
if (this._listener) try {
|
|
253
|
+
result = await this._listener.handleRequest({
|
|
254
|
+
method: message.method,
|
|
255
|
+
params: message.params || null
|
|
256
|
+
}, message.id);
|
|
257
|
+
} catch (exception) {
|
|
258
|
+
if (this._logger) this._logger.warn({
|
|
259
|
+
text: `Exception was thrown while handling request: ${exception}`,
|
|
260
|
+
message,
|
|
261
|
+
exception
|
|
262
|
+
});
|
|
263
|
+
result = { error: {
|
|
264
|
+
code: ErrorCode.internalError,
|
|
265
|
+
message: "An unexpected exception was thrown.",
|
|
266
|
+
data: void 0
|
|
267
|
+
} };
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
if (this._logger) this._logger.debug({
|
|
271
|
+
text: "Received request even though not listening for requests",
|
|
272
|
+
message
|
|
273
|
+
});
|
|
274
|
+
result = { error: {
|
|
275
|
+
code: ErrorCode.methodNotFound,
|
|
276
|
+
message: "This endpoint does not listen for requests or notifications.",
|
|
277
|
+
data: void 0
|
|
278
|
+
} };
|
|
279
|
+
}
|
|
280
|
+
let responseMsg;
|
|
281
|
+
if ("result" in result) responseMsg = {
|
|
282
|
+
jsonrpc: "2.0",
|
|
283
|
+
id: message.id,
|
|
284
|
+
result: result.result
|
|
285
|
+
};
|
|
286
|
+
else responseMsg = {
|
|
287
|
+
jsonrpc: "2.0",
|
|
288
|
+
id: message.id,
|
|
289
|
+
error: result.error
|
|
290
|
+
};
|
|
291
|
+
await this._stream.send(responseMsg);
|
|
292
|
+
}
|
|
293
|
+
_processResponse(message) {
|
|
294
|
+
const strId = "" + message.id;
|
|
295
|
+
const callback = this._unprocessedResponses.get(strId);
|
|
296
|
+
if (!callback) {
|
|
297
|
+
if (this._logger) this._logger.debug({
|
|
298
|
+
text: "Got an unexpected response message",
|
|
299
|
+
message
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this._unprocessedResponses.delete(strId);
|
|
304
|
+
callback(message);
|
|
305
|
+
}
|
|
306
|
+
_newRequestId() {
|
|
307
|
+
return this._lastUsedRequestId++;
|
|
308
|
+
}
|
|
309
|
+
sendRequest(request, _context, messageIdCallback) {
|
|
310
|
+
const message = {
|
|
311
|
+
jsonrpc: "2.0",
|
|
312
|
+
id: this._newRequestId(),
|
|
313
|
+
method: request.method,
|
|
314
|
+
params: request.params || void 0
|
|
315
|
+
};
|
|
316
|
+
if (messageIdCallback) messageIdCallback(message.id);
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
const strId = "" + message.id;
|
|
319
|
+
this._unprocessedResponses.set(strId, (response) => {
|
|
320
|
+
if ("result" in response) resolve({ result: response.result });
|
|
321
|
+
else {
|
|
322
|
+
if (!response.error) reject(/* @__PURE__ */ new Error("Response had neither 'result' nor 'error' field set."));
|
|
323
|
+
resolve({ error: response.error });
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
this._stream.send(message).then(void 0, (reason) => {
|
|
327
|
+
this._unprocessedResponses.delete(strId);
|
|
328
|
+
reject(reason);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
sendNotification(notification, context) {
|
|
333
|
+
const msg = {
|
|
334
|
+
jsonrpc: "2.0",
|
|
335
|
+
id: void 0,
|
|
336
|
+
method: notification.method,
|
|
337
|
+
params: notification.params || void 0
|
|
338
|
+
};
|
|
339
|
+
return this._stream.send(msg);
|
|
340
|
+
}
|
|
341
|
+
toString() {
|
|
342
|
+
return "StreamChannel/" + this._stream.toString();
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var Serializers;
|
|
346
|
+
(function(Serializers$1) {
|
|
347
|
+
function sAny() {
|
|
348
|
+
return {
|
|
349
|
+
deserializeFromJson: (input) => ({
|
|
350
|
+
hasErrors: false,
|
|
351
|
+
value: input
|
|
352
|
+
}),
|
|
353
|
+
serializeToJson: (input) => input
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
Serializers$1.sAny = sAny;
|
|
357
|
+
function sEmptyObject() {
|
|
358
|
+
return {
|
|
359
|
+
deserializeFromJson: (input) => ({
|
|
360
|
+
hasErrors: false,
|
|
361
|
+
value: {}
|
|
362
|
+
}),
|
|
363
|
+
serializeToJson: (input) => ({})
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
Serializers$1.sEmptyObject = sEmptyObject;
|
|
367
|
+
function sVoidFromNull() {
|
|
368
|
+
return {
|
|
369
|
+
deserializeFromJson: (input) => ({
|
|
370
|
+
hasErrors: false,
|
|
371
|
+
value: void 0
|
|
372
|
+
}),
|
|
373
|
+
serializeToJson: (input) => null
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
Serializers$1.sVoidFromNull = sVoidFromNull;
|
|
377
|
+
})(Serializers || (Serializers = {}));
|
|
378
|
+
const OptionalMethodNotFound = /* @__PURE__ */ Symbol("OptionalMethodNotFound");
|
|
379
|
+
var TypedChannelBase = class {
|
|
380
|
+
contextualize(args) {
|
|
381
|
+
return new ContextualizedTypedChannel(this, args);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var ContextualizedTypedChannel = class extends TypedChannelBase {
|
|
385
|
+
underylingTypedChannel;
|
|
386
|
+
converters;
|
|
387
|
+
constructor(underylingTypedChannel, converters) {
|
|
388
|
+
super();
|
|
389
|
+
this.underylingTypedChannel = underylingTypedChannel;
|
|
390
|
+
this.converters = converters;
|
|
391
|
+
}
|
|
392
|
+
async request(requestType, args, newContext) {
|
|
393
|
+
const context = await this.converters.getSendContext(newContext);
|
|
394
|
+
return this.underylingTypedChannel.request(requestType, args, context);
|
|
395
|
+
}
|
|
396
|
+
async notify(notificationType, params, newContext) {
|
|
397
|
+
const context = await this.converters.getSendContext(newContext);
|
|
398
|
+
return this.underylingTypedChannel.notify(notificationType, params, context);
|
|
399
|
+
}
|
|
400
|
+
registerNotificationHandler(type, handler) {
|
|
401
|
+
return this.underylingTypedChannel.registerNotificationHandler(type, async (arg, context) => {
|
|
402
|
+
return await handler(arg, await this.converters.getNewContext(context));
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
registerRequestHandler(requestType, handler) {
|
|
406
|
+
return this.underylingTypedChannel.registerRequestHandler(requestType, async (arg, requestId, context) => {
|
|
407
|
+
return await handler(arg, requestId, await this.converters.getNewContext(context));
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var TypedChannel = class TypedChannel2 extends TypedChannelBase {
|
|
412
|
+
channelCtor;
|
|
413
|
+
static fromTransport(stream, options = {}) {
|
|
414
|
+
return new TypedChannel2(StreamBasedChannel.createChannel(stream, options.logger), options);
|
|
415
|
+
}
|
|
416
|
+
_requestSender = void 0;
|
|
417
|
+
_handler = /* @__PURE__ */ new Map();
|
|
418
|
+
_unknownNotificationHandler = /* @__PURE__ */ new Set();
|
|
419
|
+
_timeout;
|
|
420
|
+
sendExceptionDetails = false;
|
|
421
|
+
_logger;
|
|
422
|
+
constructor(channelCtor, options = {}) {
|
|
423
|
+
super();
|
|
424
|
+
this.channelCtor = channelCtor;
|
|
425
|
+
this._logger = options.logger;
|
|
426
|
+
this.sendExceptionDetails = !!options.sendExceptionDetails;
|
|
427
|
+
this._timeout = createTimeout(1e3, () => {
|
|
428
|
+
if (!this._requestSender) console.warn(`"${this.startListen.name}" has not been called within 1 second after construction of this channel. Did you forget to call it?`, this);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
listeningDeferred = new Deferred();
|
|
432
|
+
onListening = this.listeningDeferred.promise;
|
|
433
|
+
_requestDidErrorEventEmitter = new EventEmitter();
|
|
434
|
+
onRequestDidError = this._requestDidErrorEventEmitter.event;
|
|
435
|
+
/**
|
|
436
|
+
* This method must be called to forward messages from the stream to this channel.
|
|
437
|
+
* This is not done automatically on construction so that this instance
|
|
438
|
+
* can be setup properly before handling messages.
|
|
439
|
+
*/
|
|
440
|
+
startListen() {
|
|
441
|
+
if (this._requestSender) throw new Error(`"${this.startListen.name}" can be called only once, but it already has been called.`);
|
|
442
|
+
if (this._timeout) {
|
|
443
|
+
this._timeout.dispose();
|
|
444
|
+
this._timeout = void 0;
|
|
445
|
+
}
|
|
446
|
+
this._requestSender = this.channelCtor.connect({
|
|
447
|
+
handleRequest: (req, id, context) => this.handleRequest(req, id, context),
|
|
448
|
+
handleNotification: (req, context) => this.handleNotification(req, context)
|
|
449
|
+
});
|
|
450
|
+
this.listeningDeferred.resolve();
|
|
451
|
+
}
|
|
452
|
+
checkChannel(channel) {
|
|
453
|
+
if (!channel) throw new Error(`"${this.startListen.name}" must be called before any messages can be sent or received.`);
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
async handleRequest(request, requestId, context) {
|
|
457
|
+
const handler = this._handler.get(request.method);
|
|
458
|
+
if (!handler) {
|
|
459
|
+
if (this._logger) this._logger.debug({
|
|
460
|
+
text: `No request handler for "${request.method}".`,
|
|
461
|
+
data: { requestObject: request }
|
|
462
|
+
});
|
|
463
|
+
return { error: {
|
|
464
|
+
code: ErrorCode.methodNotFound,
|
|
465
|
+
message: `No request handler for "${request.method}".`,
|
|
466
|
+
data: { method: request.method }
|
|
467
|
+
} };
|
|
468
|
+
}
|
|
469
|
+
if (handler.kind != "request") {
|
|
470
|
+
const message = `"${request.method}" is registered as notification, but was sent as request.`;
|
|
471
|
+
if (this._logger) this._logger.debug({
|
|
472
|
+
text: message,
|
|
473
|
+
data: { requestObject: request }
|
|
474
|
+
});
|
|
475
|
+
return { error: {
|
|
476
|
+
code: ErrorCode.invalidRequest,
|
|
477
|
+
message,
|
|
478
|
+
data: { method: request.method }
|
|
479
|
+
} };
|
|
480
|
+
}
|
|
481
|
+
const decodeResult = handler.requestType.paramsSerializer.deserializeFromJson(request.params);
|
|
482
|
+
if (decodeResult.hasErrors) {
|
|
483
|
+
const message = `Got invalid params: ${decodeResult.errorMessage}`;
|
|
484
|
+
if (this._logger) this._logger.debug({
|
|
485
|
+
text: message,
|
|
486
|
+
data: {
|
|
487
|
+
requestObject: request,
|
|
488
|
+
errorMessage: decodeResult.errorMessage
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
return { error: {
|
|
492
|
+
code: ErrorCode.invalidParams,
|
|
493
|
+
message,
|
|
494
|
+
data: { errors: decodeResult.errorMessage }
|
|
495
|
+
} };
|
|
496
|
+
} else {
|
|
497
|
+
const args = decodeResult.value;
|
|
498
|
+
let response;
|
|
499
|
+
try {
|
|
500
|
+
const result = await handler.handler(args, requestId, context);
|
|
501
|
+
if ("error" in result || "errorMessage" in result) {
|
|
502
|
+
const errorData = result.error ? handler.requestType.errorSerializer.serializeToJson(result.error) : void 0;
|
|
503
|
+
response = { error: {
|
|
504
|
+
code: result.errorCode || ErrorCode.genericApplicationError,
|
|
505
|
+
message: result.errorMessage || "An error was returned",
|
|
506
|
+
data: errorData
|
|
507
|
+
} };
|
|
508
|
+
} else response = { result: handler.requestType.resultSerializer.serializeToJson(result.ok) };
|
|
509
|
+
} catch (exception) {
|
|
510
|
+
if (exception instanceof RequestHandlingError) response = { error: {
|
|
511
|
+
code: exception.code,
|
|
512
|
+
message: exception.message
|
|
513
|
+
} };
|
|
514
|
+
else {
|
|
515
|
+
if (this._logger) this._logger.warn({
|
|
516
|
+
text: `An exception was thrown while handling a request: ${exception}.`,
|
|
517
|
+
exception,
|
|
518
|
+
data: { requestObject: request }
|
|
519
|
+
});
|
|
520
|
+
response = { error: {
|
|
521
|
+
code: ErrorCode.unexpectedServerError,
|
|
522
|
+
message: this.sendExceptionDetails ? `An exception was thrown while handling a request: ${exception}.` : "Server has thrown an unexpected exception"
|
|
523
|
+
} };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return response;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
async handleNotification(request, context) {
|
|
530
|
+
const handler = this._handler.get(request.method);
|
|
531
|
+
if (!handler) {
|
|
532
|
+
for (const h of this._unknownNotificationHandler) h(request);
|
|
533
|
+
if (this._unknownNotificationHandler.size === 0) {
|
|
534
|
+
if (this._logger) this._logger.debug({
|
|
535
|
+
text: `Unhandled notification "${request.method}"`,
|
|
536
|
+
data: { requestObject: request }
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (handler.kind != "notification") {
|
|
542
|
+
if (this._logger) this._logger.debug({
|
|
543
|
+
text: `"${request.method}" is registered as request, but was sent as notification.`,
|
|
544
|
+
data: { requestObject: request }
|
|
545
|
+
});
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const decodeResult = handler.notificationType.paramsSerializer.deserializeFromJson(request.params);
|
|
549
|
+
if (decodeResult.hasErrors) {
|
|
550
|
+
if (this._logger) this._logger.debug({
|
|
551
|
+
text: `Got invalid params: ${decodeResult}`,
|
|
552
|
+
data: {
|
|
553
|
+
requestObject: request,
|
|
554
|
+
errorMessage: decodeResult.errorMessage
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const val = decodeResult.value;
|
|
560
|
+
for (const handlerFunc of handler.handlers) try {
|
|
561
|
+
handlerFunc(val, context);
|
|
562
|
+
} catch (exception) {
|
|
563
|
+
if (this._logger) this._logger.warn({
|
|
564
|
+
text: `An exception was thrown while handling a notification: ${exception}.`,
|
|
565
|
+
exception,
|
|
566
|
+
data: { requestObject: request }
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
registerUnknownNotificationHandler(handler) {
|
|
571
|
+
return setAndDeleteOnDispose(this._unknownNotificationHandler, handler);
|
|
572
|
+
}
|
|
573
|
+
registerRequestHandler(requestType, handler) {
|
|
574
|
+
if (this._handler.get(requestType.method)) throw new Error(`Handler with method "${requestType.method}" already registered.`);
|
|
575
|
+
return setAndDeleteOnDispose(this._handler, requestType.method, {
|
|
576
|
+
kind: "request",
|
|
577
|
+
requestType,
|
|
578
|
+
handler
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
registerNotificationHandler(type, handler) {
|
|
582
|
+
let registeredHandler = this._handler.get(type.method);
|
|
583
|
+
if (!registeredHandler) {
|
|
584
|
+
registeredHandler = {
|
|
585
|
+
kind: "notification",
|
|
586
|
+
notificationType: type,
|
|
587
|
+
handlers: /* @__PURE__ */ new Set()
|
|
588
|
+
};
|
|
589
|
+
this._handler.set(type.method, registeredHandler);
|
|
590
|
+
} else {
|
|
591
|
+
if (registeredHandler.kind !== "notification") throw new Error(`Method "${type.method}" was already registered as request handler.`);
|
|
592
|
+
if (registeredHandler.notificationType !== type) throw new Error(`Method "${type.method}" was registered for a different type.`);
|
|
593
|
+
}
|
|
594
|
+
return setAndDeleteOnDispose(registeredHandler.handlers, handler);
|
|
595
|
+
}
|
|
596
|
+
getRegisteredTypes() {
|
|
597
|
+
const result = [];
|
|
598
|
+
for (const h of this._handler.values()) if (h.kind === "notification") result.push(h.notificationType);
|
|
599
|
+
else if (h.kind === "request") result.push(h.requestType);
|
|
600
|
+
return result;
|
|
601
|
+
}
|
|
602
|
+
async request(requestType, args, context) {
|
|
603
|
+
if (!this.checkChannel(this._requestSender)) throw new Error("Impossible");
|
|
604
|
+
const params = requestType.paramsSerializer.serializeToJson(args);
|
|
605
|
+
assertObjectArrayOrNull(params);
|
|
606
|
+
const response = await this._requestSender.sendRequest({
|
|
607
|
+
method: requestType.method,
|
|
608
|
+
params
|
|
609
|
+
}, context);
|
|
610
|
+
if ("error" in response) {
|
|
611
|
+
if (requestType.isOptional && response.error.code === ErrorCode.methodNotFound) return OptionalMethodNotFound;
|
|
612
|
+
let errorData;
|
|
613
|
+
if (response.error.data !== void 0) {
|
|
614
|
+
const deserializationResult = requestType.errorSerializer.deserializeFromJson(response.error.data);
|
|
615
|
+
if (deserializationResult.hasErrors) throw new Error(deserializationResult.errorMessage);
|
|
616
|
+
errorData = deserializationResult.value;
|
|
617
|
+
} else errorData = void 0;
|
|
618
|
+
const error = new RequestHandlingError(response.error.message, errorData, response.error.code);
|
|
619
|
+
this._requestDidErrorEventEmitter.fire({ error });
|
|
620
|
+
throw error;
|
|
621
|
+
} else {
|
|
622
|
+
const result = requestType.resultSerializer.deserializeFromJson(response.result);
|
|
623
|
+
if (result.hasErrors) throw new Error("Could not deserialize response: " + result.errorMessage + `
|
|
624
|
+
|
|
625
|
+
${JSON.stringify(response, null, 2)}`);
|
|
626
|
+
else return result.value;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
async notify(notificationType, params, context) {
|
|
630
|
+
if (!this.checkChannel(this._requestSender)) throw new Error();
|
|
631
|
+
const encodedParams = notificationType.paramsSerializer.serializeToJson(params);
|
|
632
|
+
assertObjectArrayOrNull(encodedParams);
|
|
633
|
+
this._requestSender.sendNotification({
|
|
634
|
+
method: notificationType.method,
|
|
635
|
+
params: encodedParams
|
|
636
|
+
}, context);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
function assertObjectArrayOrNull(val) {
|
|
640
|
+
if (val !== null && Array.isArray(val) && typeof val !== "object") throw new Error("Invalid value! Only null, array and object is allowed.");
|
|
641
|
+
}
|
|
642
|
+
var RequestHandlingError = class RequestHandlingError2 extends Error {
|
|
643
|
+
data;
|
|
644
|
+
code;
|
|
645
|
+
constructor(message, data, code = ErrorCode.genericApplicationError) {
|
|
646
|
+
super(message);
|
|
647
|
+
this.data = data;
|
|
648
|
+
this.code = code;
|
|
649
|
+
Object.setPrototypeOf(this, RequestHandlingError2.prototype);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
var RequestType = class RequestType2 {
|
|
653
|
+
method;
|
|
654
|
+
paramsSerializer;
|
|
655
|
+
resultSerializer;
|
|
656
|
+
errorSerializer;
|
|
657
|
+
isOptional;
|
|
658
|
+
kind = "request";
|
|
659
|
+
constructor(method, paramsSerializer, resultSerializer, errorSerializer, isOptional = false) {
|
|
660
|
+
this.method = method;
|
|
661
|
+
this.paramsSerializer = paramsSerializer;
|
|
662
|
+
this.resultSerializer = resultSerializer;
|
|
663
|
+
this.errorSerializer = errorSerializer;
|
|
664
|
+
this.isOptional = isOptional;
|
|
665
|
+
}
|
|
666
|
+
withMethod(method) {
|
|
667
|
+
return new RequestType2(method, this.paramsSerializer, this.resultSerializer, this.errorSerializer);
|
|
668
|
+
}
|
|
669
|
+
optional() {
|
|
670
|
+
return new RequestType2(this.method, this.paramsSerializer, this.resultSerializer, this.errorSerializer, true);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
var NotificationType = class NotificationType2 {
|
|
674
|
+
method;
|
|
675
|
+
paramsSerializer;
|
|
676
|
+
kind = "notification";
|
|
677
|
+
constructor(method, paramsSerializer) {
|
|
678
|
+
this.method = method;
|
|
679
|
+
this.paramsSerializer = paramsSerializer;
|
|
680
|
+
}
|
|
681
|
+
withMethod(method) {
|
|
682
|
+
return new NotificationType2(method, this.paramsSerializer);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
function unverifiedRequest(request) {
|
|
686
|
+
return new RequestType((request || {}).method, Serializers.sAny(), Serializers.sAny(), Serializers.sAny());
|
|
687
|
+
}
|
|
688
|
+
function unverifiedNotification(request) {
|
|
689
|
+
return new NotificationType((request || {}).method, Serializers.sAny());
|
|
690
|
+
}
|
|
691
|
+
const IsErrorWrapper = /* @__PURE__ */ Symbol();
|
|
692
|
+
var ErrorWrapper = class ErrorWrapper2 {
|
|
693
|
+
error;
|
|
694
|
+
static factory = (error) => {
|
|
695
|
+
return new ErrorWrapper2(error);
|
|
696
|
+
};
|
|
697
|
+
[IsErrorWrapper];
|
|
698
|
+
constructor(error) {
|
|
699
|
+
this.error = error;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
function contract(contractObj) {
|
|
703
|
+
const server = transform(contractObj["server"]);
|
|
704
|
+
const client = transform(contractObj["client"]);
|
|
705
|
+
return new Contract(contractObj.tags || [], server, client);
|
|
706
|
+
}
|
|
707
|
+
function transform(requestMap) {
|
|
708
|
+
const result = {};
|
|
709
|
+
for (const [key, req] of Object.entries(requestMap)) {
|
|
710
|
+
const method = req.method ? req.method : key;
|
|
711
|
+
result[key] = req.withMethod(method);
|
|
712
|
+
}
|
|
713
|
+
return result;
|
|
714
|
+
}
|
|
715
|
+
var Contract = class Contract2 {
|
|
716
|
+
tags;
|
|
717
|
+
server;
|
|
718
|
+
client;
|
|
719
|
+
_onlyDesignTime() {
|
|
720
|
+
return /* @__PURE__ */ new Error("This property is not meant to be accessed at runtime");
|
|
721
|
+
}
|
|
722
|
+
get TContractObject() {
|
|
723
|
+
throw this._onlyDesignTime();
|
|
724
|
+
}
|
|
725
|
+
get TClientInterface() {
|
|
726
|
+
throw this._onlyDesignTime();
|
|
727
|
+
}
|
|
728
|
+
get TServerInterface() {
|
|
729
|
+
throw this._onlyDesignTime();
|
|
730
|
+
}
|
|
731
|
+
get TClientHandler() {
|
|
732
|
+
throw this._onlyDesignTime();
|
|
733
|
+
}
|
|
734
|
+
get TServerHandler() {
|
|
735
|
+
throw this._onlyDesignTime();
|
|
736
|
+
}
|
|
737
|
+
get TTags() {
|
|
738
|
+
throw this._onlyDesignTime();
|
|
739
|
+
}
|
|
740
|
+
constructor(tags = [], server, client) {
|
|
741
|
+
this.tags = tags;
|
|
742
|
+
this.server = server;
|
|
743
|
+
this.client = client;
|
|
744
|
+
}
|
|
745
|
+
getInterface(typedChannel, myContract, otherContract, myInterface) {
|
|
746
|
+
const counterpart = this.buildCounterpart(typedChannel, otherContract);
|
|
747
|
+
const disposable = this.registerHandlers(typedChannel, myContract, myInterface, counterpart);
|
|
748
|
+
return {
|
|
749
|
+
counterpart,
|
|
750
|
+
dispose: () => disposable.dispose()
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
buildCounterpart(typedChannel, otherContract) {
|
|
754
|
+
const counterpart = {};
|
|
755
|
+
for (const [key, req] of Object.entries(otherContract)) {
|
|
756
|
+
let method;
|
|
757
|
+
if (req.kind === "request") if (req.isOptional) method = async (args, context) => {
|
|
758
|
+
if (args === void 0) args = {};
|
|
759
|
+
try {
|
|
760
|
+
return await typedChannel.request(req, args, context);
|
|
761
|
+
} catch (error) {
|
|
762
|
+
if (error && error.code === ErrorCode.methodNotFound) return OptionalMethodNotFound;
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
else method = (args, context) => {
|
|
767
|
+
if (args === void 0) args = {};
|
|
768
|
+
return typedChannel.request(req, args, context);
|
|
769
|
+
};
|
|
770
|
+
else method = (args, context) => {
|
|
771
|
+
if (args === void 0) args = {};
|
|
772
|
+
return typedChannel.notify(req, args, context);
|
|
773
|
+
};
|
|
774
|
+
counterpart[key] = method;
|
|
775
|
+
}
|
|
776
|
+
return counterpart;
|
|
777
|
+
}
|
|
778
|
+
registerHandlers(typedChannel, myContract, myInterface, counterpart) {
|
|
779
|
+
const disposables = [];
|
|
780
|
+
for (const [key, req] of Object.entries(myContract)) if (req.kind === "request") {
|
|
781
|
+
let method = myInterface[key];
|
|
782
|
+
if (!method) continue;
|
|
783
|
+
const handler = this.createRequestHandler(counterpart, method);
|
|
784
|
+
disposables.push(typedChannel.registerRequestHandler(req, handler));
|
|
785
|
+
} else {
|
|
786
|
+
const method = myInterface[key];
|
|
787
|
+
if (method) disposables.push(typedChannel.registerNotificationHandler(req, (args, context) => {
|
|
788
|
+
method(args, {
|
|
789
|
+
context,
|
|
790
|
+
counterpart
|
|
791
|
+
});
|
|
792
|
+
}));
|
|
793
|
+
}
|
|
794
|
+
return { dispose: () => disposables.forEach((d) => d.dispose()) };
|
|
795
|
+
}
|
|
796
|
+
createRequestHandler(counterpart, method) {
|
|
797
|
+
return async (args, requestId, listenerContext) => {
|
|
798
|
+
const result = await method(args, {
|
|
799
|
+
context: listenerContext,
|
|
800
|
+
counterpart,
|
|
801
|
+
newErr: ErrorWrapper.factory,
|
|
802
|
+
requestId
|
|
803
|
+
});
|
|
804
|
+
if (result instanceof ErrorWrapper) return result.error;
|
|
805
|
+
return { ok: result };
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Gets a server object directly from a stream by constructing a new `TypedChannel`.
|
|
810
|
+
* It also registers the client implementation to the stream.
|
|
811
|
+
* The channel starts listening immediately.
|
|
812
|
+
*/
|
|
813
|
+
static getServerFromStream(contract$1, stream, options, clientImplementation) {
|
|
814
|
+
const channel = TypedChannel.fromTransport(stream, options);
|
|
815
|
+
const { server } = contract$1.getServer(channel, clientImplementation);
|
|
816
|
+
channel.startListen();
|
|
817
|
+
return {
|
|
818
|
+
channel,
|
|
819
|
+
server
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Gets a client object directly from a stream by constructing a new `TypedChannel`.
|
|
824
|
+
* It also registers the server implementation to the stream.
|
|
825
|
+
* The channel starts listening immediately.
|
|
826
|
+
*/
|
|
827
|
+
static registerServerToStream(contract$1, stream, options, serverImplementation) {
|
|
828
|
+
const channel = TypedChannel.fromTransport(stream, options);
|
|
829
|
+
const { client } = contract$1.registerServer(channel, serverImplementation);
|
|
830
|
+
channel.startListen();
|
|
831
|
+
return {
|
|
832
|
+
channel,
|
|
833
|
+
client
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
getServer(typedChannel, clientImplementation) {
|
|
837
|
+
const { counterpart, dispose } = this.getInterface(typedChannel, this.client, this.server, clientImplementation);
|
|
838
|
+
return {
|
|
839
|
+
server: counterpart,
|
|
840
|
+
dispose
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
registerServer(typedChannel, serverImplementation) {
|
|
844
|
+
const { counterpart, dispose } = this.getInterface(typedChannel, this.server, this.client, serverImplementation);
|
|
845
|
+
return {
|
|
846
|
+
client: counterpart,
|
|
847
|
+
dispose
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
withContext() {
|
|
851
|
+
return new Contract2(this.tags, this.server, this.client);
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
let FoldingRangeKind = /* @__PURE__ */ (function(FoldingRangeKind$1) {
|
|
855
|
+
FoldingRangeKind$1["Comment"] = "comment";
|
|
856
|
+
FoldingRangeKind$1["Imports"] = "imports";
|
|
857
|
+
FoldingRangeKind$1["Region"] = "region";
|
|
858
|
+
return FoldingRangeKind$1;
|
|
859
|
+
})({});
|
|
860
|
+
let SymbolKind = /* @__PURE__ */ (function(SymbolKind$1) {
|
|
861
|
+
SymbolKind$1[SymbolKind$1["File"] = 1] = "File";
|
|
862
|
+
SymbolKind$1[SymbolKind$1["Module"] = 2] = "Module";
|
|
863
|
+
SymbolKind$1[SymbolKind$1["Namespace"] = 3] = "Namespace";
|
|
864
|
+
SymbolKind$1[SymbolKind$1["Package"] = 4] = "Package";
|
|
865
|
+
SymbolKind$1[SymbolKind$1["Class"] = 5] = "Class";
|
|
866
|
+
SymbolKind$1[SymbolKind$1["Method"] = 6] = "Method";
|
|
867
|
+
SymbolKind$1[SymbolKind$1["Property"] = 7] = "Property";
|
|
868
|
+
SymbolKind$1[SymbolKind$1["Field"] = 8] = "Field";
|
|
869
|
+
SymbolKind$1[SymbolKind$1["Constructor"] = 9] = "Constructor";
|
|
870
|
+
SymbolKind$1[SymbolKind$1["Enum"] = 10] = "Enum";
|
|
871
|
+
SymbolKind$1[SymbolKind$1["Interface"] = 11] = "Interface";
|
|
872
|
+
SymbolKind$1[SymbolKind$1["Function"] = 12] = "Function";
|
|
873
|
+
SymbolKind$1[SymbolKind$1["Variable"] = 13] = "Variable";
|
|
874
|
+
SymbolKind$1[SymbolKind$1["Constant"] = 14] = "Constant";
|
|
875
|
+
SymbolKind$1[SymbolKind$1["String"] = 15] = "String";
|
|
876
|
+
SymbolKind$1[SymbolKind$1["Number"] = 16] = "Number";
|
|
877
|
+
SymbolKind$1[SymbolKind$1["Boolean"] = 17] = "Boolean";
|
|
878
|
+
SymbolKind$1[SymbolKind$1["Array"] = 18] = "Array";
|
|
879
|
+
SymbolKind$1[SymbolKind$1["Object"] = 19] = "Object";
|
|
880
|
+
SymbolKind$1[SymbolKind$1["Key"] = 20] = "Key";
|
|
881
|
+
SymbolKind$1[SymbolKind$1["Null"] = 21] = "Null";
|
|
882
|
+
SymbolKind$1[SymbolKind$1["EnumMember"] = 22] = "EnumMember";
|
|
883
|
+
SymbolKind$1[SymbolKind$1["Struct"] = 23] = "Struct";
|
|
884
|
+
SymbolKind$1[SymbolKind$1["Event"] = 24] = "Event";
|
|
885
|
+
SymbolKind$1[SymbolKind$1["Operator"] = 25] = "Operator";
|
|
886
|
+
SymbolKind$1[SymbolKind$1["TypeParameter"] = 26] = "TypeParameter";
|
|
887
|
+
return SymbolKind$1;
|
|
888
|
+
})({});
|
|
889
|
+
let SymbolTag = /* @__PURE__ */ (function(SymbolTag$1) {
|
|
890
|
+
SymbolTag$1[SymbolTag$1["Deprecated"] = 1] = "Deprecated";
|
|
891
|
+
return SymbolTag$1;
|
|
892
|
+
})({});
|
|
893
|
+
let InlayHintKind = /* @__PURE__ */ (function(InlayHintKind$1) {
|
|
894
|
+
InlayHintKind$1[InlayHintKind$1["Type"] = 1] = "Type";
|
|
895
|
+
InlayHintKind$1[InlayHintKind$1["Parameter"] = 2] = "Parameter";
|
|
896
|
+
return InlayHintKind$1;
|
|
897
|
+
})({});
|
|
898
|
+
let TextDocumentSyncKind = /* @__PURE__ */ (function(TextDocumentSyncKind$1) {
|
|
899
|
+
TextDocumentSyncKind$1[TextDocumentSyncKind$1["None"] = 0] = "None";
|
|
900
|
+
TextDocumentSyncKind$1[TextDocumentSyncKind$1["Full"] = 1] = "Full";
|
|
901
|
+
TextDocumentSyncKind$1[TextDocumentSyncKind$1["Incremental"] = 2] = "Incremental";
|
|
902
|
+
return TextDocumentSyncKind$1;
|
|
903
|
+
})({});
|
|
904
|
+
let CompletionItemKind = /* @__PURE__ */ (function(CompletionItemKind$1) {
|
|
905
|
+
CompletionItemKind$1[CompletionItemKind$1["Text"] = 1] = "Text";
|
|
906
|
+
CompletionItemKind$1[CompletionItemKind$1["Method"] = 2] = "Method";
|
|
907
|
+
CompletionItemKind$1[CompletionItemKind$1["Function"] = 3] = "Function";
|
|
908
|
+
CompletionItemKind$1[CompletionItemKind$1["Constructor"] = 4] = "Constructor";
|
|
909
|
+
CompletionItemKind$1[CompletionItemKind$1["Field"] = 5] = "Field";
|
|
910
|
+
CompletionItemKind$1[CompletionItemKind$1["Variable"] = 6] = "Variable";
|
|
911
|
+
CompletionItemKind$1[CompletionItemKind$1["Class"] = 7] = "Class";
|
|
912
|
+
CompletionItemKind$1[CompletionItemKind$1["Interface"] = 8] = "Interface";
|
|
913
|
+
CompletionItemKind$1[CompletionItemKind$1["Module"] = 9] = "Module";
|
|
914
|
+
CompletionItemKind$1[CompletionItemKind$1["Property"] = 10] = "Property";
|
|
915
|
+
CompletionItemKind$1[CompletionItemKind$1["Unit"] = 11] = "Unit";
|
|
916
|
+
CompletionItemKind$1[CompletionItemKind$1["Value"] = 12] = "Value";
|
|
917
|
+
CompletionItemKind$1[CompletionItemKind$1["Enum"] = 13] = "Enum";
|
|
918
|
+
CompletionItemKind$1[CompletionItemKind$1["Keyword"] = 14] = "Keyword";
|
|
919
|
+
CompletionItemKind$1[CompletionItemKind$1["Snippet"] = 15] = "Snippet";
|
|
920
|
+
CompletionItemKind$1[CompletionItemKind$1["Color"] = 16] = "Color";
|
|
921
|
+
CompletionItemKind$1[CompletionItemKind$1["File"] = 17] = "File";
|
|
922
|
+
CompletionItemKind$1[CompletionItemKind$1["Reference"] = 18] = "Reference";
|
|
923
|
+
CompletionItemKind$1[CompletionItemKind$1["Folder"] = 19] = "Folder";
|
|
924
|
+
CompletionItemKind$1[CompletionItemKind$1["EnumMember"] = 20] = "EnumMember";
|
|
925
|
+
CompletionItemKind$1[CompletionItemKind$1["Constant"] = 21] = "Constant";
|
|
926
|
+
CompletionItemKind$1[CompletionItemKind$1["Struct"] = 22] = "Struct";
|
|
927
|
+
CompletionItemKind$1[CompletionItemKind$1["Event"] = 23] = "Event";
|
|
928
|
+
CompletionItemKind$1[CompletionItemKind$1["Operator"] = 24] = "Operator";
|
|
929
|
+
CompletionItemKind$1[CompletionItemKind$1["TypeParameter"] = 25] = "TypeParameter";
|
|
930
|
+
return CompletionItemKind$1;
|
|
931
|
+
})({});
|
|
932
|
+
let CompletionItemTag = /* @__PURE__ */ (function(CompletionItemTag$1) {
|
|
933
|
+
CompletionItemTag$1[CompletionItemTag$1["Deprecated"] = 1] = "Deprecated";
|
|
934
|
+
return CompletionItemTag$1;
|
|
935
|
+
})({});
|
|
936
|
+
let InsertTextFormat = /* @__PURE__ */ (function(InsertTextFormat$1) {
|
|
937
|
+
InsertTextFormat$1[InsertTextFormat$1["PlainText"] = 1] = "PlainText";
|
|
938
|
+
InsertTextFormat$1[InsertTextFormat$1["Snippet"] = 2] = "Snippet";
|
|
939
|
+
return InsertTextFormat$1;
|
|
940
|
+
})({});
|
|
941
|
+
let DocumentHighlightKind = /* @__PURE__ */ (function(DocumentHighlightKind$1) {
|
|
942
|
+
DocumentHighlightKind$1[DocumentHighlightKind$1["Text"] = 1] = "Text";
|
|
943
|
+
DocumentHighlightKind$1[DocumentHighlightKind$1["Read"] = 2] = "Read";
|
|
944
|
+
DocumentHighlightKind$1[DocumentHighlightKind$1["Write"] = 3] = "Write";
|
|
945
|
+
return DocumentHighlightKind$1;
|
|
946
|
+
})({});
|
|
947
|
+
let CodeActionKind = /* @__PURE__ */ (function(CodeActionKind$1) {
|
|
948
|
+
CodeActionKind$1["Empty"] = "";
|
|
949
|
+
CodeActionKind$1["QuickFix"] = "quickfix";
|
|
950
|
+
CodeActionKind$1["Refactor"] = "refactor";
|
|
951
|
+
CodeActionKind$1["RefactorExtract"] = "refactor.extract";
|
|
952
|
+
CodeActionKind$1["RefactorInline"] = "refactor.inline";
|
|
953
|
+
CodeActionKind$1["RefactorRewrite"] = "refactor.rewrite";
|
|
954
|
+
CodeActionKind$1["Source"] = "source";
|
|
955
|
+
CodeActionKind$1["SourceOrganizeImports"] = "source.organizeImports";
|
|
956
|
+
CodeActionKind$1["SourceFixAll"] = "source.fixAll";
|
|
957
|
+
return CodeActionKind$1;
|
|
958
|
+
})({});
|
|
959
|
+
let MarkupKind = /* @__PURE__ */ (function(MarkupKind$1) {
|
|
960
|
+
MarkupKind$1["PlainText"] = "plaintext";
|
|
961
|
+
MarkupKind$1["Markdown"] = "markdown";
|
|
962
|
+
return MarkupKind$1;
|
|
963
|
+
})({});
|
|
964
|
+
let DiagnosticSeverity = /* @__PURE__ */ (function(DiagnosticSeverity$1) {
|
|
965
|
+
DiagnosticSeverity$1[DiagnosticSeverity$1["Error"] = 1] = "Error";
|
|
966
|
+
DiagnosticSeverity$1[DiagnosticSeverity$1["Warning"] = 2] = "Warning";
|
|
967
|
+
DiagnosticSeverity$1[DiagnosticSeverity$1["Information"] = 3] = "Information";
|
|
968
|
+
DiagnosticSeverity$1[DiagnosticSeverity$1["Hint"] = 4] = "Hint";
|
|
969
|
+
return DiagnosticSeverity$1;
|
|
970
|
+
})({});
|
|
971
|
+
let DiagnosticTag = /* @__PURE__ */ (function(DiagnosticTag$1) {
|
|
972
|
+
DiagnosticTag$1[DiagnosticTag$1["Unnecessary"] = 1] = "Unnecessary";
|
|
973
|
+
DiagnosticTag$1[DiagnosticTag$1["Deprecated"] = 2] = "Deprecated";
|
|
974
|
+
return DiagnosticTag$1;
|
|
975
|
+
})({});
|
|
976
|
+
let CompletionTriggerKind = /* @__PURE__ */ (function(CompletionTriggerKind$1) {
|
|
977
|
+
CompletionTriggerKind$1[CompletionTriggerKind$1["Invoked"] = 1] = "Invoked";
|
|
978
|
+
CompletionTriggerKind$1[CompletionTriggerKind$1["TriggerCharacter"] = 2] = "TriggerCharacter";
|
|
979
|
+
CompletionTriggerKind$1[CompletionTriggerKind$1["TriggerForIncompleteCompletions"] = 3] = "TriggerForIncompleteCompletions";
|
|
980
|
+
return CompletionTriggerKind$1;
|
|
981
|
+
})({});
|
|
982
|
+
let SignatureHelpTriggerKind = /* @__PURE__ */ (function(SignatureHelpTriggerKind$1) {
|
|
983
|
+
SignatureHelpTriggerKind$1[SignatureHelpTriggerKind$1["Invoked"] = 1] = "Invoked";
|
|
984
|
+
SignatureHelpTriggerKind$1[SignatureHelpTriggerKind$1["TriggerCharacter"] = 2] = "TriggerCharacter";
|
|
985
|
+
SignatureHelpTriggerKind$1[SignatureHelpTriggerKind$1["ContentChange"] = 3] = "ContentChange";
|
|
986
|
+
return SignatureHelpTriggerKind$1;
|
|
987
|
+
})({});
|
|
988
|
+
let CodeActionTriggerKind = /* @__PURE__ */ (function(CodeActionTriggerKind$1) {
|
|
989
|
+
CodeActionTriggerKind$1[CodeActionTriggerKind$1["Invoked"] = 1] = "Invoked";
|
|
990
|
+
CodeActionTriggerKind$1[CodeActionTriggerKind$1["Automatic"] = 2] = "Automatic";
|
|
991
|
+
return CodeActionTriggerKind$1;
|
|
992
|
+
})({});
|
|
993
|
+
let TokenFormat = /* @__PURE__ */ (function(TokenFormat$1) {
|
|
994
|
+
TokenFormat$1["Relative"] = "relative";
|
|
995
|
+
return TokenFormat$1;
|
|
996
|
+
})({});
|
|
997
|
+
var Capability = class {
|
|
998
|
+
constructor(method) {
|
|
999
|
+
this.method = method;
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
const capabilities = {
|
|
1003
|
+
textDocumentImplementation: new Capability("textDocument/implementation"),
|
|
1004
|
+
textDocumentTypeDefinition: new Capability("textDocument/typeDefinition"),
|
|
1005
|
+
textDocumentDocumentColor: new Capability("textDocument/documentColor"),
|
|
1006
|
+
textDocumentColorPresentation: new Capability("textDocument/colorPresentation"),
|
|
1007
|
+
textDocumentFoldingRange: new Capability("textDocument/foldingRange"),
|
|
1008
|
+
textDocumentDeclaration: new Capability("textDocument/declaration"),
|
|
1009
|
+
textDocumentSelectionRange: new Capability("textDocument/selectionRange"),
|
|
1010
|
+
textDocumentPrepareCallHierarchy: new Capability("textDocument/prepareCallHierarchy"),
|
|
1011
|
+
textDocumentSemanticTokensFull: new Capability("textDocument/semanticTokens/full"),
|
|
1012
|
+
textDocumentSemanticTokensFullDelta: new Capability("textDocument/semanticTokens/full/delta"),
|
|
1013
|
+
textDocumentLinkedEditingRange: new Capability("textDocument/linkedEditingRange"),
|
|
1014
|
+
workspaceWillCreateFiles: new Capability("workspace/willCreateFiles"),
|
|
1015
|
+
workspaceWillRenameFiles: new Capability("workspace/willRenameFiles"),
|
|
1016
|
+
workspaceWillDeleteFiles: new Capability("workspace/willDeleteFiles"),
|
|
1017
|
+
textDocumentMoniker: new Capability("textDocument/moniker"),
|
|
1018
|
+
textDocumentPrepareTypeHierarchy: new Capability("textDocument/prepareTypeHierarchy"),
|
|
1019
|
+
textDocumentInlineValue: new Capability("textDocument/inlineValue"),
|
|
1020
|
+
textDocumentInlayHint: new Capability("textDocument/inlayHint"),
|
|
1021
|
+
textDocumentDiagnostic: new Capability("textDocument/diagnostic"),
|
|
1022
|
+
textDocumentInlineCompletion: new Capability("textDocument/inlineCompletion"),
|
|
1023
|
+
textDocumentWillSaveWaitUntil: new Capability("textDocument/willSaveWaitUntil"),
|
|
1024
|
+
textDocumentCompletion: new Capability("textDocument/completion"),
|
|
1025
|
+
textDocumentHover: new Capability("textDocument/hover"),
|
|
1026
|
+
textDocumentSignatureHelp: new Capability("textDocument/signatureHelp"),
|
|
1027
|
+
textDocumentDefinition: new Capability("textDocument/definition"),
|
|
1028
|
+
textDocumentReferences: new Capability("textDocument/references"),
|
|
1029
|
+
textDocumentDocumentHighlight: new Capability("textDocument/documentHighlight"),
|
|
1030
|
+
textDocumentDocumentSymbol: new Capability("textDocument/documentSymbol"),
|
|
1031
|
+
textDocumentCodeAction: new Capability("textDocument/codeAction"),
|
|
1032
|
+
workspaceSymbol: new Capability("workspace/symbol"),
|
|
1033
|
+
textDocumentCodeLens: new Capability("textDocument/codeLens"),
|
|
1034
|
+
textDocumentDocumentLink: new Capability("textDocument/documentLink"),
|
|
1035
|
+
textDocumentFormatting: new Capability("textDocument/formatting"),
|
|
1036
|
+
textDocumentRangeFormatting: new Capability("textDocument/rangeFormatting"),
|
|
1037
|
+
textDocumentRangesFormatting: new Capability("textDocument/rangesFormatting"),
|
|
1038
|
+
textDocumentOnTypeFormatting: new Capability("textDocument/onTypeFormatting"),
|
|
1039
|
+
textDocumentRename: new Capability("textDocument/rename"),
|
|
1040
|
+
workspaceExecuteCommand: new Capability("workspace/executeCommand"),
|
|
1041
|
+
workspaceDidCreateFiles: new Capability("workspace/didCreateFiles"),
|
|
1042
|
+
workspaceDidRenameFiles: new Capability("workspace/didRenameFiles"),
|
|
1043
|
+
workspaceDidDeleteFiles: new Capability("workspace/didDeleteFiles"),
|
|
1044
|
+
workspaceDidChangeConfiguration: new Capability("workspace/didChangeConfiguration"),
|
|
1045
|
+
textDocumentDidOpen: new Capability("textDocument/didOpen"),
|
|
1046
|
+
textDocumentDidChange: new Capability("textDocument/didChange"),
|
|
1047
|
+
textDocumentDidClose: new Capability("textDocument/didClose"),
|
|
1048
|
+
textDocumentDidSave: new Capability("textDocument/didSave"),
|
|
1049
|
+
textDocumentWillSave: new Capability("textDocument/willSave"),
|
|
1050
|
+
workspaceDidChangeWatchedFiles: new Capability("workspace/didChangeWatchedFiles")
|
|
1051
|
+
};
|
|
1052
|
+
const api = contract({
|
|
1053
|
+
server: {
|
|
1054
|
+
textDocumentImplementation: unverifiedRequest({ method: "textDocument/implementation" }),
|
|
1055
|
+
textDocumentTypeDefinition: unverifiedRequest({ method: "textDocument/typeDefinition" }),
|
|
1056
|
+
textDocumentDocumentColor: unverifiedRequest({ method: "textDocument/documentColor" }),
|
|
1057
|
+
textDocumentColorPresentation: unverifiedRequest({ method: "textDocument/colorPresentation" }),
|
|
1058
|
+
textDocumentFoldingRange: unverifiedRequest({ method: "textDocument/foldingRange" }),
|
|
1059
|
+
textDocumentDeclaration: unverifiedRequest({ method: "textDocument/declaration" }),
|
|
1060
|
+
textDocumentSelectionRange: unverifiedRequest({ method: "textDocument/selectionRange" }),
|
|
1061
|
+
textDocumentPrepareCallHierarchy: unverifiedRequest({ method: "textDocument/prepareCallHierarchy" }),
|
|
1062
|
+
callHierarchyIncomingCalls: unverifiedRequest({ method: "callHierarchy/incomingCalls" }),
|
|
1063
|
+
callHierarchyOutgoingCalls: unverifiedRequest({ method: "callHierarchy/outgoingCalls" }),
|
|
1064
|
+
textDocumentSemanticTokensFull: unverifiedRequest({ method: "textDocument/semanticTokens/full" }),
|
|
1065
|
+
textDocumentSemanticTokensFullDelta: unverifiedRequest({ method: "textDocument/semanticTokens/full/delta" }),
|
|
1066
|
+
textDocumentSemanticTokensRange: unverifiedRequest({ method: "textDocument/semanticTokens/range" }),
|
|
1067
|
+
textDocumentLinkedEditingRange: unverifiedRequest({ method: "textDocument/linkedEditingRange" }),
|
|
1068
|
+
workspaceWillCreateFiles: unverifiedRequest({ method: "workspace/willCreateFiles" }),
|
|
1069
|
+
workspaceWillRenameFiles: unverifiedRequest({ method: "workspace/willRenameFiles" }),
|
|
1070
|
+
workspaceWillDeleteFiles: unverifiedRequest({ method: "workspace/willDeleteFiles" }),
|
|
1071
|
+
textDocumentMoniker: unverifiedRequest({ method: "textDocument/moniker" }),
|
|
1072
|
+
textDocumentPrepareTypeHierarchy: unverifiedRequest({ method: "textDocument/prepareTypeHierarchy" }),
|
|
1073
|
+
typeHierarchySupertypes: unverifiedRequest({ method: "typeHierarchy/supertypes" }),
|
|
1074
|
+
typeHierarchySubtypes: unverifiedRequest({ method: "typeHierarchy/subtypes" }),
|
|
1075
|
+
textDocumentInlineValue: unverifiedRequest({ method: "textDocument/inlineValue" }),
|
|
1076
|
+
textDocumentInlayHint: unverifiedRequest({ method: "textDocument/inlayHint" }),
|
|
1077
|
+
inlayHintResolve: unverifiedRequest({ method: "inlayHint/resolve" }),
|
|
1078
|
+
textDocumentDiagnostic: unverifiedRequest({ method: "textDocument/diagnostic" }),
|
|
1079
|
+
workspaceDiagnostic: unverifiedRequest({ method: "workspace/diagnostic" }),
|
|
1080
|
+
textDocumentInlineCompletion: unverifiedRequest({ method: "textDocument/inlineCompletion" }),
|
|
1081
|
+
initialize: unverifiedRequest({ method: "initialize" }),
|
|
1082
|
+
shutdown: unverifiedRequest({ method: "shutdown" }),
|
|
1083
|
+
textDocumentWillSaveWaitUntil: unverifiedRequest({ method: "textDocument/willSaveWaitUntil" }),
|
|
1084
|
+
textDocumentCompletion: unverifiedRequest({ method: "textDocument/completion" }),
|
|
1085
|
+
completionItemResolve: unverifiedRequest({ method: "completionItem/resolve" }),
|
|
1086
|
+
textDocumentHover: unverifiedRequest({ method: "textDocument/hover" }),
|
|
1087
|
+
textDocumentSignatureHelp: unverifiedRequest({ method: "textDocument/signatureHelp" }),
|
|
1088
|
+
textDocumentDefinition: unverifiedRequest({ method: "textDocument/definition" }),
|
|
1089
|
+
textDocumentReferences: unverifiedRequest({ method: "textDocument/references" }),
|
|
1090
|
+
textDocumentDocumentHighlight: unverifiedRequest({ method: "textDocument/documentHighlight" }),
|
|
1091
|
+
textDocumentDocumentSymbol: unverifiedRequest({ method: "textDocument/documentSymbol" }),
|
|
1092
|
+
textDocumentCodeAction: unverifiedRequest({ method: "textDocument/codeAction" }),
|
|
1093
|
+
codeActionResolve: unverifiedRequest({ method: "codeAction/resolve" }),
|
|
1094
|
+
workspaceSymbol: unverifiedRequest({ method: "workspace/symbol" }),
|
|
1095
|
+
workspaceSymbolResolve: unverifiedRequest({ method: "workspaceSymbol/resolve" }),
|
|
1096
|
+
textDocumentCodeLens: unverifiedRequest({ method: "textDocument/codeLens" }),
|
|
1097
|
+
codeLensResolve: unverifiedRequest({ method: "codeLens/resolve" }),
|
|
1098
|
+
textDocumentDocumentLink: unverifiedRequest({ method: "textDocument/documentLink" }),
|
|
1099
|
+
documentLinkResolve: unverifiedRequest({ method: "documentLink/resolve" }),
|
|
1100
|
+
textDocumentFormatting: unverifiedRequest({ method: "textDocument/formatting" }),
|
|
1101
|
+
textDocumentRangeFormatting: unverifiedRequest({ method: "textDocument/rangeFormatting" }),
|
|
1102
|
+
textDocumentRangesFormatting: unverifiedRequest({ method: "textDocument/rangesFormatting" }),
|
|
1103
|
+
textDocumentOnTypeFormatting: unverifiedRequest({ method: "textDocument/onTypeFormatting" }),
|
|
1104
|
+
textDocumentRename: unverifiedRequest({ method: "textDocument/rename" }),
|
|
1105
|
+
textDocumentPrepareRename: unverifiedRequest({ method: "textDocument/prepareRename" }),
|
|
1106
|
+
workspaceExecuteCommand: unverifiedRequest({ method: "workspace/executeCommand" }),
|
|
1107
|
+
workspaceDidChangeWorkspaceFolders: unverifiedNotification({ method: "workspace/didChangeWorkspaceFolders" }),
|
|
1108
|
+
windowWorkDoneProgressCancel: unverifiedNotification({ method: "window/workDoneProgress/cancel" }),
|
|
1109
|
+
workspaceDidCreateFiles: unverifiedNotification({ method: "workspace/didCreateFiles" }),
|
|
1110
|
+
workspaceDidRenameFiles: unverifiedNotification({ method: "workspace/didRenameFiles" }),
|
|
1111
|
+
workspaceDidDeleteFiles: unverifiedNotification({ method: "workspace/didDeleteFiles" }),
|
|
1112
|
+
notebookDocumentDidOpen: unverifiedNotification({ method: "notebookDocument/didOpen" }),
|
|
1113
|
+
notebookDocumentDidChange: unverifiedNotification({ method: "notebookDocument/didChange" }),
|
|
1114
|
+
notebookDocumentDidSave: unverifiedNotification({ method: "notebookDocument/didSave" }),
|
|
1115
|
+
notebookDocumentDidClose: unverifiedNotification({ method: "notebookDocument/didClose" }),
|
|
1116
|
+
initialized: unverifiedNotification({ method: "initialized" }),
|
|
1117
|
+
exit: unverifiedNotification({ method: "exit" }),
|
|
1118
|
+
workspaceDidChangeConfiguration: unverifiedNotification({ method: "workspace/didChangeConfiguration" }),
|
|
1119
|
+
textDocumentDidOpen: unverifiedNotification({ method: "textDocument/didOpen" }),
|
|
1120
|
+
textDocumentDidChange: unverifiedNotification({ method: "textDocument/didChange" }),
|
|
1121
|
+
textDocumentDidClose: unverifiedNotification({ method: "textDocument/didClose" }),
|
|
1122
|
+
textDocumentDidSave: unverifiedNotification({ method: "textDocument/didSave" }),
|
|
1123
|
+
textDocumentWillSave: unverifiedNotification({ method: "textDocument/willSave" }),
|
|
1124
|
+
workspaceDidChangeWatchedFiles: unverifiedNotification({ method: "workspace/didChangeWatchedFiles" }),
|
|
1125
|
+
setTrace: unverifiedNotification({ method: "$/setTrace" }),
|
|
1126
|
+
cancelRequest: unverifiedNotification({ method: "$/cancelRequest" }),
|
|
1127
|
+
progress: unverifiedNotification({ method: "$/progress" })
|
|
1128
|
+
},
|
|
1129
|
+
client: {
|
|
1130
|
+
workspaceWorkspaceFolders: unverifiedRequest({ method: "workspace/workspaceFolders" }).optional(),
|
|
1131
|
+
workspaceConfiguration: unverifiedRequest({ method: "workspace/configuration" }).optional(),
|
|
1132
|
+
workspaceFoldingRangeRefresh: unverifiedRequest({ method: "workspace/foldingRange/refresh" }).optional(),
|
|
1133
|
+
windowWorkDoneProgressCreate: unverifiedRequest({ method: "window/workDoneProgress/create" }).optional(),
|
|
1134
|
+
workspaceSemanticTokensRefresh: unverifiedRequest({ method: "workspace/semanticTokens/refresh" }).optional(),
|
|
1135
|
+
windowShowDocument: unverifiedRequest({ method: "window/showDocument" }).optional(),
|
|
1136
|
+
workspaceInlineValueRefresh: unverifiedRequest({ method: "workspace/inlineValue/refresh" }).optional(),
|
|
1137
|
+
workspaceInlayHintRefresh: unverifiedRequest({ method: "workspace/inlayHint/refresh" }).optional(),
|
|
1138
|
+
workspaceDiagnosticRefresh: unverifiedRequest({ method: "workspace/diagnostic/refresh" }).optional(),
|
|
1139
|
+
clientRegisterCapability: unverifiedRequest({ method: "client/registerCapability" }).optional(),
|
|
1140
|
+
clientUnregisterCapability: unverifiedRequest({ method: "client/unregisterCapability" }).optional(),
|
|
1141
|
+
windowShowMessageRequest: unverifiedRequest({ method: "window/showMessageRequest" }).optional(),
|
|
1142
|
+
workspaceCodeLensRefresh: unverifiedRequest({ method: "workspace/codeLens/refresh" }).optional(),
|
|
1143
|
+
workspaceApplyEdit: unverifiedRequest({ method: "workspace/applyEdit" }).optional(),
|
|
1144
|
+
windowShowMessage: unverifiedNotification({ method: "window/showMessage" }),
|
|
1145
|
+
windowLogMessage: unverifiedNotification({ method: "window/logMessage" }),
|
|
1146
|
+
telemetryEvent: unverifiedNotification({ method: "telemetry/event" }),
|
|
1147
|
+
textDocumentPublishDiagnostics: unverifiedNotification({ method: "textDocument/publishDiagnostics" }),
|
|
1148
|
+
logTrace: unverifiedNotification({ method: "$/logTrace" }),
|
|
1149
|
+
cancelRequest: unverifiedNotification({ method: "$/cancelRequest" }),
|
|
1150
|
+
progress: unverifiedNotification({ method: "$/progress" })
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
function assertTargetTextModel(input, expectedTextModel) {
|
|
1154
|
+
if (input.textModel !== expectedTextModel) throw new Error(`Expected text model to be ${expectedTextModel}, but got ${input.textModel}`);
|
|
1155
|
+
return input;
|
|
1156
|
+
}
|
|
1157
|
+
var Disposable = class {
|
|
1158
|
+
static None = Object.freeze({ dispose() {
|
|
1159
|
+
} });
|
|
1160
|
+
_store = new DisposableStore();
|
|
1161
|
+
constructor() {
|
|
1162
|
+
}
|
|
1163
|
+
dispose() {
|
|
1164
|
+
this._store.dispose();
|
|
1165
|
+
}
|
|
1166
|
+
_register(t) {
|
|
1167
|
+
if (t === this) throw new Error("Cannot register a disposable on itself!");
|
|
1168
|
+
return this._store.add(t);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
var DisposableStore = class DisposableStore {
|
|
1172
|
+
static DISABLE_DISPOSED_WARNING = false;
|
|
1173
|
+
_toDispose = /* @__PURE__ */ new Set();
|
|
1174
|
+
_isDisposed = false;
|
|
1175
|
+
dispose() {
|
|
1176
|
+
if (this._isDisposed) return;
|
|
1177
|
+
this._isDisposed = true;
|
|
1178
|
+
this.clear();
|
|
1179
|
+
}
|
|
1180
|
+
clear() {
|
|
1181
|
+
if (this._toDispose.size === 0) return;
|
|
1182
|
+
try {
|
|
1183
|
+
for (const item of this._toDispose) item.dispose();
|
|
1184
|
+
} finally {
|
|
1185
|
+
this._toDispose.clear();
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
add(t) {
|
|
1189
|
+
if (!t) return t;
|
|
1190
|
+
if (t === this) throw new Error("Cannot register a disposable on itself!");
|
|
1191
|
+
if (this._isDisposed) {
|
|
1192
|
+
console.warn((/* @__PURE__ */ new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!")).stack);
|
|
1193
|
+
} else this._toDispose.add(t);
|
|
1194
|
+
return t;
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
const lspCodeActionKindToMonacoCodeActionKind = /* @__PURE__ */ new Map([
|
|
1198
|
+
[CodeActionKind.Empty, ""],
|
|
1199
|
+
[CodeActionKind.QuickFix, "quickfix"],
|
|
1200
|
+
[CodeActionKind.Refactor, "refactor"],
|
|
1201
|
+
[CodeActionKind.RefactorExtract, "refactor.extract"],
|
|
1202
|
+
[CodeActionKind.RefactorInline, "refactor.inline"],
|
|
1203
|
+
[CodeActionKind.RefactorRewrite, "refactor.rewrite"],
|
|
1204
|
+
[CodeActionKind.Source, "source"],
|
|
1205
|
+
[CodeActionKind.SourceOrganizeImports, "source.organizeImports"],
|
|
1206
|
+
[CodeActionKind.SourceFixAll, "source.fixAll"]
|
|
1207
|
+
]);
|
|
1208
|
+
function toMonacoCodeActionKind(kind) {
|
|
1209
|
+
if (!kind) return;
|
|
1210
|
+
return lspCodeActionKindToMonacoCodeActionKind.get(kind) ?? kind;
|
|
1211
|
+
}
|
|
1212
|
+
const monacoCodeActionTriggerTypeToLspCodeActionTriggerKind = /* @__PURE__ */ new Map([[editor.languages.CodeActionTriggerType.Invoke, CodeActionTriggerKind.Invoked], [editor.languages.CodeActionTriggerType.Auto, CodeActionTriggerKind.Automatic]]);
|
|
1213
|
+
function toLspCodeActionTriggerKind(monacoTrigger) {
|
|
1214
|
+
return monacoCodeActionTriggerTypeToLspCodeActionTriggerKind.get(monacoTrigger) ?? CodeActionTriggerKind.Invoked;
|
|
1215
|
+
}
|
|
1216
|
+
const lspCompletionItemKindToMonacoCompletionItemKind = /* @__PURE__ */ new Map([
|
|
1217
|
+
[CompletionItemKind.Text, editor.languages.CompletionItemKind.Text],
|
|
1218
|
+
[CompletionItemKind.Method, editor.languages.CompletionItemKind.Method],
|
|
1219
|
+
[CompletionItemKind.Function, editor.languages.CompletionItemKind.Function],
|
|
1220
|
+
[CompletionItemKind.Constructor, editor.languages.CompletionItemKind.Constructor],
|
|
1221
|
+
[CompletionItemKind.Field, editor.languages.CompletionItemKind.Field],
|
|
1222
|
+
[CompletionItemKind.Variable, editor.languages.CompletionItemKind.Variable],
|
|
1223
|
+
[CompletionItemKind.Class, editor.languages.CompletionItemKind.Class],
|
|
1224
|
+
[CompletionItemKind.Interface, editor.languages.CompletionItemKind.Interface],
|
|
1225
|
+
[CompletionItemKind.Module, editor.languages.CompletionItemKind.Module],
|
|
1226
|
+
[CompletionItemKind.Property, editor.languages.CompletionItemKind.Property],
|
|
1227
|
+
[CompletionItemKind.Unit, editor.languages.CompletionItemKind.Unit],
|
|
1228
|
+
[CompletionItemKind.Value, editor.languages.CompletionItemKind.Value],
|
|
1229
|
+
[CompletionItemKind.Enum, editor.languages.CompletionItemKind.Enum],
|
|
1230
|
+
[CompletionItemKind.Keyword, editor.languages.CompletionItemKind.Keyword],
|
|
1231
|
+
[CompletionItemKind.Snippet, editor.languages.CompletionItemKind.Snippet],
|
|
1232
|
+
[CompletionItemKind.Color, editor.languages.CompletionItemKind.Color],
|
|
1233
|
+
[CompletionItemKind.File, editor.languages.CompletionItemKind.File],
|
|
1234
|
+
[CompletionItemKind.Reference, editor.languages.CompletionItemKind.Reference],
|
|
1235
|
+
[CompletionItemKind.Folder, editor.languages.CompletionItemKind.Folder],
|
|
1236
|
+
[CompletionItemKind.EnumMember, editor.languages.CompletionItemKind.EnumMember],
|
|
1237
|
+
[CompletionItemKind.Constant, editor.languages.CompletionItemKind.Constant],
|
|
1238
|
+
[CompletionItemKind.Struct, editor.languages.CompletionItemKind.Struct],
|
|
1239
|
+
[CompletionItemKind.Event, editor.languages.CompletionItemKind.Event],
|
|
1240
|
+
[CompletionItemKind.Operator, editor.languages.CompletionItemKind.Operator],
|
|
1241
|
+
[CompletionItemKind.TypeParameter, editor.languages.CompletionItemKind.TypeParameter]
|
|
1242
|
+
]);
|
|
1243
|
+
function toMonacoCompletionItemKind(kind) {
|
|
1244
|
+
if (!kind) return editor.languages.CompletionItemKind.Text;
|
|
1245
|
+
return lspCompletionItemKindToMonacoCompletionItemKind.get(kind) ?? editor.languages.CompletionItemKind.Text;
|
|
1246
|
+
}
|
|
1247
|
+
const lspCompletionItemTagToMonacoCompletionItemTag = /* @__PURE__ */ new Map([[CompletionItemTag.Deprecated, editor.languages.CompletionItemTag.Deprecated]]);
|
|
1248
|
+
function toMonacoCompletionItemTag(tag) {
|
|
1249
|
+
return lspCompletionItemTagToMonacoCompletionItemTag.get(tag);
|
|
1250
|
+
}
|
|
1251
|
+
const monacoCompletionTriggerKindToLspCompletionTriggerKind = /* @__PURE__ */ new Map([
|
|
1252
|
+
[editor.languages.CompletionTriggerKind.Invoke, CompletionTriggerKind.Invoked],
|
|
1253
|
+
[editor.languages.CompletionTriggerKind.TriggerCharacter, CompletionTriggerKind.TriggerCharacter],
|
|
1254
|
+
[editor.languages.CompletionTriggerKind.TriggerForIncompleteCompletions, CompletionTriggerKind.TriggerForIncompleteCompletions]
|
|
1255
|
+
]);
|
|
1256
|
+
function toLspCompletionTriggerKind(monacoKind) {
|
|
1257
|
+
return monacoCompletionTriggerKindToLspCompletionTriggerKind.get(monacoKind) ?? CompletionTriggerKind.Invoked;
|
|
1258
|
+
}
|
|
1259
|
+
const lspInsertTextFormatToMonacoInsertTextRules = /* @__PURE__ */ new Map([[InsertTextFormat.Snippet, editor.languages.CompletionItemInsertTextRule.InsertAsSnippet]]);
|
|
1260
|
+
function toMonacoInsertTextRules(format) {
|
|
1261
|
+
if (!format) return;
|
|
1262
|
+
return lspInsertTextFormatToMonacoInsertTextRules.get(format);
|
|
1263
|
+
}
|
|
1264
|
+
const lspSymbolKindToMonacoSymbolKind = /* @__PURE__ */ new Map([
|
|
1265
|
+
[SymbolKind.File, editor.languages.SymbolKind.File],
|
|
1266
|
+
[SymbolKind.Module, editor.languages.SymbolKind.Module],
|
|
1267
|
+
[SymbolKind.Namespace, editor.languages.SymbolKind.Namespace],
|
|
1268
|
+
[SymbolKind.Package, editor.languages.SymbolKind.Package],
|
|
1269
|
+
[SymbolKind.Class, editor.languages.SymbolKind.Class],
|
|
1270
|
+
[SymbolKind.Method, editor.languages.SymbolKind.Method],
|
|
1271
|
+
[SymbolKind.Property, editor.languages.SymbolKind.Property],
|
|
1272
|
+
[SymbolKind.Field, editor.languages.SymbolKind.Field],
|
|
1273
|
+
[SymbolKind.Constructor, editor.languages.SymbolKind.Constructor],
|
|
1274
|
+
[SymbolKind.Enum, editor.languages.SymbolKind.Enum],
|
|
1275
|
+
[SymbolKind.Interface, editor.languages.SymbolKind.Interface],
|
|
1276
|
+
[SymbolKind.Function, editor.languages.SymbolKind.Function],
|
|
1277
|
+
[SymbolKind.Variable, editor.languages.SymbolKind.Variable],
|
|
1278
|
+
[SymbolKind.Constant, editor.languages.SymbolKind.Constant],
|
|
1279
|
+
[SymbolKind.String, editor.languages.SymbolKind.String],
|
|
1280
|
+
[SymbolKind.Number, editor.languages.SymbolKind.Number],
|
|
1281
|
+
[SymbolKind.Boolean, editor.languages.SymbolKind.Boolean],
|
|
1282
|
+
[SymbolKind.Array, editor.languages.SymbolKind.Array],
|
|
1283
|
+
[SymbolKind.Object, editor.languages.SymbolKind.Object],
|
|
1284
|
+
[SymbolKind.Key, editor.languages.SymbolKind.Key],
|
|
1285
|
+
[SymbolKind.Null, editor.languages.SymbolKind.Null],
|
|
1286
|
+
[SymbolKind.EnumMember, editor.languages.SymbolKind.EnumMember],
|
|
1287
|
+
[SymbolKind.Struct, editor.languages.SymbolKind.Struct],
|
|
1288
|
+
[SymbolKind.Event, editor.languages.SymbolKind.Event],
|
|
1289
|
+
[SymbolKind.Operator, editor.languages.SymbolKind.Operator],
|
|
1290
|
+
[SymbolKind.TypeParameter, editor.languages.SymbolKind.TypeParameter]
|
|
1291
|
+
]);
|
|
1292
|
+
function toMonacoSymbolKind(kind) {
|
|
1293
|
+
return lspSymbolKindToMonacoSymbolKind.get(kind) ?? editor.languages.SymbolKind.File;
|
|
1294
|
+
}
|
|
1295
|
+
const lspSymbolTagToMonacoSymbolTag = /* @__PURE__ */ new Map([[SymbolTag.Deprecated, editor.languages.SymbolTag.Deprecated]]);
|
|
1296
|
+
function toMonacoSymbolTag(tag) {
|
|
1297
|
+
return lspSymbolTagToMonacoSymbolTag.get(tag);
|
|
1298
|
+
}
|
|
1299
|
+
const lspDocumentHighlightKindToMonacoDocumentHighlightKind = /* @__PURE__ */ new Map([
|
|
1300
|
+
[DocumentHighlightKind.Text, editor.languages.DocumentHighlightKind.Text],
|
|
1301
|
+
[DocumentHighlightKind.Read, editor.languages.DocumentHighlightKind.Read],
|
|
1302
|
+
[DocumentHighlightKind.Write, editor.languages.DocumentHighlightKind.Write]
|
|
1303
|
+
]);
|
|
1304
|
+
function toMonacoDocumentHighlightKind(kind) {
|
|
1305
|
+
if (!kind) return editor.languages.DocumentHighlightKind.Text;
|
|
1306
|
+
return lspDocumentHighlightKindToMonacoDocumentHighlightKind.get(kind) ?? editor.languages.DocumentHighlightKind.Text;
|
|
1307
|
+
}
|
|
1308
|
+
const lspFoldingRangeKindToMonacoFoldingRangeKind = /* @__PURE__ */ new Map([
|
|
1309
|
+
[FoldingRangeKind.Comment, editor.languages.FoldingRangeKind.Comment],
|
|
1310
|
+
[FoldingRangeKind.Imports, editor.languages.FoldingRangeKind.Imports],
|
|
1311
|
+
[FoldingRangeKind.Region, editor.languages.FoldingRangeKind.Region]
|
|
1312
|
+
]);
|
|
1313
|
+
function toMonacoFoldingRangeKind(kind) {
|
|
1314
|
+
if (!kind) return;
|
|
1315
|
+
return lspFoldingRangeKindToMonacoFoldingRangeKind.get(kind);
|
|
1316
|
+
}
|
|
1317
|
+
const monacoMarkerSeverityToLspDiagnosticSeverity = /* @__PURE__ */ new Map([
|
|
1318
|
+
[editor.MarkerSeverity.Error, DiagnosticSeverity.Error],
|
|
1319
|
+
[editor.MarkerSeverity.Warning, DiagnosticSeverity.Warning],
|
|
1320
|
+
[editor.MarkerSeverity.Info, DiagnosticSeverity.Information],
|
|
1321
|
+
[editor.MarkerSeverity.Hint, DiagnosticSeverity.Hint]
|
|
1322
|
+
]);
|
|
1323
|
+
function toLspDiagnosticSeverity(severity) {
|
|
1324
|
+
return monacoMarkerSeverityToLspDiagnosticSeverity.get(severity) ?? DiagnosticSeverity.Error;
|
|
1325
|
+
}
|
|
1326
|
+
const lspDiagnosticSeverityToMonacoMarkerSeverity = /* @__PURE__ */ new Map([
|
|
1327
|
+
[DiagnosticSeverity.Error, editor.MarkerSeverity.Error],
|
|
1328
|
+
[DiagnosticSeverity.Warning, editor.MarkerSeverity.Warning],
|
|
1329
|
+
[DiagnosticSeverity.Information, editor.MarkerSeverity.Info],
|
|
1330
|
+
[DiagnosticSeverity.Hint, editor.MarkerSeverity.Hint]
|
|
1331
|
+
]);
|
|
1332
|
+
function toMonacoDiagnosticSeverity(severity) {
|
|
1333
|
+
if (!severity) return editor.MarkerSeverity.Error;
|
|
1334
|
+
return lspDiagnosticSeverityToMonacoMarkerSeverity.get(severity) ?? editor.MarkerSeverity.Error;
|
|
1335
|
+
}
|
|
1336
|
+
const lspDiagnosticTagToMonacoMarkerTag = /* @__PURE__ */ new Map([[DiagnosticTag.Unnecessary, editor.MarkerTag.Unnecessary], [DiagnosticTag.Deprecated, editor.MarkerTag.Deprecated]]);
|
|
1337
|
+
function toMonacoDiagnosticTag(tag) {
|
|
1338
|
+
return lspDiagnosticTagToMonacoMarkerTag.get(tag);
|
|
1339
|
+
}
|
|
1340
|
+
const monacoSignatureHelpTriggerKindToLspSignatureHelpTriggerKind = /* @__PURE__ */ new Map([
|
|
1341
|
+
[editor.languages.SignatureHelpTriggerKind.Invoke, SignatureHelpTriggerKind.Invoked],
|
|
1342
|
+
[editor.languages.SignatureHelpTriggerKind.TriggerCharacter, SignatureHelpTriggerKind.TriggerCharacter],
|
|
1343
|
+
[editor.languages.SignatureHelpTriggerKind.ContentChange, SignatureHelpTriggerKind.ContentChange]
|
|
1344
|
+
]);
|
|
1345
|
+
function toLspSignatureHelpTriggerKind(monacoKind) {
|
|
1346
|
+
return monacoSignatureHelpTriggerKindToLspSignatureHelpTriggerKind.get(monacoKind) ?? SignatureHelpTriggerKind.Invoked;
|
|
1347
|
+
}
|
|
1348
|
+
function toMonacoCommand(command) {
|
|
1349
|
+
if (!command) return;
|
|
1350
|
+
return {
|
|
1351
|
+
id: command.command,
|
|
1352
|
+
title: command.title,
|
|
1353
|
+
arguments: command.arguments
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
const lspInlayHintKindToMonacoInlayHintKind = /* @__PURE__ */ new Map([[InlayHintKind.Type, editor.languages.InlayHintKind.Type], [InlayHintKind.Parameter, editor.languages.InlayHintKind.Parameter]]);
|
|
1357
|
+
function toMonacoInlayHintKind(kind) {
|
|
1358
|
+
if (!kind) return editor.languages.InlayHintKind.Type;
|
|
1359
|
+
return lspInlayHintKindToMonacoInlayHintKind.get(kind) ?? editor.languages.InlayHintKind.Type;
|
|
1360
|
+
}
|
|
1361
|
+
function toMonacoLocation(location, client) {
|
|
1362
|
+
if ("targetUri" in location) {
|
|
1363
|
+
const translatedRange = client.bridge.translateBackRange({ uri: location.targetUri }, location.targetRange);
|
|
1364
|
+
return {
|
|
1365
|
+
uri: translatedRange.textModel.uri,
|
|
1366
|
+
range: translatedRange.range,
|
|
1367
|
+
originSelectionRange: location.originSelectionRange ? client.bridge.translateBackRange({ uri: location.targetUri }, location.originSelectionRange).range : void 0,
|
|
1368
|
+
targetSelectionRange: location.targetSelectionRange ? client.bridge.translateBackRange({ uri: location.targetUri }, location.targetSelectionRange).range : void 0
|
|
1369
|
+
};
|
|
1370
|
+
} else {
|
|
1371
|
+
const translatedRange = client.bridge.translateBackRange({ uri: location.uri }, location.range);
|
|
1372
|
+
return {
|
|
1373
|
+
uri: translatedRange.textModel.uri,
|
|
1374
|
+
range: translatedRange.range
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function toMonacoLanguageSelector(s) {
|
|
1379
|
+
if (!s || s.length === 0) return { language: "*" };
|
|
1380
|
+
return s.map((s$1) => {
|
|
1381
|
+
if ("notebook" in s$1) if (typeof s$1.notebook === "string") return {
|
|
1382
|
+
notebookType: s$1.notebook,
|
|
1383
|
+
language: s$1.language
|
|
1384
|
+
};
|
|
1385
|
+
else return {
|
|
1386
|
+
notebookType: s$1.notebook.notebookType,
|
|
1387
|
+
language: s$1.language,
|
|
1388
|
+
pattern: s$1.notebook.pattern,
|
|
1389
|
+
scheme: s$1.notebook.scheme
|
|
1390
|
+
};
|
|
1391
|
+
else return {
|
|
1392
|
+
language: s$1.language,
|
|
1393
|
+
pattern: s$1.pattern,
|
|
1394
|
+
scheme: s$1.scheme
|
|
1395
|
+
};
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
function matchesDocumentSelector(model, selector) {
|
|
1399
|
+
if (!selector) return true;
|
|
1400
|
+
const languageId = model.getLanguageId();
|
|
1401
|
+
model.uri.toString(true);
|
|
1402
|
+
if (!selector || selector.length === 0) return true;
|
|
1403
|
+
for (const filter of selector) {
|
|
1404
|
+
if (filter.language && filter.language !== "*" && filter.language !== languageId) continue;
|
|
1405
|
+
return true;
|
|
1406
|
+
}
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
function toDiagnosticMarker(diagnostic) {
|
|
1410
|
+
const marker = {
|
|
1411
|
+
severity: toMonacoDiagnosticSeverity(diagnostic.severity),
|
|
1412
|
+
startLineNumber: diagnostic.range.start.line + 1,
|
|
1413
|
+
startColumn: diagnostic.range.start.character + 1,
|
|
1414
|
+
endLineNumber: diagnostic.range.end.line + 1,
|
|
1415
|
+
endColumn: diagnostic.range.end.character + 1,
|
|
1416
|
+
message: diagnostic.message,
|
|
1417
|
+
source: diagnostic.source,
|
|
1418
|
+
code: typeof diagnostic.code === "string" ? diagnostic.code : diagnostic.code?.toString()
|
|
1419
|
+
};
|
|
1420
|
+
if (diagnostic.tags) marker.tags = diagnostic.tags.map((tag) => toMonacoDiagnosticTag(tag)).filter((tag) => tag !== void 0);
|
|
1421
|
+
if (diagnostic.relatedInformation) marker.relatedInformation = diagnostic.relatedInformation.map((info) => ({
|
|
1422
|
+
resource: editor.Uri.parse(info.location.uri),
|
|
1423
|
+
startLineNumber: info.location.range.start.line + 1,
|
|
1424
|
+
startColumn: info.location.range.start.character + 1,
|
|
1425
|
+
endLineNumber: info.location.range.end.line + 1,
|
|
1426
|
+
endColumn: info.location.range.end.character + 1,
|
|
1427
|
+
message: info.message
|
|
1428
|
+
}));
|
|
1429
|
+
return marker;
|
|
1430
|
+
}
|
|
1431
|
+
var LspCompletionFeature = class extends Disposable {
|
|
1432
|
+
constructor(_connection) {
|
|
1433
|
+
super();
|
|
1434
|
+
this._connection = _connection;
|
|
1435
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { completion: {
|
|
1436
|
+
dynamicRegistration: true,
|
|
1437
|
+
contextSupport: true,
|
|
1438
|
+
completionItemKind: { valueSet: Array.from(lspCompletionItemKindToMonacoCompletionItemKind.keys()) },
|
|
1439
|
+
completionItem: {
|
|
1440
|
+
tagSupport: { valueSet: Array.from(lspCompletionItemTagToMonacoCompletionItemTag.keys()) },
|
|
1441
|
+
commitCharactersSupport: true,
|
|
1442
|
+
deprecatedSupport: true,
|
|
1443
|
+
preselectSupport: true
|
|
1444
|
+
}
|
|
1445
|
+
} } }));
|
|
1446
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentCompletion, true, (capability) => {
|
|
1447
|
+
return editor.languages.registerCompletionItemProvider(toMonacoLanguageSelector(capability.documentSelector), new LspCompletionProvider(this._connection, capability));
|
|
1448
|
+
}));
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
var LspCompletionProvider = class {
|
|
1452
|
+
resolveCompletionItem;
|
|
1453
|
+
constructor(_client, _capabilities) {
|
|
1454
|
+
this._client = _client;
|
|
1455
|
+
this._capabilities = _capabilities;
|
|
1456
|
+
if (_capabilities.resolveProvider) this.resolveCompletionItem = async (item, token) => {
|
|
1457
|
+
applyLspCompletionItemProperties(item, await this._client.server.completionItemResolve(item._lspItem), this._client.bridge, item._translated, item._model);
|
|
1458
|
+
return item;
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
get triggerCharacters() {
|
|
1462
|
+
return this._capabilities.triggerCharacters;
|
|
1463
|
+
}
|
|
1464
|
+
async provideCompletionItems(model, position, context, token) {
|
|
1465
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1466
|
+
const result = await this._client.server.textDocumentCompletion({
|
|
1467
|
+
textDocument: translated.textDocument,
|
|
1468
|
+
position: translated.position,
|
|
1469
|
+
context: context.triggerCharacter ? {
|
|
1470
|
+
triggerKind: toLspCompletionTriggerKind(context.triggerKind),
|
|
1471
|
+
triggerCharacter: context.triggerCharacter
|
|
1472
|
+
} : void 0
|
|
1473
|
+
});
|
|
1474
|
+
if (!result) return { suggestions: [] };
|
|
1475
|
+
return { suggestions: (Array.isArray(result) ? result : result.items).map((i) => {
|
|
1476
|
+
return {
|
|
1477
|
+
...convertLspToMonacoCompletionItem(i, this._client.bridge, translated, model, position),
|
|
1478
|
+
_lspItem: i,
|
|
1479
|
+
_translated: translated,
|
|
1480
|
+
_model: model
|
|
1481
|
+
};
|
|
1482
|
+
}) };
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
function convertLspToMonacoCompletionItem(lspItem, bridge, translated, model, position) {
|
|
1486
|
+
let insertText = lspItem.insertText || lspItem.label;
|
|
1487
|
+
let range = void 0;
|
|
1488
|
+
if (lspItem.textEdit) if ("range" in lspItem.textEdit) {
|
|
1489
|
+
insertText = lspItem.textEdit.newText;
|
|
1490
|
+
range = assertTargetTextModel(bridge.translateBackRange(translated.textDocument, lspItem.textEdit.range), model).range;
|
|
1491
|
+
} else {
|
|
1492
|
+
insertText = lspItem.textEdit.newText;
|
|
1493
|
+
range = {
|
|
1494
|
+
insert: assertTargetTextModel(bridge.translateBackRange(translated.textDocument, lspItem.textEdit.insert), model).range,
|
|
1495
|
+
replace: assertTargetTextModel(bridge.translateBackRange(translated.textDocument, lspItem.textEdit.replace), model).range
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
if (!range) range = editor.Range.fromPositions(position, position);
|
|
1499
|
+
const item = {
|
|
1500
|
+
label: lspItem.label,
|
|
1501
|
+
kind: toMonacoCompletionItemKind(lspItem.kind),
|
|
1502
|
+
insertText,
|
|
1503
|
+
sortText: lspItem.sortText,
|
|
1504
|
+
filterText: lspItem.filterText,
|
|
1505
|
+
preselect: lspItem.preselect,
|
|
1506
|
+
commitCharacters: lspItem.commitCharacters,
|
|
1507
|
+
range
|
|
1508
|
+
};
|
|
1509
|
+
applyLspCompletionItemProperties(item, lspItem, bridge, translated, model);
|
|
1510
|
+
return item;
|
|
1511
|
+
}
|
|
1512
|
+
function applyLspCompletionItemProperties(monacoItem, lspItem, bridge, translated, targetModel) {
|
|
1513
|
+
if (lspItem.detail !== void 0) monacoItem.detail = lspItem.detail;
|
|
1514
|
+
if (lspItem.documentation !== void 0) monacoItem.documentation = toMonacoDocumentation$1(lspItem.documentation);
|
|
1515
|
+
if (lspItem.insertTextFormat !== void 0) monacoItem.insertTextRules = toMonacoInsertTextRules(lspItem.insertTextFormat);
|
|
1516
|
+
if (lspItem.tags && lspItem.tags.length > 0) monacoItem.tags = lspItem.tags.map(toMonacoCompletionItemTag).filter((tag) => tag !== void 0);
|
|
1517
|
+
if (lspItem.additionalTextEdits && lspItem.additionalTextEdits.length > 0) monacoItem.additionalTextEdits = lspItem.additionalTextEdits.map((edit) => ({
|
|
1518
|
+
range: assertTargetTextModel(bridge.translateBackRange(translated.textDocument, edit.range), targetModel).range,
|
|
1519
|
+
text: edit.newText
|
|
1520
|
+
}));
|
|
1521
|
+
if (lspItem.command) monacoItem.command = toMonacoCommand(lspItem.command);
|
|
1522
|
+
}
|
|
1523
|
+
function toMonacoDocumentation$1(doc) {
|
|
1524
|
+
if (!doc) return void 0;
|
|
1525
|
+
if (typeof doc === "string") return doc;
|
|
1526
|
+
return {
|
|
1527
|
+
value: doc.value,
|
|
1528
|
+
isTrusted: true
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
var LspHoverFeature = class extends Disposable {
|
|
1532
|
+
constructor(_connection) {
|
|
1533
|
+
super();
|
|
1534
|
+
this._connection = _connection;
|
|
1535
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { hover: {
|
|
1536
|
+
dynamicRegistration: true,
|
|
1537
|
+
contentFormat: [MarkupKind.Markdown, MarkupKind.PlainText]
|
|
1538
|
+
} } }));
|
|
1539
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentHover, true, (capability) => {
|
|
1540
|
+
return editor.languages.registerHoverProvider(toMonacoLanguageSelector(capability.documentSelector), new LspHoverProvider(this._connection, capability));
|
|
1541
|
+
}));
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1544
|
+
var LspHoverProvider = class {
|
|
1545
|
+
constructor(_client, _capabilities) {
|
|
1546
|
+
this._client = _client;
|
|
1547
|
+
this._capabilities = _capabilities;
|
|
1548
|
+
}
|
|
1549
|
+
async provideHover(model, position, token) {
|
|
1550
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1551
|
+
const result = await this._client.server.textDocumentHover({
|
|
1552
|
+
textDocument: translated.textDocument,
|
|
1553
|
+
position: translated.position
|
|
1554
|
+
});
|
|
1555
|
+
if (!result || !result.contents) return null;
|
|
1556
|
+
return {
|
|
1557
|
+
contents: toMonacoMarkdownString(result.contents),
|
|
1558
|
+
range: result.range ? this._client.bridge.translateBackRange(translated.textDocument, result.range).range : void 0
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
function toMonacoMarkdownString(contents) {
|
|
1563
|
+
if (Array.isArray(contents)) return contents.map((c) => toSingleMarkdownString(c));
|
|
1564
|
+
return [toSingleMarkdownString(contents)];
|
|
1565
|
+
}
|
|
1566
|
+
function toSingleMarkdownString(content) {
|
|
1567
|
+
if (typeof content === "string") return {
|
|
1568
|
+
value: content,
|
|
1569
|
+
isTrusted: true
|
|
1570
|
+
};
|
|
1571
|
+
if ("kind" in content) return {
|
|
1572
|
+
value: content.value,
|
|
1573
|
+
isTrusted: true
|
|
1574
|
+
};
|
|
1575
|
+
return {
|
|
1576
|
+
value: `\`\`\`${content.language}
|
|
1577
|
+
${content.value}
|
|
1578
|
+
\`\`\``,
|
|
1579
|
+
isTrusted: true
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
var LspSignatureHelpFeature = class extends Disposable {
|
|
1583
|
+
constructor(_connection) {
|
|
1584
|
+
super();
|
|
1585
|
+
this._connection = _connection;
|
|
1586
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { signatureHelp: {
|
|
1587
|
+
dynamicRegistration: true,
|
|
1588
|
+
contextSupport: true,
|
|
1589
|
+
signatureInformation: {
|
|
1590
|
+
documentationFormat: [MarkupKind.Markdown, MarkupKind.PlainText],
|
|
1591
|
+
parameterInformation: { labelOffsetSupport: true },
|
|
1592
|
+
activeParameterSupport: true
|
|
1593
|
+
}
|
|
1594
|
+
} } }));
|
|
1595
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentSignatureHelp, true, (capability) => {
|
|
1596
|
+
return editor.languages.registerSignatureHelpProvider(toMonacoLanguageSelector(capability.documentSelector), new LspSignatureHelpProvider(this._connection, capability));
|
|
1597
|
+
}));
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
var LspSignatureHelpProvider = class {
|
|
1601
|
+
signatureHelpTriggerCharacters;
|
|
1602
|
+
signatureHelpRetriggerCharacters;
|
|
1603
|
+
constructor(_client, _capabilities) {
|
|
1604
|
+
this._client = _client;
|
|
1605
|
+
this._capabilities = _capabilities;
|
|
1606
|
+
this.signatureHelpTriggerCharacters = _capabilities.triggerCharacters;
|
|
1607
|
+
this.signatureHelpRetriggerCharacters = _capabilities.retriggerCharacters;
|
|
1608
|
+
}
|
|
1609
|
+
async provideSignatureHelp(model, position, token, context) {
|
|
1610
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1611
|
+
const result = await this._client.server.textDocumentSignatureHelp({
|
|
1612
|
+
textDocument: translated.textDocument,
|
|
1613
|
+
position: translated.position,
|
|
1614
|
+
context: {
|
|
1615
|
+
triggerKind: toLspSignatureHelpTriggerKind(context.triggerKind),
|
|
1616
|
+
triggerCharacter: context.triggerCharacter,
|
|
1617
|
+
isRetrigger: context.isRetrigger
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
if (!result) return null;
|
|
1621
|
+
return {
|
|
1622
|
+
value: {
|
|
1623
|
+
signatures: result.signatures.map((sig) => ({
|
|
1624
|
+
label: sig.label,
|
|
1625
|
+
documentation: toMonacoDocumentation(sig.documentation),
|
|
1626
|
+
parameters: sig.parameters?.map((param) => ({
|
|
1627
|
+
label: param.label,
|
|
1628
|
+
documentation: toMonacoDocumentation(param.documentation)
|
|
1629
|
+
})) || [],
|
|
1630
|
+
activeParameter: sig.activeParameter
|
|
1631
|
+
})),
|
|
1632
|
+
activeSignature: result.activeSignature || 0,
|
|
1633
|
+
activeParameter: result.activeParameter || 0
|
|
1634
|
+
},
|
|
1635
|
+
dispose: () => {
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
function toMonacoDocumentation(doc) {
|
|
1641
|
+
if (!doc) return void 0;
|
|
1642
|
+
if (typeof doc === "string") return doc;
|
|
1643
|
+
return {
|
|
1644
|
+
value: doc.value,
|
|
1645
|
+
isTrusted: true
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
var LspDefinitionFeature = class extends Disposable {
|
|
1649
|
+
constructor(_connection) {
|
|
1650
|
+
super();
|
|
1651
|
+
this._connection = _connection;
|
|
1652
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { definition: {
|
|
1653
|
+
dynamicRegistration: true,
|
|
1654
|
+
linkSupport: true
|
|
1655
|
+
} } }));
|
|
1656
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDefinition, true, (capability) => {
|
|
1657
|
+
return editor.languages.registerDefinitionProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDefinitionProvider(this._connection, capability));
|
|
1658
|
+
}));
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
var LspDefinitionProvider = class {
|
|
1662
|
+
constructor(_client, _capabilities) {
|
|
1663
|
+
this._client = _client;
|
|
1664
|
+
this._capabilities = _capabilities;
|
|
1665
|
+
}
|
|
1666
|
+
async provideDefinition(model, position, token) {
|
|
1667
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1668
|
+
const result = await this._client.server.textDocumentDefinition({
|
|
1669
|
+
textDocument: translated.textDocument,
|
|
1670
|
+
position: translated.position
|
|
1671
|
+
});
|
|
1672
|
+
if (!result) return null;
|
|
1673
|
+
if (Array.isArray(result)) return result.map((loc) => toMonacoLocation(loc, this._client));
|
|
1674
|
+
return toMonacoLocation(result, this._client);
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
var LspDeclarationFeature = class extends Disposable {
|
|
1678
|
+
constructor(_connection) {
|
|
1679
|
+
super();
|
|
1680
|
+
this._connection = _connection;
|
|
1681
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { declaration: {
|
|
1682
|
+
dynamicRegistration: true,
|
|
1683
|
+
linkSupport: true
|
|
1684
|
+
} } }));
|
|
1685
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDeclaration, true, (capability) => {
|
|
1686
|
+
return editor.languages.registerDeclarationProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDeclarationProvider(this._connection, capability));
|
|
1687
|
+
}));
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
var LspDeclarationProvider = class {
|
|
1691
|
+
constructor(_client, _capabilities) {
|
|
1692
|
+
this._client = _client;
|
|
1693
|
+
this._capabilities = _capabilities;
|
|
1694
|
+
}
|
|
1695
|
+
async provideDeclaration(model, position, token) {
|
|
1696
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1697
|
+
const result = await this._client.server.textDocumentDeclaration({
|
|
1698
|
+
textDocument: translated.textDocument,
|
|
1699
|
+
position: translated.position
|
|
1700
|
+
});
|
|
1701
|
+
if (!result) return null;
|
|
1702
|
+
if (Array.isArray(result)) return result.map((loc) => toMonacoLocation(loc, this._client));
|
|
1703
|
+
return toMonacoLocation(result, this._client);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
var LspTypeDefinitionFeature = class extends Disposable {
|
|
1707
|
+
constructor(_connection) {
|
|
1708
|
+
super();
|
|
1709
|
+
this._connection = _connection;
|
|
1710
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { typeDefinition: {
|
|
1711
|
+
dynamicRegistration: true,
|
|
1712
|
+
linkSupport: true
|
|
1713
|
+
} } }));
|
|
1714
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentTypeDefinition, true, (capability) => {
|
|
1715
|
+
return editor.languages.registerTypeDefinitionProvider(toMonacoLanguageSelector(capability.documentSelector), new LspTypeDefinitionProvider(this._connection, capability));
|
|
1716
|
+
}));
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
var LspTypeDefinitionProvider = class {
|
|
1720
|
+
constructor(_client, _capabilities) {
|
|
1721
|
+
this._client = _client;
|
|
1722
|
+
this._capabilities = _capabilities;
|
|
1723
|
+
}
|
|
1724
|
+
async provideTypeDefinition(model, position, token) {
|
|
1725
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1726
|
+
const result = await this._client.server.textDocumentTypeDefinition({
|
|
1727
|
+
textDocument: translated.textDocument,
|
|
1728
|
+
position: translated.position
|
|
1729
|
+
});
|
|
1730
|
+
if (!result) return null;
|
|
1731
|
+
if (Array.isArray(result)) return result.map((loc) => toMonacoLocation(loc, this._client));
|
|
1732
|
+
return toMonacoLocation(result, this._client);
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
var LspImplementationFeature = class extends Disposable {
|
|
1736
|
+
constructor(_connection) {
|
|
1737
|
+
super();
|
|
1738
|
+
this._connection = _connection;
|
|
1739
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { implementation: {
|
|
1740
|
+
dynamicRegistration: true,
|
|
1741
|
+
linkSupport: true
|
|
1742
|
+
} } }));
|
|
1743
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentImplementation, true, (capability) => {
|
|
1744
|
+
return editor.languages.registerImplementationProvider(toMonacoLanguageSelector(capability.documentSelector), new LspImplementationProvider(this._connection, capability));
|
|
1745
|
+
}));
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
var LspImplementationProvider = class {
|
|
1749
|
+
constructor(_client, _capabilities) {
|
|
1750
|
+
this._client = _client;
|
|
1751
|
+
this._capabilities = _capabilities;
|
|
1752
|
+
}
|
|
1753
|
+
async provideImplementation(model, position, token) {
|
|
1754
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1755
|
+
const result = await this._client.server.textDocumentImplementation({
|
|
1756
|
+
textDocument: translated.textDocument,
|
|
1757
|
+
position: translated.position
|
|
1758
|
+
});
|
|
1759
|
+
if (!result) return null;
|
|
1760
|
+
if (Array.isArray(result)) return result.map((loc) => toMonacoLocation(loc, this._client));
|
|
1761
|
+
return toMonacoLocation(result, this._client);
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
var LspReferencesFeature = class extends Disposable {
|
|
1765
|
+
constructor(_connection) {
|
|
1766
|
+
super();
|
|
1767
|
+
this._connection = _connection;
|
|
1768
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { references: { dynamicRegistration: true } } }));
|
|
1769
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentReferences, true, (capability) => {
|
|
1770
|
+
return editor.languages.registerReferenceProvider(toMonacoLanguageSelector(capability.documentSelector), new LspReferenceProvider(this._connection, capability));
|
|
1771
|
+
}));
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
var LspReferenceProvider = class {
|
|
1775
|
+
constructor(_client, _capabilities) {
|
|
1776
|
+
this._client = _client;
|
|
1777
|
+
this._capabilities = _capabilities;
|
|
1778
|
+
}
|
|
1779
|
+
async provideReferences(model, position, context, token) {
|
|
1780
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1781
|
+
const result = await this._client.server.textDocumentReferences({
|
|
1782
|
+
textDocument: translated.textDocument,
|
|
1783
|
+
position: translated.position,
|
|
1784
|
+
context: { includeDeclaration: context.includeDeclaration }
|
|
1785
|
+
});
|
|
1786
|
+
if (!result) return null;
|
|
1787
|
+
return result.map((loc) => {
|
|
1788
|
+
const translated$1 = this._client.bridge.translateBackRange({ uri: loc.uri }, loc.range);
|
|
1789
|
+
return {
|
|
1790
|
+
uri: translated$1.textModel.uri,
|
|
1791
|
+
range: translated$1.range
|
|
1792
|
+
};
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
var LspDocumentHighlightFeature = class extends Disposable {
|
|
1797
|
+
constructor(_connection) {
|
|
1798
|
+
super();
|
|
1799
|
+
this._connection = _connection;
|
|
1800
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { documentHighlight: { dynamicRegistration: true } } }));
|
|
1801
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDocumentHighlight, true, (capability) => {
|
|
1802
|
+
return editor.languages.registerDocumentHighlightProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDocumentHighlightProvider(this._connection, capability));
|
|
1803
|
+
}));
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
var LspDocumentHighlightProvider = class {
|
|
1807
|
+
constructor(_client, _capabilities) {
|
|
1808
|
+
this._client = _client;
|
|
1809
|
+
this._capabilities = _capabilities;
|
|
1810
|
+
}
|
|
1811
|
+
async provideDocumentHighlights(model, position, token) {
|
|
1812
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1813
|
+
const result = await this._client.server.textDocumentDocumentHighlight({
|
|
1814
|
+
textDocument: translated.textDocument,
|
|
1815
|
+
position: translated.position
|
|
1816
|
+
});
|
|
1817
|
+
if (!result) return null;
|
|
1818
|
+
return result.map((highlight) => ({
|
|
1819
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, highlight.range).range,
|
|
1820
|
+
kind: toMonacoDocumentHighlightKind(highlight.kind)
|
|
1821
|
+
}));
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
var LspDocumentSymbolFeature = class extends Disposable {
|
|
1825
|
+
constructor(_connection) {
|
|
1826
|
+
super();
|
|
1827
|
+
this._connection = _connection;
|
|
1828
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { documentSymbol: {
|
|
1829
|
+
dynamicRegistration: true,
|
|
1830
|
+
hierarchicalDocumentSymbolSupport: true,
|
|
1831
|
+
symbolKind: { valueSet: Array.from(lspSymbolKindToMonacoSymbolKind.keys()) },
|
|
1832
|
+
tagSupport: { valueSet: [SymbolTag.Deprecated] }
|
|
1833
|
+
} } }));
|
|
1834
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDocumentSymbol, true, (capability) => {
|
|
1835
|
+
return editor.languages.registerDocumentSymbolProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDocumentSymbolProvider(this._connection, capability));
|
|
1836
|
+
}));
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
var LspDocumentSymbolProvider = class {
|
|
1840
|
+
constructor(_client, _capabilities) {
|
|
1841
|
+
this._client = _client;
|
|
1842
|
+
this._capabilities = _capabilities;
|
|
1843
|
+
}
|
|
1844
|
+
async provideDocumentSymbols(model, token) {
|
|
1845
|
+
const translated = this._client.bridge.translate(model, new editor.Position(1, 1));
|
|
1846
|
+
const result = await this._client.server.textDocumentDocumentSymbol({ textDocument: translated.textDocument });
|
|
1847
|
+
if (!result) return null;
|
|
1848
|
+
if (Array.isArray(result) && result.length > 0) if ("location" in result[0]) return result.map((symbol) => toMonacoSymbolInformation(symbol, this._client));
|
|
1849
|
+
else return result.map((symbol) => toMonacoDocumentSymbol(symbol, this._client, translated.textDocument));
|
|
1850
|
+
return [];
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
function toMonacoDocumentSymbol(symbol, client, textDocument) {
|
|
1854
|
+
return {
|
|
1855
|
+
name: symbol.name,
|
|
1856
|
+
detail: symbol.detail || "",
|
|
1857
|
+
kind: toMonacoSymbolKind(symbol.kind),
|
|
1858
|
+
tags: symbol.tags?.map((tag) => toMonacoSymbolTag(tag)).filter((t) => t !== void 0) || [],
|
|
1859
|
+
range: client.bridge.translateBackRange(textDocument, symbol.range).range,
|
|
1860
|
+
selectionRange: client.bridge.translateBackRange(textDocument, symbol.selectionRange).range,
|
|
1861
|
+
children: symbol.children?.map((child) => toMonacoDocumentSymbol(child, client, textDocument)) || []
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
function toMonacoSymbolInformation(symbol, client) {
|
|
1865
|
+
return {
|
|
1866
|
+
name: symbol.name,
|
|
1867
|
+
detail: "",
|
|
1868
|
+
kind: toMonacoSymbolKind(symbol.kind),
|
|
1869
|
+
tags: symbol.tags?.map((tag) => toMonacoSymbolTag(tag)).filter((t) => t !== void 0) || [],
|
|
1870
|
+
range: client.bridge.translateBackRange({ uri: symbol.location.uri }, symbol.location.range).range,
|
|
1871
|
+
selectionRange: client.bridge.translateBackRange({ uri: symbol.location.uri }, symbol.location.range).range,
|
|
1872
|
+
children: []
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
var LspRenameFeature = class extends Disposable {
|
|
1876
|
+
constructor(_connection) {
|
|
1877
|
+
super();
|
|
1878
|
+
this._connection = _connection;
|
|
1879
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { rename: {
|
|
1880
|
+
dynamicRegistration: true,
|
|
1881
|
+
prepareSupport: true
|
|
1882
|
+
} } }));
|
|
1883
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentRename, true, (capability) => {
|
|
1884
|
+
return editor.languages.registerRenameProvider(toMonacoLanguageSelector(capability.documentSelector), new LspRenameProvider(this._connection, capability));
|
|
1885
|
+
}));
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
var LspRenameProvider = class {
|
|
1889
|
+
constructor(_client, _capabilities) {
|
|
1890
|
+
this._client = _client;
|
|
1891
|
+
this._capabilities = _capabilities;
|
|
1892
|
+
}
|
|
1893
|
+
async provideRenameEdits(model, position, newName, token) {
|
|
1894
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1895
|
+
const result = await this._client.server.textDocumentRename({
|
|
1896
|
+
textDocument: translated.textDocument,
|
|
1897
|
+
position: translated.position,
|
|
1898
|
+
newName
|
|
1899
|
+
});
|
|
1900
|
+
if (!result) return null;
|
|
1901
|
+
return toMonacoWorkspaceEdit$1(result, this._client);
|
|
1902
|
+
}
|
|
1903
|
+
async resolveRenameLocation(model, position, token) {
|
|
1904
|
+
if (!this._capabilities.prepareProvider) return null;
|
|
1905
|
+
const translated = this._client.bridge.translate(model, position);
|
|
1906
|
+
const result = await this._client.server.textDocumentPrepareRename({
|
|
1907
|
+
textDocument: translated.textDocument,
|
|
1908
|
+
position: translated.position
|
|
1909
|
+
});
|
|
1910
|
+
if (!result) return null;
|
|
1911
|
+
if ("range" in result && "placeholder" in result) return {
|
|
1912
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, result.range).range,
|
|
1913
|
+
text: result.placeholder
|
|
1914
|
+
};
|
|
1915
|
+
else if ("defaultBehavior" in result) return null;
|
|
1916
|
+
else if ("start" in result && "end" in result) {
|
|
1917
|
+
const range = this._client.bridge.translateBackRange(translated.textDocument, result).range;
|
|
1918
|
+
return {
|
|
1919
|
+
range,
|
|
1920
|
+
text: model.getValueInRange(range)
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
return null;
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
function toMonacoWorkspaceEdit$1(edit, client) {
|
|
1927
|
+
const edits = [];
|
|
1928
|
+
if (edit.changes) for (const uri in edit.changes) {
|
|
1929
|
+
const textEdits = edit.changes[uri];
|
|
1930
|
+
for (const textEdit of textEdits) {
|
|
1931
|
+
const translated = client.bridge.translateBackRange({ uri }, textEdit.range);
|
|
1932
|
+
edits.push({
|
|
1933
|
+
resource: translated.textModel.uri,
|
|
1934
|
+
versionId: void 0,
|
|
1935
|
+
textEdit: {
|
|
1936
|
+
range: translated.range,
|
|
1937
|
+
text: textEdit.newText
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
if (edit.documentChanges) {
|
|
1943
|
+
for (const change of edit.documentChanges) if ("textDocument" in change) {
|
|
1944
|
+
const uri = change.textDocument.uri;
|
|
1945
|
+
for (const textEdit of change.edits) {
|
|
1946
|
+
const translated = client.bridge.translateBackRange({ uri }, textEdit.range);
|
|
1947
|
+
edits.push({
|
|
1948
|
+
resource: translated.textModel.uri,
|
|
1949
|
+
versionId: change.textDocument.version,
|
|
1950
|
+
textEdit: {
|
|
1951
|
+
range: translated.range,
|
|
1952
|
+
text: textEdit.newText
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return { edits };
|
|
1959
|
+
}
|
|
1960
|
+
var LspCodeActionFeature = class extends Disposable {
|
|
1961
|
+
constructor(_connection) {
|
|
1962
|
+
super();
|
|
1963
|
+
this._connection = _connection;
|
|
1964
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { codeAction: {
|
|
1965
|
+
dynamicRegistration: true,
|
|
1966
|
+
codeActionLiteralSupport: { codeActionKind: { valueSet: Array.from(lspCodeActionKindToMonacoCodeActionKind.keys()) } },
|
|
1967
|
+
isPreferredSupport: true,
|
|
1968
|
+
disabledSupport: true,
|
|
1969
|
+
dataSupport: true,
|
|
1970
|
+
resolveSupport: { properties: ["edit"] }
|
|
1971
|
+
} } }));
|
|
1972
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentCodeAction, true, (capability) => {
|
|
1973
|
+
return editor.languages.registerCodeActionProvider(toMonacoLanguageSelector(capability.documentSelector), new LspCodeActionProvider(this._connection, capability));
|
|
1974
|
+
}));
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
var LspCodeActionProvider = class {
|
|
1978
|
+
resolveCodeAction;
|
|
1979
|
+
constructor(_client, _capabilities) {
|
|
1980
|
+
this._client = _client;
|
|
1981
|
+
this._capabilities = _capabilities;
|
|
1982
|
+
if (_capabilities.resolveProvider) this.resolveCodeAction = async (codeAction, token) => {
|
|
1983
|
+
if (codeAction._lspAction) {
|
|
1984
|
+
const resolved = await this._client.server.codeActionResolve(codeAction._lspAction);
|
|
1985
|
+
if (resolved.edit) codeAction.edit = toMonacoWorkspaceEdit(resolved.edit, this._client);
|
|
1986
|
+
if (resolved.command) codeAction.command = toMonacoCommand(resolved.command);
|
|
1987
|
+
}
|
|
1988
|
+
return codeAction;
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
async provideCodeActions(model, range, context, token) {
|
|
1992
|
+
const translated = this._client.bridge.translate(model, range.getStartPosition());
|
|
1993
|
+
const result = await this._client.server.textDocumentCodeAction({
|
|
1994
|
+
textDocument: translated.textDocument,
|
|
1995
|
+
range: this._client.bridge.translateRange(model, range),
|
|
1996
|
+
context: {
|
|
1997
|
+
diagnostics: context.markers.map((marker) => ({
|
|
1998
|
+
range: this._client.bridge.translateRange(model, editor.Range.lift(marker)),
|
|
1999
|
+
message: marker.message,
|
|
2000
|
+
severity: toLspDiagnosticSeverity(marker.severity)
|
|
2001
|
+
})),
|
|
2002
|
+
triggerKind: toLspCodeActionTriggerKind(context.trigger)
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
if (!result) return null;
|
|
2006
|
+
return {
|
|
2007
|
+
actions: (Array.isArray(result) ? result : [result]).map((action) => {
|
|
2008
|
+
if ("title" in action && !("kind" in action)) {
|
|
2009
|
+
const cmd = action;
|
|
2010
|
+
return {
|
|
2011
|
+
title: cmd.title,
|
|
2012
|
+
command: toMonacoCommand(cmd)
|
|
2013
|
+
};
|
|
2014
|
+
} else {
|
|
2015
|
+
const codeAction = action;
|
|
2016
|
+
return {
|
|
2017
|
+
title: codeAction.title,
|
|
2018
|
+
kind: toMonacoCodeActionKind(codeAction.kind),
|
|
2019
|
+
isPreferred: codeAction.isPreferred,
|
|
2020
|
+
disabled: codeAction.disabled?.reason,
|
|
2021
|
+
edit: codeAction.edit ? toMonacoWorkspaceEdit(codeAction.edit, this._client) : void 0,
|
|
2022
|
+
command: toMonacoCommand(codeAction.command),
|
|
2023
|
+
_lspAction: codeAction
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
}),
|
|
2027
|
+
dispose: () => {
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
function toMonacoWorkspaceEdit(edit, client) {
|
|
2033
|
+
const edits = [];
|
|
2034
|
+
if (edit.changes) for (const uri in edit.changes) {
|
|
2035
|
+
const textEdits = edit.changes[uri];
|
|
2036
|
+
for (const textEdit of textEdits) {
|
|
2037
|
+
const translated = client.bridge.translateBackRange({ uri }, textEdit.range);
|
|
2038
|
+
edits.push({
|
|
2039
|
+
resource: translated.textModel.uri,
|
|
2040
|
+
versionId: void 0,
|
|
2041
|
+
textEdit: {
|
|
2042
|
+
range: translated.range,
|
|
2043
|
+
text: textEdit.newText
|
|
2044
|
+
}
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
if (edit.documentChanges) {
|
|
2049
|
+
for (const change of edit.documentChanges) if ("textDocument" in change) {
|
|
2050
|
+
const uri = change.textDocument.uri;
|
|
2051
|
+
for (const textEdit of change.edits) {
|
|
2052
|
+
const translated = client.bridge.translateBackRange({ uri }, textEdit.range);
|
|
2053
|
+
edits.push({
|
|
2054
|
+
resource: translated.textModel.uri,
|
|
2055
|
+
versionId: change.textDocument.version ?? void 0,
|
|
2056
|
+
textEdit: {
|
|
2057
|
+
range: translated.range,
|
|
2058
|
+
text: textEdit.newText
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
return { edits };
|
|
2065
|
+
}
|
|
2066
|
+
var LspCodeLensFeature = class extends Disposable {
|
|
2067
|
+
constructor(_connection) {
|
|
2068
|
+
super();
|
|
2069
|
+
this._connection = _connection;
|
|
2070
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { codeLens: { dynamicRegistration: true } } }));
|
|
2071
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentCodeLens, true, (capability) => {
|
|
2072
|
+
return editor.languages.registerCodeLensProvider(toMonacoLanguageSelector(capability.documentSelector), new LspCodeLensProvider(this._connection, capability));
|
|
2073
|
+
}));
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
var LspCodeLensProvider = class {
|
|
2077
|
+
constructor(_client, _capabilities) {
|
|
2078
|
+
this._client = _client;
|
|
2079
|
+
this._capabilities = _capabilities;
|
|
2080
|
+
}
|
|
2081
|
+
async provideCodeLenses(model, token) {
|
|
2082
|
+
const translated = this._client.bridge.translate(model, new editor.Position(1, 1));
|
|
2083
|
+
const result = await this._client.server.textDocumentCodeLens({ textDocument: translated.textDocument });
|
|
2084
|
+
if (!result) return null;
|
|
2085
|
+
return {
|
|
2086
|
+
lenses: result.map((lens) => {
|
|
2087
|
+
return {
|
|
2088
|
+
range: assertTargetTextModel(this._client.bridge.translateBackRange(translated.textDocument, lens.range), model).range,
|
|
2089
|
+
command: toMonacoCommand(lens.command),
|
|
2090
|
+
_lspCodeLens: lens
|
|
2091
|
+
};
|
|
2092
|
+
}),
|
|
2093
|
+
dispose: () => {
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
async resolveCodeLens(model, codeLens, token) {
|
|
2098
|
+
if (!this._capabilities.resolveProvider || !codeLens._lspCodeLens) return codeLens;
|
|
2099
|
+
const resolved = await this._client.server.codeLensResolve(codeLens._lspCodeLens);
|
|
2100
|
+
if (resolved.command) codeLens.command = {
|
|
2101
|
+
id: resolved.command.command,
|
|
2102
|
+
title: resolved.command.title,
|
|
2103
|
+
arguments: resolved.command.arguments
|
|
2104
|
+
};
|
|
2105
|
+
return codeLens;
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
var LspDocumentLinkFeature = class extends Disposable {
|
|
2109
|
+
constructor(_connection) {
|
|
2110
|
+
super();
|
|
2111
|
+
this._connection = _connection;
|
|
2112
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { documentLink: {
|
|
2113
|
+
dynamicRegistration: true,
|
|
2114
|
+
tooltipSupport: true
|
|
2115
|
+
} } }));
|
|
2116
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDocumentLink, true, (capability) => {
|
|
2117
|
+
return editor.languages.registerLinkProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDocumentLinkProvider(this._connection, capability));
|
|
2118
|
+
}));
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
var LspDocumentLinkProvider = class {
|
|
2122
|
+
constructor(_client, _capabilities) {
|
|
2123
|
+
this._client = _client;
|
|
2124
|
+
this._capabilities = _capabilities;
|
|
2125
|
+
}
|
|
2126
|
+
async provideLinks(model, token) {
|
|
2127
|
+
const translated = this._client.bridge.translate(model, new editor.Position(1, 1));
|
|
2128
|
+
const result = await this._client.server.textDocumentDocumentLink({ textDocument: translated.textDocument });
|
|
2129
|
+
if (!result) return null;
|
|
2130
|
+
return { links: result.map((link) => ({
|
|
2131
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, link.range).range,
|
|
2132
|
+
url: link.target,
|
|
2133
|
+
tooltip: link.tooltip
|
|
2134
|
+
})) };
|
|
2135
|
+
}
|
|
2136
|
+
async resolveLink(link, token) {
|
|
2137
|
+
if (!this._capabilities.resolveProvider) return link;
|
|
2138
|
+
return link;
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
var LspFormattingFeature = class extends Disposable {
|
|
2142
|
+
constructor(_connection) {
|
|
2143
|
+
super();
|
|
2144
|
+
this._connection = _connection;
|
|
2145
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { formatting: { dynamicRegistration: true } } }));
|
|
2146
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentFormatting, true, (capability) => {
|
|
2147
|
+
return editor.languages.registerDocumentFormattingEditProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDocumentFormattingProvider(this._connection, capability));
|
|
2148
|
+
}));
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
var LspDocumentFormattingProvider = class {
|
|
2152
|
+
constructor(_client, _capabilities) {
|
|
2153
|
+
this._client = _client;
|
|
2154
|
+
this._capabilities = _capabilities;
|
|
2155
|
+
}
|
|
2156
|
+
async provideDocumentFormattingEdits(model, options, token) {
|
|
2157
|
+
const translated = this._client.bridge.translate(model, new editor.Position(1, 1));
|
|
2158
|
+
const result = await this._client.server.textDocumentFormatting({
|
|
2159
|
+
textDocument: translated.textDocument,
|
|
2160
|
+
options: {
|
|
2161
|
+
tabSize: options.tabSize,
|
|
2162
|
+
insertSpaces: options.insertSpaces
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
if (!result) return null;
|
|
2166
|
+
return result.map((edit) => ({
|
|
2167
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, edit.range).range,
|
|
2168
|
+
text: edit.newText
|
|
2169
|
+
}));
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
var LspRangeFormattingFeature = class extends Disposable {
|
|
2173
|
+
constructor(_connection) {
|
|
2174
|
+
super();
|
|
2175
|
+
this._connection = _connection;
|
|
2176
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { rangeFormatting: { dynamicRegistration: true } } }));
|
|
2177
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentRangeFormatting, true, (capability) => {
|
|
2178
|
+
return editor.languages.registerDocumentRangeFormattingEditProvider(toMonacoLanguageSelector(capability.documentSelector), new LspDocumentRangeFormattingProvider(this._connection, capability));
|
|
2179
|
+
}));
|
|
2180
|
+
}
|
|
2181
|
+
};
|
|
2182
|
+
var LspDocumentRangeFormattingProvider = class {
|
|
2183
|
+
constructor(_client, _capabilities) {
|
|
2184
|
+
this._client = _client;
|
|
2185
|
+
this._capabilities = _capabilities;
|
|
2186
|
+
}
|
|
2187
|
+
async provideDocumentRangeFormattingEdits(model, range, options, token) {
|
|
2188
|
+
const translated = this._client.bridge.translate(model, range.getStartPosition());
|
|
2189
|
+
const result = await this._client.server.textDocumentRangeFormatting({
|
|
2190
|
+
textDocument: translated.textDocument,
|
|
2191
|
+
range: this._client.bridge.translateRange(model, range),
|
|
2192
|
+
options: {
|
|
2193
|
+
tabSize: options.tabSize,
|
|
2194
|
+
insertSpaces: options.insertSpaces
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
if (!result) return null;
|
|
2198
|
+
return result.map((edit) => ({
|
|
2199
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, edit.range).range,
|
|
2200
|
+
text: edit.newText
|
|
2201
|
+
}));
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
var LspOnTypeFormattingFeature = class extends Disposable {
|
|
2205
|
+
constructor(_connection) {
|
|
2206
|
+
super();
|
|
2207
|
+
this._connection = _connection;
|
|
2208
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { onTypeFormatting: { dynamicRegistration: true } } }));
|
|
2209
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentOnTypeFormatting, true, (capability) => {
|
|
2210
|
+
return editor.languages.registerOnTypeFormattingEditProvider(toMonacoLanguageSelector(capability.documentSelector), new LspOnTypeFormattingProvider(this._connection, capability));
|
|
2211
|
+
}));
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
var LspOnTypeFormattingProvider = class {
|
|
2215
|
+
autoFormatTriggerCharacters;
|
|
2216
|
+
constructor(_client, _capabilities) {
|
|
2217
|
+
this._client = _client;
|
|
2218
|
+
this._capabilities = _capabilities;
|
|
2219
|
+
this.autoFormatTriggerCharacters = [_capabilities.firstTriggerCharacter, ..._capabilities.moreTriggerCharacter || []];
|
|
2220
|
+
}
|
|
2221
|
+
async provideOnTypeFormattingEdits(model, position, ch, options, token) {
|
|
2222
|
+
const translated = this._client.bridge.translate(model, position);
|
|
2223
|
+
const result = await this._client.server.textDocumentOnTypeFormatting({
|
|
2224
|
+
textDocument: translated.textDocument,
|
|
2225
|
+
position: translated.position,
|
|
2226
|
+
ch,
|
|
2227
|
+
options: {
|
|
2228
|
+
tabSize: options.tabSize,
|
|
2229
|
+
insertSpaces: options.insertSpaces
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
if (!result) return null;
|
|
2233
|
+
return result.map((edit) => ({
|
|
2234
|
+
range: this._client.bridge.translateBackRange(translated.textDocument, edit.range).range,
|
|
2235
|
+
text: edit.newText
|
|
2236
|
+
}));
|
|
2237
|
+
}
|
|
2238
|
+
};
|
|
2239
|
+
var LspFoldingRangeFeature = class extends Disposable {
|
|
2240
|
+
constructor(_connection) {
|
|
2241
|
+
super();
|
|
2242
|
+
this._connection = _connection;
|
|
2243
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { foldingRange: {
|
|
2244
|
+
dynamicRegistration: true,
|
|
2245
|
+
rangeLimit: 5e3,
|
|
2246
|
+
lineFoldingOnly: false,
|
|
2247
|
+
foldingRangeKind: { valueSet: [
|
|
2248
|
+
FoldingRangeKind.Comment,
|
|
2249
|
+
FoldingRangeKind.Imports,
|
|
2250
|
+
FoldingRangeKind.Region
|
|
2251
|
+
] }
|
|
2252
|
+
} } }));
|
|
2253
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentFoldingRange, true, (capability) => {
|
|
2254
|
+
return editor.languages.registerFoldingRangeProvider(toMonacoLanguageSelector(capability.documentSelector), new LspFoldingRangeProvider(this._connection, capability));
|
|
2255
|
+
}));
|
|
2256
|
+
}
|
|
2257
|
+
};
|
|
2258
|
+
var LspFoldingRangeProvider = class {
|
|
2259
|
+
constructor(_client, _capabilities) {
|
|
2260
|
+
this._client = _client;
|
|
2261
|
+
this._capabilities = _capabilities;
|
|
2262
|
+
}
|
|
2263
|
+
async provideFoldingRanges(model, context, token) {
|
|
2264
|
+
const translated = this._client.bridge.translate(model, new editor.Position(1, 1));
|
|
2265
|
+
const result = await this._client.server.textDocumentFoldingRange({ textDocument: translated.textDocument });
|
|
2266
|
+
if (!result) return null;
|
|
2267
|
+
return result.map((range) => ({
|
|
2268
|
+
start: range.startLine + 1,
|
|
2269
|
+
end: range.endLine + 1,
|
|
2270
|
+
kind: toMonacoFoldingRangeKind(range.kind)
|
|
2271
|
+
}));
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
var LspSelectionRangeFeature = class extends Disposable {
|
|
2275
|
+
constructor(_connection) {
|
|
2276
|
+
super();
|
|
2277
|
+
this._connection = _connection;
|
|
2278
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { selectionRange: { dynamicRegistration: true } } }));
|
|
2279
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentSelectionRange, true, (capability) => {
|
|
2280
|
+
return editor.languages.registerSelectionRangeProvider(toMonacoLanguageSelector(capability.documentSelector), new LspSelectionRangeProvider(this._connection, capability));
|
|
2281
|
+
}));
|
|
2282
|
+
}
|
|
2283
|
+
};
|
|
2284
|
+
var LspSelectionRangeProvider = class {
|
|
2285
|
+
constructor(_client, _capabilities) {
|
|
2286
|
+
this._client = _client;
|
|
2287
|
+
this._capabilities = _capabilities;
|
|
2288
|
+
}
|
|
2289
|
+
async provideSelectionRanges(model, positions, token) {
|
|
2290
|
+
const translated = this._client.bridge.translate(model, positions[0]);
|
|
2291
|
+
const result = await this._client.server.textDocumentSelectionRange({
|
|
2292
|
+
textDocument: translated.textDocument,
|
|
2293
|
+
positions: positions.map((pos) => this._client.bridge.translate(model, pos).position)
|
|
2294
|
+
});
|
|
2295
|
+
if (!result) return null;
|
|
2296
|
+
return result.map((selRange) => this.convertSelectionRange(selRange, translated.textDocument));
|
|
2297
|
+
}
|
|
2298
|
+
convertSelectionRange(range, textDocument) {
|
|
2299
|
+
const result = [];
|
|
2300
|
+
let current = range;
|
|
2301
|
+
while (current) {
|
|
2302
|
+
result.push({ range: this._client.bridge.translateBackRange(textDocument, current.range).range });
|
|
2303
|
+
current = current.parent;
|
|
2304
|
+
}
|
|
2305
|
+
return result;
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
var LspInlayHintsFeature = class extends Disposable {
|
|
2309
|
+
_providers = /* @__PURE__ */ new Set();
|
|
2310
|
+
constructor(_connection) {
|
|
2311
|
+
super();
|
|
2312
|
+
this._connection = _connection;
|
|
2313
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({
|
|
2314
|
+
textDocument: { inlayHint: {
|
|
2315
|
+
dynamicRegistration: true,
|
|
2316
|
+
resolveSupport: { properties: [
|
|
2317
|
+
"tooltip",
|
|
2318
|
+
"textEdits",
|
|
2319
|
+
"label.tooltip",
|
|
2320
|
+
"label.location",
|
|
2321
|
+
"label.command"
|
|
2322
|
+
] }
|
|
2323
|
+
} },
|
|
2324
|
+
workspace: { inlayHint: { refreshSupport: true } }
|
|
2325
|
+
}));
|
|
2326
|
+
this._register(this._connection.connection.registerRequestHandler(api.client.workspaceInlayHintRefresh, async () => {
|
|
2327
|
+
for (const provider of this._providers) provider.refresh();
|
|
2328
|
+
return { ok: null };
|
|
2329
|
+
}));
|
|
2330
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentInlayHint, true, (capability) => {
|
|
2331
|
+
const provider = new LspInlayHintsProvider(this._connection, capability);
|
|
2332
|
+
this._providers.add(provider);
|
|
2333
|
+
const disposable = editor.languages.registerInlayHintsProvider(toMonacoLanguageSelector(capability.documentSelector), provider);
|
|
2334
|
+
return { dispose: () => {
|
|
2335
|
+
this._providers.delete(provider);
|
|
2336
|
+
disposable.dispose();
|
|
2337
|
+
} };
|
|
2338
|
+
}));
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
var LspInlayHintsProvider = class {
|
|
2342
|
+
_onDidChangeInlayHints = new editor.Emitter();
|
|
2343
|
+
onDidChangeInlayHints = this._onDidChangeInlayHints.event;
|
|
2344
|
+
resolveInlayHint;
|
|
2345
|
+
constructor(_client, _capabilities) {
|
|
2346
|
+
this._client = _client;
|
|
2347
|
+
this._capabilities = _capabilities;
|
|
2348
|
+
if (_capabilities.resolveProvider) this.resolveInlayHint = async (hint, token) => {
|
|
2349
|
+
const resolved = await this._client.server.inlayHintResolve(hint._lspInlayHint);
|
|
2350
|
+
if (resolved.tooltip) hint.tooltip = toMonacoTooltip(resolved.tooltip);
|
|
2351
|
+
if (resolved.label !== hint._lspInlayHint.label) hint.label = toLspInlayHintLabel(resolved.label);
|
|
2352
|
+
if (resolved.textEdits) hint.textEdits = resolved.textEdits.map((edit) => {
|
|
2353
|
+
return {
|
|
2354
|
+
range: this._client.bridge.translateBackRange({ uri: hint._targetUri }, edit.range).range,
|
|
2355
|
+
text: edit.newText
|
|
2356
|
+
};
|
|
2357
|
+
});
|
|
2358
|
+
return hint;
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
refresh() {
|
|
2362
|
+
this._onDidChangeInlayHints.fire();
|
|
2363
|
+
}
|
|
2364
|
+
async provideInlayHints(model, range, token) {
|
|
2365
|
+
const translated = this._client.bridge.translate(model, range.getStartPosition());
|
|
2366
|
+
const result = await retryOnContentModified(async () => await this._client.server.textDocumentInlayHint({
|
|
2367
|
+
textDocument: translated.textDocument,
|
|
2368
|
+
range: this._client.bridge.translateRange(model, range)
|
|
2369
|
+
}));
|
|
2370
|
+
if (!result) return null;
|
|
2371
|
+
return {
|
|
2372
|
+
hints: result.map((hint) => {
|
|
2373
|
+
return {
|
|
2374
|
+
label: toLspInlayHintLabel(hint.label),
|
|
2375
|
+
position: assertTargetTextModel(this._client.bridge.translateBack(translated.textDocument, hint.position), model).position,
|
|
2376
|
+
kind: toMonacoInlayHintKind(hint.kind),
|
|
2377
|
+
tooltip: toMonacoTooltip(hint.tooltip),
|
|
2378
|
+
paddingLeft: hint.paddingLeft,
|
|
2379
|
+
paddingRight: hint.paddingRight,
|
|
2380
|
+
textEdits: hint.textEdits?.map((edit) => ({
|
|
2381
|
+
range: assertTargetTextModel(this._client.bridge.translateBackRange(translated.textDocument, edit.range), model).range,
|
|
2382
|
+
text: edit.newText
|
|
2383
|
+
})),
|
|
2384
|
+
_lspInlayHint: hint,
|
|
2385
|
+
_targetUri: translated.textDocument.uri
|
|
2386
|
+
};
|
|
2387
|
+
}),
|
|
2388
|
+
dispose: () => {
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
async function retryOnContentModified(cb) {
|
|
2394
|
+
for (let triesLeft = 3; ; triesLeft--) try {
|
|
2395
|
+
return await cb();
|
|
2396
|
+
} catch (e) {
|
|
2397
|
+
if (e.message === "content modified" && triesLeft > 0) continue;
|
|
2398
|
+
throw e;
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
function toLspInlayHintLabel(label) {
|
|
2402
|
+
if (typeof label === "string") return label;
|
|
2403
|
+
return label.map((part) => {
|
|
2404
|
+
const monacoLabelPart = {
|
|
2405
|
+
label: part.value,
|
|
2406
|
+
tooltip: toMonacoTooltip(part.tooltip),
|
|
2407
|
+
command: toMonacoCommand(part.command)
|
|
2408
|
+
};
|
|
2409
|
+
if (part.location) monacoLabelPart.location = {
|
|
2410
|
+
uri: editor.Uri.parse(part.location.uri),
|
|
2411
|
+
range: new editor.Range(part.location.range.start.line + 1, part.location.range.start.character + 1, part.location.range.end.line + 1, part.location.range.end.character + 1)
|
|
2412
|
+
};
|
|
2413
|
+
return monacoLabelPart;
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
function toMonacoTooltip(tooltip) {
|
|
2417
|
+
if (!tooltip) return;
|
|
2418
|
+
if (typeof tooltip === "string") return tooltip;
|
|
2419
|
+
return {
|
|
2420
|
+
value: tooltip.value,
|
|
2421
|
+
isTrusted: true
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
var LspSemanticTokensFeature = class extends Disposable {
|
|
2425
|
+
constructor(_connection) {
|
|
2426
|
+
super();
|
|
2427
|
+
this._connection = _connection;
|
|
2428
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: { semanticTokens: {
|
|
2429
|
+
dynamicRegistration: true,
|
|
2430
|
+
requests: {
|
|
2431
|
+
range: true,
|
|
2432
|
+
full: { delta: true }
|
|
2433
|
+
},
|
|
2434
|
+
tokenTypes: [
|
|
2435
|
+
"namespace",
|
|
2436
|
+
"type",
|
|
2437
|
+
"class",
|
|
2438
|
+
"enum",
|
|
2439
|
+
"interface",
|
|
2440
|
+
"struct",
|
|
2441
|
+
"typeParameter",
|
|
2442
|
+
"parameter",
|
|
2443
|
+
"variable",
|
|
2444
|
+
"property",
|
|
2445
|
+
"enumMember",
|
|
2446
|
+
"event",
|
|
2447
|
+
"function",
|
|
2448
|
+
"method",
|
|
2449
|
+
"macro",
|
|
2450
|
+
"keyword",
|
|
2451
|
+
"modifier",
|
|
2452
|
+
"comment",
|
|
2453
|
+
"string",
|
|
2454
|
+
"number",
|
|
2455
|
+
"regexp",
|
|
2456
|
+
"operator",
|
|
2457
|
+
"decorator"
|
|
2458
|
+
],
|
|
2459
|
+
tokenModifiers: [
|
|
2460
|
+
"declaration",
|
|
2461
|
+
"definition",
|
|
2462
|
+
"readonly",
|
|
2463
|
+
"static",
|
|
2464
|
+
"deprecated",
|
|
2465
|
+
"abstract",
|
|
2466
|
+
"async",
|
|
2467
|
+
"modification",
|
|
2468
|
+
"documentation",
|
|
2469
|
+
"defaultLibrary"
|
|
2470
|
+
],
|
|
2471
|
+
formats: [TokenFormat.Relative],
|
|
2472
|
+
overlappingTokenSupport: false,
|
|
2473
|
+
multilineTokenSupport: true
|
|
2474
|
+
} } }));
|
|
2475
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentSemanticTokensFull, true, (capability) => {
|
|
2476
|
+
return editor.languages.registerDocumentSemanticTokensProvider(toMonacoLanguageSelector(capability.documentSelector), new LspSemanticTokensProvider(this._connection, capability));
|
|
2477
|
+
}));
|
|
2478
|
+
}
|
|
2479
|
+
};
|
|
2480
|
+
var LspSemanticTokensProvider = class {
|
|
2481
|
+
constructor(_client, _capabilities) {
|
|
2482
|
+
this._client = _client;
|
|
2483
|
+
this._capabilities = _capabilities;
|
|
2484
|
+
}
|
|
2485
|
+
getLegend() {
|
|
2486
|
+
return {
|
|
2487
|
+
tokenTypes: this._capabilities.legend.tokenTypes,
|
|
2488
|
+
tokenModifiers: this._capabilities.legend.tokenModifiers
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
releaseDocumentSemanticTokens(resultId) {
|
|
2492
|
+
}
|
|
2493
|
+
async provideDocumentSemanticTokens(model, lastResultId, token) {
|
|
2494
|
+
const translated = this._client.bridge.translate(model, model.getPositionAt(0));
|
|
2495
|
+
const full = this._capabilities.full;
|
|
2496
|
+
if (lastResultId && full && typeof full === "object" && full.delta) {
|
|
2497
|
+
const deltaResult = await this._client.server.textDocumentSemanticTokensFullDelta({
|
|
2498
|
+
textDocument: translated.textDocument,
|
|
2499
|
+
previousResultId: lastResultId
|
|
2500
|
+
});
|
|
2501
|
+
if (!deltaResult) return null;
|
|
2502
|
+
if ("edits" in deltaResult) return {
|
|
2503
|
+
resultId: deltaResult.resultId,
|
|
2504
|
+
edits: deltaResult.edits.map((edit) => ({
|
|
2505
|
+
start: edit.start,
|
|
2506
|
+
deleteCount: edit.deleteCount,
|
|
2507
|
+
data: edit.data ? new Uint32Array(edit.data) : void 0
|
|
2508
|
+
}))
|
|
2509
|
+
};
|
|
2510
|
+
else return {
|
|
2511
|
+
resultId: deltaResult.resultId,
|
|
2512
|
+
data: new Uint32Array(deltaResult.data)
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
const result = await this._client.server.textDocumentSemanticTokensFull({ textDocument: translated.textDocument });
|
|
2516
|
+
if (!result) return null;
|
|
2517
|
+
return {
|
|
2518
|
+
resultId: result.resultId,
|
|
2519
|
+
data: new Uint32Array(result.data)
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
async provideDocumentSemanticTokensEdits(model, previousResultId, token) {
|
|
2523
|
+
return this.provideDocumentSemanticTokens(model, previousResultId, token);
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
var LspDiagnosticsFeature = class extends Disposable {
|
|
2527
|
+
_diagnosticsMarkerOwner = "lsp";
|
|
2528
|
+
_pullDiagnosticProviders = /* @__PURE__ */ new Map();
|
|
2529
|
+
constructor(_connection) {
|
|
2530
|
+
super();
|
|
2531
|
+
this._connection = _connection;
|
|
2532
|
+
this._register(this._connection.capabilities.addStaticClientCapabilities({ textDocument: {
|
|
2533
|
+
publishDiagnostics: {
|
|
2534
|
+
relatedInformation: true,
|
|
2535
|
+
tagSupport: { valueSet: [...lspDiagnosticTagToMonacoMarkerTag.keys()] },
|
|
2536
|
+
versionSupport: true,
|
|
2537
|
+
codeDescriptionSupport: true,
|
|
2538
|
+
dataSupport: true
|
|
2539
|
+
},
|
|
2540
|
+
diagnostic: {
|
|
2541
|
+
dynamicRegistration: true,
|
|
2542
|
+
relatedDocumentSupport: true
|
|
2543
|
+
}
|
|
2544
|
+
} }));
|
|
2545
|
+
debugger;
|
|
2546
|
+
this._register(this._connection.connection.registerNotificationHandler(api.client.textDocumentPublishDiagnostics, (params) => this._handlePublishDiagnostics(params)));
|
|
2547
|
+
this._register(this._connection.capabilities.registerCapabilityHandler(capabilities.textDocumentDiagnostic, true, (capability) => {
|
|
2548
|
+
const disposables = new DisposableStore();
|
|
2549
|
+
for (const model of editor.editor.getModels()) this._addPullDiagnosticProvider(model, capability, disposables);
|
|
2550
|
+
disposables.add(editor.editor.onDidCreateModel((model) => {
|
|
2551
|
+
this._addPullDiagnosticProvider(model, capability, disposables);
|
|
2552
|
+
}));
|
|
2553
|
+
return disposables;
|
|
2554
|
+
}));
|
|
2555
|
+
}
|
|
2556
|
+
_addPullDiagnosticProvider(model, capability, disposables) {
|
|
2557
|
+
model.getLanguageId();
|
|
2558
|
+
if (!matchesDocumentSelector(model, capability.documentSelector)) return;
|
|
2559
|
+
const provider = new ModelDiagnosticProvider(model, this._connection, this._diagnosticsMarkerOwner, capability);
|
|
2560
|
+
this._pullDiagnosticProviders.set(model, provider);
|
|
2561
|
+
disposables.add(provider);
|
|
2562
|
+
disposables.add(model.onWillDispose(() => {
|
|
2563
|
+
this._pullDiagnosticProviders.delete(model);
|
|
2564
|
+
}));
|
|
2565
|
+
}
|
|
2566
|
+
_handlePublishDiagnostics(params) {
|
|
2567
|
+
const uri = params.uri;
|
|
2568
|
+
try {
|
|
2569
|
+
const model = this._connection.bridge.translateBack({ uri }, {
|
|
2570
|
+
line: 0,
|
|
2571
|
+
character: 0
|
|
2572
|
+
}).textModel;
|
|
2573
|
+
if (!model || model.isDisposed()) return;
|
|
2574
|
+
const markers = params.diagnostics.map((diagnostic) => toDiagnosticMarker(diagnostic));
|
|
2575
|
+
editor.editor.setModelMarkers(model, this._diagnosticsMarkerOwner, markers);
|
|
2576
|
+
} catch (error) {
|
|
2577
|
+
console.debug(`Could not set diagnostics for ${uri}:`, error);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
var ModelDiagnosticProvider = class extends Disposable {
|
|
2582
|
+
_updateHandle;
|
|
2583
|
+
_previousResultId;
|
|
2584
|
+
constructor(_model, _connection, _markerOwner, _capability) {
|
|
2585
|
+
super();
|
|
2586
|
+
this._model = _model;
|
|
2587
|
+
this._connection = _connection;
|
|
2588
|
+
this._markerOwner = _markerOwner;
|
|
2589
|
+
this._capability = _capability;
|
|
2590
|
+
this._register(this._model.onDidChangeContent(() => {
|
|
2591
|
+
this._scheduleDiagnosticUpdate();
|
|
2592
|
+
}));
|
|
2593
|
+
this._scheduleDiagnosticUpdate();
|
|
2594
|
+
}
|
|
2595
|
+
_scheduleDiagnosticUpdate() {
|
|
2596
|
+
if (this._updateHandle !== void 0) clearTimeout(this._updateHandle);
|
|
2597
|
+
this._updateHandle = window.setTimeout(() => {
|
|
2598
|
+
this._updateHandle = void 0;
|
|
2599
|
+
this._requestDiagnostics();
|
|
2600
|
+
}, 500);
|
|
2601
|
+
}
|
|
2602
|
+
async _requestDiagnostics() {
|
|
2603
|
+
if (this._model.isDisposed()) return;
|
|
2604
|
+
try {
|
|
2605
|
+
const translated = this._connection.bridge.translate(this._model, new editor.Position(1, 1));
|
|
2606
|
+
const result = await this._connection.server.textDocumentDiagnostic({
|
|
2607
|
+
textDocument: translated.textDocument,
|
|
2608
|
+
identifier: this._capability.identifier,
|
|
2609
|
+
previousResultId: this._previousResultId
|
|
2610
|
+
});
|
|
2611
|
+
if (this._model.isDisposed()) return;
|
|
2612
|
+
this._handleDiagnosticReport(result);
|
|
2613
|
+
} catch (error) {
|
|
2614
|
+
console.error("Error requesting diagnostics:", error);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
_handleDiagnosticReport(report) {
|
|
2618
|
+
if (report.kind === "full") {
|
|
2619
|
+
this._previousResultId = report.resultId;
|
|
2620
|
+
const markers = report.items.map((diagnostic) => toDiagnosticMarker(diagnostic));
|
|
2621
|
+
editor.editor.setModelMarkers(this._model, this._markerOwner, markers);
|
|
2622
|
+
if ("relatedDocuments" in report && report.relatedDocuments) this._handleRelatedDocuments(report.relatedDocuments);
|
|
2623
|
+
} else if (report.kind === "unchanged") this._previousResultId = report.resultId;
|
|
2624
|
+
}
|
|
2625
|
+
_handleRelatedDocuments(relatedDocuments) {
|
|
2626
|
+
for (const [uri, report] of Object.entries(relatedDocuments)) try {
|
|
2627
|
+
const model = this._connection.bridge.translateBack({ uri }, {
|
|
2628
|
+
line: 0,
|
|
2629
|
+
character: 0
|
|
2630
|
+
}).textModel;
|
|
2631
|
+
if (!model || model.isDisposed()) continue;
|
|
2632
|
+
if (report.kind === "full") {
|
|
2633
|
+
const markers = report.items.map((diagnostic) => toDiagnosticMarker(diagnostic));
|
|
2634
|
+
editor.editor.setModelMarkers(model, this._markerOwner, markers);
|
|
2635
|
+
}
|
|
2636
|
+
} catch (error) {
|
|
2637
|
+
console.debug(`Could not set related diagnostics for ${uri}:`, error);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
dispose() {
|
|
2641
|
+
if (this._updateHandle !== void 0) {
|
|
2642
|
+
clearTimeout(this._updateHandle);
|
|
2643
|
+
this._updateHandle = void 0;
|
|
2644
|
+
}
|
|
2645
|
+
super.dispose();
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2648
|
+
var LspConnection = class {
|
|
2649
|
+
constructor(server, bridge, capabilities$1, connection) {
|
|
2650
|
+
this.server = server;
|
|
2651
|
+
this.bridge = bridge;
|
|
2652
|
+
this.capabilities = capabilities$1;
|
|
2653
|
+
this.connection = connection;
|
|
2654
|
+
}
|
|
2655
|
+
};
|
|
2656
|
+
var LspCapabilitiesRegistry = class extends Disposable {
|
|
2657
|
+
_staticCapabilities = /* @__PURE__ */ new Set();
|
|
2658
|
+
_dynamicFromStatic = DynamicFromStaticOptions.create();
|
|
2659
|
+
_registrations = /* @__PURE__ */ new Map();
|
|
2660
|
+
_serverCapabilities = void 0;
|
|
2661
|
+
constructor(_connection) {
|
|
2662
|
+
super();
|
|
2663
|
+
this._connection = _connection;
|
|
2664
|
+
this._register(this._connection.registerRequestHandler(api.client.clientRegisterCapability, async (params) => {
|
|
2665
|
+
for (const registration of params.registrations) {
|
|
2666
|
+
const capability = getCapabilityByMethod(registration.method);
|
|
2667
|
+
const r = new CapabilityRegistration(registration.id, capability, registration.registerOptions, false);
|
|
2668
|
+
this._registerCapabilityOptions(r);
|
|
2669
|
+
}
|
|
2670
|
+
return { ok: null };
|
|
2671
|
+
}));
|
|
2672
|
+
this._register(this._connection.registerRequestHandler(api.client.clientUnregisterCapability, async (params) => {
|
|
2673
|
+
for (const unregistration of params.unregisterations) {
|
|
2674
|
+
const capability = getCapabilityByMethod(unregistration.method);
|
|
2675
|
+
const info = this._registrations.get(capability);
|
|
2676
|
+
const handlerInfo = info?.registrations.get(unregistration.id);
|
|
2677
|
+
if (!handlerInfo) throw new Error(`No registration for method ${unregistration.method} with id ${unregistration.id}`);
|
|
2678
|
+
handlerInfo?.handlerDisposables.forEach((d) => d.dispose());
|
|
2679
|
+
info?.registrations.delete(unregistration.id);
|
|
2680
|
+
}
|
|
2681
|
+
return { ok: null };
|
|
2682
|
+
}));
|
|
2683
|
+
}
|
|
2684
|
+
_registerCapabilityOptions(registration) {
|
|
2685
|
+
let registrationForMethod = this._registrations.get(registration.capability);
|
|
2686
|
+
if (!registrationForMethod) {
|
|
2687
|
+
registrationForMethod = new CapabilityInfo();
|
|
2688
|
+
this._registrations.set(registration.capability, registrationForMethod);
|
|
2689
|
+
}
|
|
2690
|
+
if (registrationForMethod.registrations.has(registration.id)) throw new Error(`Handler for method ${registration.capability.method} with id ${registration.id} already registered`);
|
|
2691
|
+
registrationForMethod.registrations.set(registration.id, registration);
|
|
2692
|
+
for (const h of registrationForMethod.handlers) {
|
|
2693
|
+
if (!h.handleStaticCapability && registration.isFromStatic) continue;
|
|
2694
|
+
registration.handlerDisposables.set(h, h.handler(registration.options));
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
setServerCapabilities(serverCapabilities) {
|
|
2698
|
+
if (this._serverCapabilities) throw new Error("Server capabilities already set");
|
|
2699
|
+
this._serverCapabilities = serverCapabilities;
|
|
2700
|
+
for (const cap of Object.values(capabilities)) {
|
|
2701
|
+
const options = this._dynamicFromStatic.getOptions(cap, serverCapabilities);
|
|
2702
|
+
if (options) this._registerCapabilityOptions(new CapabilityRegistration(cap.method, cap, options, true));
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
getClientCapabilities() {
|
|
2706
|
+
const result = {};
|
|
2707
|
+
for (const c of this._staticCapabilities) deepAssign(result, c.cap);
|
|
2708
|
+
return result;
|
|
2709
|
+
}
|
|
2710
|
+
addStaticClientCapabilities(capability) {
|
|
2711
|
+
const obj = { cap: capability };
|
|
2712
|
+
this._staticCapabilities.add(obj);
|
|
2713
|
+
return { dispose: () => {
|
|
2714
|
+
this._staticCapabilities.delete(obj);
|
|
2715
|
+
} };
|
|
2716
|
+
}
|
|
2717
|
+
registerCapabilityHandler(capability, handleStaticCapability, handler) {
|
|
2718
|
+
let info = this._registrations.get(capability);
|
|
2719
|
+
if (!info) {
|
|
2720
|
+
info = new CapabilityInfo();
|
|
2721
|
+
this._registrations.set(capability, info);
|
|
2722
|
+
}
|
|
2723
|
+
const handlerInfo = new CapabilityHandler(capability, handleStaticCapability, handler);
|
|
2724
|
+
info.handlers.add(handlerInfo);
|
|
2725
|
+
for (const registration of info.registrations.values()) {
|
|
2726
|
+
if (!handlerInfo.handleStaticCapability && registration.isFromStatic) continue;
|
|
2727
|
+
registration.handlerDisposables.set(handlerInfo, handler(registration.options));
|
|
2728
|
+
}
|
|
2729
|
+
return { dispose: () => {
|
|
2730
|
+
info.handlers.delete(handlerInfo);
|
|
2731
|
+
for (const registration of info.registrations.values()) {
|
|
2732
|
+
const disposable = registration.handlerDisposables.get(handlerInfo);
|
|
2733
|
+
if (disposable) {
|
|
2734
|
+
disposable.dispose();
|
|
2735
|
+
registration.handlerDisposables.delete(handlerInfo);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
} };
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2741
|
+
var CapabilityHandler = class {
|
|
2742
|
+
constructor(capability, handleStaticCapability, handler) {
|
|
2743
|
+
this.capability = capability;
|
|
2744
|
+
this.handleStaticCapability = handleStaticCapability;
|
|
2745
|
+
this.handler = handler;
|
|
2746
|
+
}
|
|
2747
|
+
};
|
|
2748
|
+
var CapabilityRegistration = class {
|
|
2749
|
+
handlerDisposables = /* @__PURE__ */ new Map();
|
|
2750
|
+
constructor(id, capability, options, isFromStatic) {
|
|
2751
|
+
this.id = id;
|
|
2752
|
+
this.capability = capability;
|
|
2753
|
+
this.options = options;
|
|
2754
|
+
this.isFromStatic = isFromStatic;
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
const capabilitiesByMethod = new Map([...Object.values(capabilities)].map((c) => [c.method, c]));
|
|
2758
|
+
function getCapabilityByMethod(method) {
|
|
2759
|
+
const c = capabilitiesByMethod.get(method);
|
|
2760
|
+
if (!c) throw new Error(`No capability found for method ${method}`);
|
|
2761
|
+
return c;
|
|
2762
|
+
}
|
|
2763
|
+
var CapabilityInfo = class {
|
|
2764
|
+
handlers = /* @__PURE__ */ new Set();
|
|
2765
|
+
registrations = /* @__PURE__ */ new Map();
|
|
2766
|
+
};
|
|
2767
|
+
var DynamicFromStaticOptions = class DynamicFromStaticOptions2 {
|
|
2768
|
+
_mappings = /* @__PURE__ */ new Map();
|
|
2769
|
+
static create() {
|
|
2770
|
+
const o = new DynamicFromStaticOptions2();
|
|
2771
|
+
o.set(capabilities.textDocumentDidChange, (s) => {
|
|
2772
|
+
if (s.textDocumentSync === void 0) return;
|
|
2773
|
+
if (typeof s.textDocumentSync === "object") return {
|
|
2774
|
+
syncKind: s.textDocumentSync.change ?? TextDocumentSyncKind.None,
|
|
2775
|
+
documentSelector: null
|
|
2776
|
+
};
|
|
2777
|
+
else return {
|
|
2778
|
+
syncKind: s.textDocumentSync,
|
|
2779
|
+
documentSelector: null
|
|
2780
|
+
};
|
|
2781
|
+
});
|
|
2782
|
+
o.set(capabilities.textDocumentCompletion, (s) => s.completionProvider);
|
|
2783
|
+
o.set(capabilities.textDocumentHover, (s) => s.hoverProvider);
|
|
2784
|
+
o.set(capabilities.textDocumentSignatureHelp, (s) => s.signatureHelpProvider);
|
|
2785
|
+
o.set(capabilities.textDocumentDefinition, (s) => s.definitionProvider);
|
|
2786
|
+
o.set(capabilities.textDocumentReferences, (s) => s.referencesProvider);
|
|
2787
|
+
o.set(capabilities.textDocumentDocumentHighlight, (s) => s.documentHighlightProvider);
|
|
2788
|
+
o.set(capabilities.textDocumentDocumentSymbol, (s) => s.documentSymbolProvider);
|
|
2789
|
+
o.set(capabilities.textDocumentCodeAction, (s) => s.codeActionProvider);
|
|
2790
|
+
o.set(capabilities.textDocumentCodeLens, (s) => s.codeLensProvider);
|
|
2791
|
+
o.set(capabilities.textDocumentDocumentLink, (s) => s.documentLinkProvider);
|
|
2792
|
+
o.set(capabilities.textDocumentFormatting, (s) => s.documentFormattingProvider);
|
|
2793
|
+
o.set(capabilities.textDocumentRangeFormatting, (s) => s.documentRangeFormattingProvider);
|
|
2794
|
+
o.set(capabilities.textDocumentOnTypeFormatting, (s) => s.documentOnTypeFormattingProvider);
|
|
2795
|
+
o.set(capabilities.textDocumentRename, (s) => s.renameProvider);
|
|
2796
|
+
o.set(capabilities.textDocumentFoldingRange, (s) => s.foldingRangeProvider);
|
|
2797
|
+
o.set(capabilities.textDocumentDeclaration, (s) => s.declarationProvider);
|
|
2798
|
+
o.set(capabilities.textDocumentTypeDefinition, (s) => s.typeDefinitionProvider);
|
|
2799
|
+
o.set(capabilities.textDocumentImplementation, (s) => s.implementationProvider);
|
|
2800
|
+
o.set(capabilities.textDocumentDocumentColor, (s) => s.colorProvider);
|
|
2801
|
+
o.set(capabilities.textDocumentSelectionRange, (s) => s.selectionRangeProvider);
|
|
2802
|
+
o.set(capabilities.textDocumentLinkedEditingRange, (s) => s.linkedEditingRangeProvider);
|
|
2803
|
+
o.set(capabilities.textDocumentPrepareCallHierarchy, (s) => s.callHierarchyProvider);
|
|
2804
|
+
o.set(capabilities.textDocumentSemanticTokensFull, (s) => s.semanticTokensProvider);
|
|
2805
|
+
o.set(capabilities.textDocumentInlayHint, (s) => s.inlayHintProvider);
|
|
2806
|
+
o.set(capabilities.textDocumentInlineValue, (s) => s.inlineValueProvider);
|
|
2807
|
+
o.set(capabilities.textDocumentDiagnostic, (s) => s.diagnosticProvider);
|
|
2808
|
+
o.set(capabilities.textDocumentMoniker, (s) => s.monikerProvider);
|
|
2809
|
+
o.set(capabilities.textDocumentPrepareTypeHierarchy, (s) => s.typeHierarchyProvider);
|
|
2810
|
+
o.set(capabilities.workspaceSymbol, (s) => s.workspaceSymbolProvider);
|
|
2811
|
+
o.set(capabilities.workspaceExecuteCommand, (s) => s.executeCommandProvider);
|
|
2812
|
+
return o;
|
|
2813
|
+
}
|
|
2814
|
+
set(capability, getOptionsFromStatic) {
|
|
2815
|
+
if (this._mappings.has(capability.method)) throw new Error(`Capability for method ${capability.method} already registered`);
|
|
2816
|
+
this._mappings.set(capability.method, getOptionsFromStatic);
|
|
2817
|
+
}
|
|
2818
|
+
getOptions(capability, serverCapabilities) {
|
|
2819
|
+
const getter = this._mappings.get(capability.method);
|
|
2820
|
+
if (!getter) return;
|
|
2821
|
+
return getter(serverCapabilities);
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
function deepAssign(target, source) {
|
|
2825
|
+
for (const key of Object.keys(source)) {
|
|
2826
|
+
const srcValue = source[key];
|
|
2827
|
+
if (srcValue === void 0) continue;
|
|
2828
|
+
const tgtValue = target[key];
|
|
2829
|
+
if (tgtValue === void 0) {
|
|
2830
|
+
target[key] = srcValue;
|
|
2831
|
+
continue;
|
|
2832
|
+
}
|
|
2833
|
+
if (typeof srcValue !== "object" || srcValue === null) {
|
|
2834
|
+
target[key] = srcValue;
|
|
2835
|
+
continue;
|
|
2836
|
+
}
|
|
2837
|
+
if (typeof tgtValue !== "object" || tgtValue === null) {
|
|
2838
|
+
target[key] = srcValue;
|
|
2839
|
+
continue;
|
|
2840
|
+
}
|
|
2841
|
+
deepAssign(tgtValue, srcValue);
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
var TextDocumentSynchronizer = class extends Disposable {
|
|
2845
|
+
_managedModels = /* @__PURE__ */ new Map();
|
|
2846
|
+
_managedModelsReverse = /* @__PURE__ */ new Map();
|
|
2847
|
+
_started = false;
|
|
2848
|
+
constructor(_server, _capabilities) {
|
|
2849
|
+
super();
|
|
2850
|
+
this._server = _server;
|
|
2851
|
+
this._capabilities = _capabilities;
|
|
2852
|
+
this._register(this._capabilities.addStaticClientCapabilities({ textDocument: { synchronization: {
|
|
2853
|
+
dynamicRegistration: true,
|
|
2854
|
+
willSave: false,
|
|
2855
|
+
willSaveWaitUntil: false,
|
|
2856
|
+
didSave: false
|
|
2857
|
+
} } }));
|
|
2858
|
+
this._register(_capabilities.registerCapabilityHandler(capabilities.textDocumentDidChange, true, (e) => {
|
|
2859
|
+
if (this._started) return { dispose: () => {
|
|
2860
|
+
} };
|
|
2861
|
+
this._started = true;
|
|
2862
|
+
this._register(editor.editor.onDidCreateModel((m) => {
|
|
2863
|
+
this._getOrCreateManagedModel(m);
|
|
2864
|
+
}));
|
|
2865
|
+
for (const m of editor.editor.getModels()) this._getOrCreateManagedModel(m);
|
|
2866
|
+
return { dispose: () => {
|
|
2867
|
+
} };
|
|
2868
|
+
}));
|
|
2869
|
+
}
|
|
2870
|
+
_getOrCreateManagedModel(m) {
|
|
2871
|
+
if (!this._started) throw new Error("Not started");
|
|
2872
|
+
const uriStr = m.uri.toString(true).toLowerCase();
|
|
2873
|
+
let mm = this._managedModels.get(m);
|
|
2874
|
+
if (!mm) {
|
|
2875
|
+
mm = new ManagedModel(m, this._server);
|
|
2876
|
+
this._managedModels.set(m, mm);
|
|
2877
|
+
this._managedModelsReverse.set(uriStr, m);
|
|
2878
|
+
}
|
|
2879
|
+
m.onWillDispose(() => {
|
|
2880
|
+
mm.dispose();
|
|
2881
|
+
this._managedModels.delete(m);
|
|
2882
|
+
this._managedModelsReverse.delete(uriStr);
|
|
2883
|
+
});
|
|
2884
|
+
return mm;
|
|
2885
|
+
}
|
|
2886
|
+
translateBack(textDocument, position) {
|
|
2887
|
+
const uri = textDocument.uri.toLowerCase();
|
|
2888
|
+
const textModel = this._managedModelsReverse.get(uri);
|
|
2889
|
+
if (!textModel) throw new Error(`No text model for uri ${uri}`);
|
|
2890
|
+
return {
|
|
2891
|
+
textModel,
|
|
2892
|
+
position: new editor.Position(position.line + 1, position.character + 1)
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
translateBackRange(textDocument, range) {
|
|
2896
|
+
const uri = textDocument.uri.toLowerCase();
|
|
2897
|
+
const textModel = this._managedModelsReverse.get(uri);
|
|
2898
|
+
if (!textModel) throw new Error(`No text model for uri ${uri}`);
|
|
2899
|
+
return {
|
|
2900
|
+
textModel,
|
|
2901
|
+
range: new editor.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1)
|
|
2902
|
+
};
|
|
2903
|
+
}
|
|
2904
|
+
translate(textModel, monacoPos) {
|
|
2905
|
+
return {
|
|
2906
|
+
textDocument: { uri: textModel.uri.toString(true) },
|
|
2907
|
+
position: {
|
|
2908
|
+
line: monacoPos.lineNumber - 1,
|
|
2909
|
+
character: monacoPos.column - 1
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
translateRange(textModel, monacoRange) {
|
|
2914
|
+
return {
|
|
2915
|
+
start: {
|
|
2916
|
+
line: monacoRange.startLineNumber - 1,
|
|
2917
|
+
character: monacoRange.startColumn - 1
|
|
2918
|
+
},
|
|
2919
|
+
end: {
|
|
2920
|
+
line: monacoRange.endLineNumber - 1,
|
|
2921
|
+
character: monacoRange.endColumn - 1
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
var ManagedModel = class extends Disposable {
|
|
2927
|
+
constructor(_textModel, _api) {
|
|
2928
|
+
super();
|
|
2929
|
+
this._textModel = _textModel;
|
|
2930
|
+
this._api = _api;
|
|
2931
|
+
const uri = _textModel.uri.toString(true).toLowerCase();
|
|
2932
|
+
this._api.textDocumentDidOpen({ textDocument: {
|
|
2933
|
+
languageId: _textModel.getLanguageId(),
|
|
2934
|
+
uri,
|
|
2935
|
+
version: _textModel.getVersionId(),
|
|
2936
|
+
text: _textModel.getValue()
|
|
2937
|
+
} });
|
|
2938
|
+
this._register(_textModel.onDidChangeContent((e) => {
|
|
2939
|
+
const contentChanges = e.changes.map((c) => toLspTextDocumentContentChangeEvent(c));
|
|
2940
|
+
this._api.textDocumentDidChange({
|
|
2941
|
+
textDocument: {
|
|
2942
|
+
uri,
|
|
2943
|
+
version: _textModel.getVersionId()
|
|
2944
|
+
},
|
|
2945
|
+
contentChanges
|
|
2946
|
+
});
|
|
2947
|
+
}));
|
|
2948
|
+
this._register({ dispose: () => {
|
|
2949
|
+
this._api.textDocumentDidClose({ textDocument: { uri } });
|
|
2950
|
+
} });
|
|
2951
|
+
}
|
|
2952
|
+
};
|
|
2953
|
+
function toLspTextDocumentContentChangeEvent(change) {
|
|
2954
|
+
return {
|
|
2955
|
+
range: toLspRange(change.range),
|
|
2956
|
+
rangeLength: change.rangeLength,
|
|
2957
|
+
text: change.text
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
function toLspRange(range) {
|
|
2961
|
+
return {
|
|
2962
|
+
start: {
|
|
2963
|
+
line: range.startLineNumber - 1,
|
|
2964
|
+
character: range.startColumn - 1
|
|
2965
|
+
},
|
|
2966
|
+
end: {
|
|
2967
|
+
line: range.endLineNumber - 1,
|
|
2968
|
+
character: range.endColumn - 1
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
}
|
|
2972
|
+
var MonacoLspClient = class {
|
|
2973
|
+
_connection;
|
|
2974
|
+
_capabilitiesRegistry;
|
|
2975
|
+
_bridge;
|
|
2976
|
+
_initPromise;
|
|
2977
|
+
constructor(transport) {
|
|
2978
|
+
const c = TypedChannel.fromTransport(transport);
|
|
2979
|
+
const s = api.getServer(c, {});
|
|
2980
|
+
c.startListen();
|
|
2981
|
+
this._capabilitiesRegistry = new LspCapabilitiesRegistry(c);
|
|
2982
|
+
this._bridge = new TextDocumentSynchronizer(s.server, this._capabilitiesRegistry);
|
|
2983
|
+
this._connection = new LspConnection(s.server, this._bridge, this._capabilitiesRegistry, c);
|
|
2984
|
+
this.createFeatures();
|
|
2985
|
+
this._initPromise = this._init();
|
|
2986
|
+
}
|
|
2987
|
+
async _init() {
|
|
2988
|
+
const result = await this._connection.server.initialize({
|
|
2989
|
+
processId: null,
|
|
2990
|
+
capabilities: this._capabilitiesRegistry.getClientCapabilities(),
|
|
2991
|
+
rootUri: null
|
|
2992
|
+
});
|
|
2993
|
+
this._connection.server.initialized({});
|
|
2994
|
+
this._capabilitiesRegistry.setServerCapabilities(result.capabilities);
|
|
2995
|
+
}
|
|
2996
|
+
createFeatures() {
|
|
2997
|
+
const store = new DisposableStore();
|
|
2998
|
+
store.add(new LspCompletionFeature(this._connection));
|
|
2999
|
+
store.add(new LspHoverFeature(this._connection));
|
|
3000
|
+
store.add(new LspSignatureHelpFeature(this._connection));
|
|
3001
|
+
store.add(new LspDefinitionFeature(this._connection));
|
|
3002
|
+
store.add(new LspDeclarationFeature(this._connection));
|
|
3003
|
+
store.add(new LspTypeDefinitionFeature(this._connection));
|
|
3004
|
+
store.add(new LspImplementationFeature(this._connection));
|
|
3005
|
+
store.add(new LspReferencesFeature(this._connection));
|
|
3006
|
+
store.add(new LspDocumentHighlightFeature(this._connection));
|
|
3007
|
+
store.add(new LspDocumentSymbolFeature(this._connection));
|
|
3008
|
+
store.add(new LspRenameFeature(this._connection));
|
|
3009
|
+
store.add(new LspCodeActionFeature(this._connection));
|
|
3010
|
+
store.add(new LspCodeLensFeature(this._connection));
|
|
3011
|
+
store.add(new LspDocumentLinkFeature(this._connection));
|
|
3012
|
+
store.add(new LspFormattingFeature(this._connection));
|
|
3013
|
+
store.add(new LspRangeFormattingFeature(this._connection));
|
|
3014
|
+
store.add(new LspOnTypeFormattingFeature(this._connection));
|
|
3015
|
+
store.add(new LspFoldingRangeFeature(this._connection));
|
|
3016
|
+
store.add(new LspSelectionRangeFeature(this._connection));
|
|
3017
|
+
store.add(new LspInlayHintsFeature(this._connection));
|
|
3018
|
+
store.add(new LspSemanticTokensFeature(this._connection));
|
|
3019
|
+
store.add(new LspDiagnosticsFeature(this._connection));
|
|
3020
|
+
return store;
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
var ws = null;
|
|
3024
|
+
if (typeof WebSocket !== "undefined") ws = WebSocket;
|
|
3025
|
+
else if (typeof MozWebSocket !== "undefined") ws = MozWebSocket;
|
|
3026
|
+
else if (typeof global !== "undefined") ws = global.WebSocket || global.MozWebSocket;
|
|
3027
|
+
else if (typeof window !== "undefined") ws = window.WebSocket || window.MozWebSocket;
|
|
3028
|
+
else if (typeof self !== "undefined") ws = self.WebSocket || self.MozWebSocket;
|
|
3029
|
+
var browser_default = ws;
|
|
3030
|
+
function normalizeWebSocketOptions(options) {
|
|
3031
|
+
if ("host" in options) return { address: `${options.forceTls ? "wss" : "ws"}://${options.host}:${options.port}` };
|
|
3032
|
+
else return options;
|
|
3033
|
+
}
|
|
3034
|
+
var WebSocketTransport = class WebSocketTransport2 extends BaseMessageTransport {
|
|
3035
|
+
socket;
|
|
3036
|
+
static connectTo(options) {
|
|
3037
|
+
const ws$1 = new browser_default(normalizeWebSocketOptions(options).address);
|
|
3038
|
+
return new Promise((res, rej) => {
|
|
3039
|
+
ws$1.onerror = (err) => {
|
|
3040
|
+
rej(err);
|
|
3041
|
+
};
|
|
3042
|
+
ws$1.onopen = () => {
|
|
3043
|
+
res(new WebSocketTransport2(ws$1));
|
|
3044
|
+
};
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
static fromWebSocket(socket) {
|
|
3048
|
+
return new WebSocketTransport2(socket);
|
|
3049
|
+
}
|
|
3050
|
+
errorEmitter = new EventEmitter();
|
|
3051
|
+
onError = this.errorEmitter;
|
|
3052
|
+
constructor(socket) {
|
|
3053
|
+
super();
|
|
3054
|
+
this.socket = socket;
|
|
3055
|
+
socket.onmessage = (msg) => {
|
|
3056
|
+
try {
|
|
3057
|
+
const data = msg.data;
|
|
3058
|
+
if (typeof data === "string") {
|
|
3059
|
+
const json = JSON.parse(data);
|
|
3060
|
+
this._dispatchReceivedMessage(json);
|
|
3061
|
+
} else throw new Error("Not supported");
|
|
3062
|
+
} catch (error) {
|
|
3063
|
+
this.errorEmitter.fire({ error });
|
|
3064
|
+
}
|
|
3065
|
+
};
|
|
3066
|
+
socket.onclose = (_event) => {
|
|
3067
|
+
this._onConnectionClosed();
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
3070
|
+
/**
|
|
3071
|
+
* Closes the underlying socket.
|
|
3072
|
+
*/
|
|
3073
|
+
close() {
|
|
3074
|
+
this.socket.close();
|
|
3075
|
+
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Same as `close`.
|
|
3078
|
+
*/
|
|
3079
|
+
dispose() {
|
|
3080
|
+
this.close();
|
|
3081
|
+
}
|
|
3082
|
+
_sendImpl(message) {
|
|
3083
|
+
const str = JSON.stringify(message);
|
|
3084
|
+
return new Promise((res, rej) => {
|
|
3085
|
+
this.socket.send(str, (err) => {
|
|
3086
|
+
if (err) rej(err);
|
|
3087
|
+
else res();
|
|
3088
|
+
});
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
toString() {
|
|
3092
|
+
return `${this.id}@${this.socket.url}`;
|
|
3093
|
+
}
|
|
3094
|
+
};
|
|
3095
|
+
var WindowLikeTransport = class extends BaseMessageTransport {
|
|
3096
|
+
_windowLike;
|
|
3097
|
+
_source;
|
|
3098
|
+
_loadingState;
|
|
3099
|
+
_disposed = false;
|
|
3100
|
+
constructor(_windowLike, _source = void 0, _loadingState = void 0) {
|
|
3101
|
+
super();
|
|
3102
|
+
this._windowLike = _windowLike;
|
|
3103
|
+
this._source = _source;
|
|
3104
|
+
this._loadingState = _loadingState;
|
|
3105
|
+
this._windowLike.addEventListener("message", this._messageHandler);
|
|
3106
|
+
}
|
|
3107
|
+
_messageHandler = ({ data, source }) => {
|
|
3108
|
+
if (this._source && source !== this._source) return;
|
|
3109
|
+
if (typeof data === "object" && data) this._dispatchReceivedMessage(data);
|
|
3110
|
+
};
|
|
3111
|
+
async _sendImpl(message) {
|
|
3112
|
+
if (this._disposed) throw new Error("Transport is disposed");
|
|
3113
|
+
if (this._loadingState && !this._loadingState.loaded) await this._loadingState.onLoaded;
|
|
3114
|
+
this._windowLike.postMessage(message);
|
|
3115
|
+
}
|
|
3116
|
+
toString() {
|
|
3117
|
+
return `${this.id}@${this._windowLike}`;
|
|
3118
|
+
}
|
|
3119
|
+
dispose() {
|
|
3120
|
+
if (this._disposed) return;
|
|
3121
|
+
this._disposed = true;
|
|
3122
|
+
this._windowLike.removeEventListener("message", this._messageHandler);
|
|
3123
|
+
}
|
|
3124
|
+
};
|
|
3125
|
+
function createTransportToWorker(worker) {
|
|
3126
|
+
if (typeof window === "undefined") throw new Error(`call this function from the main browser thread`);
|
|
3127
|
+
return new WindowLikeTransport(worker);
|
|
3128
|
+
}
|
|
3129
|
+
function createTransportToIFrame(iframe) {
|
|
3130
|
+
if (typeof window === "undefined") throw new Error(`call this function from the main browser thread`);
|
|
3131
|
+
return new WindowLikeTransport(iframe.contentWindow, iframe.contentWindow, {
|
|
3132
|
+
loaded: window.document.readyState === "complete",
|
|
3133
|
+
onLoaded: new Promise((res) => {
|
|
3134
|
+
window.addEventListener("load", () => res());
|
|
3135
|
+
})
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3138
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3139
|
+
__proto__: null,
|
|
3140
|
+
MonacoLspClient,
|
|
3141
|
+
WebSocketTransport,
|
|
3142
|
+
createTransportToIFrame,
|
|
3143
|
+
createTransportToWorker
|
|
3144
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3145
|
+
const monaco = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3146
|
+
__proto__: null,
|
|
3147
|
+
CancellationTokenSource: editor.CancellationTokenSource,
|
|
3148
|
+
Emitter: editor.Emitter,
|
|
3149
|
+
KeyCode: editor.KeyCode,
|
|
3150
|
+
KeyMod: editor.KeyMod,
|
|
3151
|
+
MarkerSeverity: editor.MarkerSeverity,
|
|
3152
|
+
MarkerTag: editor.MarkerTag,
|
|
3153
|
+
Position: editor.Position,
|
|
3154
|
+
Range: editor.Range,
|
|
3155
|
+
Selection: editor.Selection,
|
|
3156
|
+
SelectionDirection: editor.SelectionDirection,
|
|
3157
|
+
Token: editor.Token,
|
|
3158
|
+
Uri: editor.Uri,
|
|
3159
|
+
css: src_deprecated_language_css_monaco_contribution_ts.register,
|
|
3160
|
+
editor: editor.editor,
|
|
3161
|
+
html: src_deprecated_language_html_monaco_contribution_ts.register,
|
|
3162
|
+
json: src_deprecated_language_json_monaco_contribution_ts.register,
|
|
3163
|
+
languages: editor.languages,
|
|
3164
|
+
lsp: index,
|
|
3165
|
+
typescript: src_deprecated_language_typescript_monaco_contribution_ts.register
|
|
3166
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3167
|
+
exports.index = index;
|
|
3168
|
+
exports.monaco = monaco;
|
|
3169
|
+
}));
|