monaco-editor11 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/monaco-editor11.es.js +11 -16
- package/dist/monaco-editor11.umd.js +1 -1
- package/package.json +2 -2
- package/dist/monaco.d.ts +0 -8
- package/dist/workers/common/initialize.js +0 -16
- package/dist/workers/common/workers.js +0 -141
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
- package/dist/workers/editor/common/abstractText.js +0 -89
- package/dist/workers/editor/common/ast.js +0 -485
- package/dist/workers/editor/common/autoIndent.js +0 -390
- package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
- package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
- package/dist/workers/editor/common/bracketPairsTree.js +0 -343
- package/dist/workers/editor/common/brackets.js +0 -108
- package/dist/workers/editor/common/characterClassifier.js +0 -59
- package/dist/workers/editor/common/characterPair.js +0 -40
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
- package/dist/workers/editor/common/columnRange.js +0 -35
- package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
- package/dist/workers/editor/common/common.js +0 -20
- package/dist/workers/editor/common/computeMovedLines.js +0 -249
- package/dist/workers/editor/common/concat23Trees.js +0 -192
- package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
- package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
- package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
- package/dist/workers/editor/common/coordinatesConverter.js +0 -51
- package/dist/workers/editor/common/cursor.js +0 -899
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
- package/dist/workers/editor/common/cursorCollection.js +0 -194
- package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
- package/dist/workers/editor/common/cursorColumns.js +0 -112
- package/dist/workers/editor/common/cursorCommon.js +0 -250
- package/dist/workers/editor/common/cursorContext.js +0 -15
- package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
- package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
- package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
- package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
- package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
- package/dist/workers/editor/common/cursorUtils.js +0 -75
- package/dist/workers/editor/common/cursorWordOperations.js +0 -720
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
- package/dist/workers/editor/common/diffAlgorithm.js +0 -139
- package/dist/workers/editor/common/diffEditor.js +0 -38
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
- package/dist/workers/editor/common/edit.js +0 -183
- package/dist/workers/editor/common/editOperation.js +0 -36
- package/dist/workers/editor/common/editStack.js +0 -363
- package/dist/workers/editor/common/editorAction.js +0 -26
- package/dist/workers/editor/common/editorBaseApi.js +0 -43
- package/dist/workers/editor/common/editorColorRegistry.js +0 -102
- package/dist/workers/editor/common/editorCommon.js +0 -13
- package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
- package/dist/workers/editor/common/editorContextKeys.js +0 -84
- package/dist/workers/editor/common/editorFeatures.js +0 -17
- package/dist/workers/editor/common/editorOptions.js +0 -3440
- package/dist/workers/editor/common/editorTheme.js +0 -23
- package/dist/workers/editor/common/editorWebWorker.js +0 -299
- package/dist/workers/editor/common/editorWorker.js +0 -9
- package/dist/workers/editor/common/editorWorkerHost.js +0 -15
- package/dist/workers/editor/common/editorZoom.js +0 -26
- package/dist/workers/editor/common/electricCharacter.js +0 -55
- package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
- package/dist/workers/editor/common/enterAction.js +0 -53
- package/dist/workers/editor/common/eolCounter.js +0 -44
- package/dist/workers/editor/common/findSectionHeaders.js +0 -128
- package/dist/workers/editor/common/fixBrackets.js +0 -67
- package/dist/workers/editor/common/fixedArray.js +0 -70
- package/dist/workers/editor/common/fontInfo.js +0 -172
- package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
- package/dist/workers/editor/common/getIconClasses.js +0 -106
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
- package/dist/workers/editor/common/glyphLanesModel.js +0 -61
- package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
- package/dist/workers/editor/common/indentRules.js +0 -63
- package/dist/workers/editor/common/indentation.js +0 -39
- package/dist/workers/editor/common/indentationGuesser.js +0 -178
- package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
- package/dist/workers/editor/common/inlineDecorations.js +0 -26
- package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
- package/dist/workers/editor/common/inputMode.js +0 -22
- package/dist/workers/editor/common/intervalTree.js +0 -1002
- package/dist/workers/editor/common/language.js +0 -9
- package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
- package/dist/workers/editor/common/languageConfiguration.js +0 -138
- package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
- package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
- package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
- package/dist/workers/editor/common/languageFeatures.js +0 -9
- package/dist/workers/editor/common/languageFeaturesService.js +0 -47
- package/dist/workers/editor/common/languageSelector.js +0 -112
- package/dist/workers/editor/common/languageService.js +0 -92
- package/dist/workers/editor/common/languages.js +0 -522
- package/dist/workers/editor/common/languagesAssociations.js +0 -193
- package/dist/workers/editor/common/languagesRegistry.js +0 -237
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
- package/dist/workers/editor/common/length.js +0 -129
- package/dist/workers/editor/common/lineDecorations.js +0 -208
- package/dist/workers/editor/common/lineEdit.js +0 -75
- package/dist/workers/editor/common/lineHeights.js +0 -370
- package/dist/workers/editor/common/linePart.js +0 -25
- package/dist/workers/editor/common/lineRange.js +0 -312
- package/dist/workers/editor/common/lineSequence.js +0 -36
- package/dist/workers/editor/common/lineTokens.js +0 -405
- package/dist/workers/editor/common/linesDiffComputer.js +0 -29
- package/dist/workers/editor/common/linesDiffComputers.js +0 -13
- package/dist/workers/editor/common/linesLayout.js +0 -765
- package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
- package/dist/workers/editor/common/linkComputer.js +0 -269
- package/dist/workers/editor/common/markerDecorations.js +0 -9
- package/dist/workers/editor/common/markerDecorationsService.js +0 -248
- package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
- package/dist/workers/editor/common/mirrorTextModel.js +0 -117
- package/dist/workers/editor/common/model.js +0 -9
- package/dist/workers/editor/common/modelLineProjection.js +0 -350
- package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
- package/dist/workers/editor/common/modelService.js +0 -413
- package/dist/workers/editor/common/modesRegistry.js +0 -75
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
- package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
- package/dist/workers/editor/common/nodeReader.js +0 -127
- package/dist/workers/editor/common/nullTokenize.js +0 -29
- package/dist/workers/editor/common/offsetRange.js +0 -225
- package/dist/workers/editor/common/onEnter.js +0 -109
- package/dist/workers/editor/common/oneCursor.js +0 -117
- package/dist/workers/editor/common/overviewZoneManager.js +0 -176
- package/dist/workers/editor/common/parser.js +0 -121
- package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
- package/dist/workers/editor/common/point.js +0 -50
- package/dist/workers/editor/common/position.js +0 -142
- package/dist/workers/editor/common/positionToOffset.js +0 -17
- package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
- package/dist/workers/editor/common/prefixSumComputer.js +0 -226
- package/dist/workers/editor/common/range.js +0 -421
- package/dist/workers/editor/common/rangeMapping.js +0 -229
- package/dist/workers/editor/common/rangeSingleLine.js +0 -17
- package/dist/workers/editor/common/rbTreeBase.js +0 -362
- package/dist/workers/editor/common/rect.js +0 -163
- package/dist/workers/editor/common/replaceCommand.js +0 -158
- package/dist/workers/editor/common/resolverService.js +0 -5
- package/dist/workers/editor/common/rgba.js +0 -35
- package/dist/workers/editor/common/richEditBrackets.js +0 -356
- package/dist/workers/editor/common/selection.js +0 -145
- package/dist/workers/editor/common/semanticTokensDto.js +0 -82
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
- package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
- package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
- package/dist/workers/editor/common/shiftCommand.js +0 -241
- package/dist/workers/editor/common/smallImmutableSet.js +0 -108
- package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
- package/dist/workers/editor/common/sparseTokensStore.js +0 -210
- package/dist/workers/editor/common/standaloneEnums.js +0 -1017
- package/dist/workers/editor/common/standaloneStrings.js +0 -42
- package/dist/workers/editor/common/stringBuilder.js +0 -122
- package/dist/workers/editor/common/stringEdit.js +0 -165
- package/dist/workers/editor/common/supports.js +0 -58
- package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
- package/dist/workers/editor/common/textChange.js +0 -248
- package/dist/workers/editor/common/textEdit.js +0 -269
- package/dist/workers/editor/common/textLength.js +0 -87
- package/dist/workers/editor/common/textModel.js +0 -2031
- package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
- package/dist/workers/editor/common/textModelDefaults.js +0 -18
- package/dist/workers/editor/common/textModelEditSource.js +0 -166
- package/dist/workers/editor/common/textModelEvents.js +0 -216
- package/dist/workers/editor/common/textModelGuides.js +0 -40
- package/dist/workers/editor/common/textModelPart.js +0 -23
- package/dist/workers/editor/common/textModelSearch.js +0 -455
- package/dist/workers/editor/common/textModelStringEdit.js +0 -11
- package/dist/workers/editor/common/textModelSync.impl.js +0 -307
- package/dist/workers/editor/common/textModelText.js +0 -26
- package/dist/workers/editor/common/textModelTokens.js +0 -436
- package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
- package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
- package/dist/workers/editor/common/tokenStore.js +0 -407
- package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
- package/dist/workers/editor/common/tokenization.js +0 -287
- package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
- package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
- package/dist/workers/editor/common/tokenizer.js +0 -301
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
- package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
- package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
- package/dist/workers/editor/common/treeSitterTree.js +0 -395
- package/dist/workers/editor/common/treeViewsDnd.js +0 -24
- package/dist/workers/editor/common/treeViewsDndService.js +0 -12
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
- package/dist/workers/editor/common/utils.js +0 -62
- package/dist/workers/editor/common/viewContext.js +0 -22
- package/dist/workers/editor/common/viewEventHandler.js +0 -186
- package/dist/workers/editor/common/viewEvents.js +0 -180
- package/dist/workers/editor/common/viewLayout.js +0 -368
- package/dist/workers/editor/common/viewLineRenderer.js +0 -948
- package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
- package/dist/workers/editor/common/viewModel.js +0 -98
- package/dist/workers/editor/common/viewModelDecoration.js +0 -55
- package/dist/workers/editor/common/viewModelDecorations.js +0 -132
- package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
- package/dist/workers/editor/common/viewModelImpl.js +0 -1163
- package/dist/workers/editor/common/viewModelLines.js +0 -938
- package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
- package/dist/workers/editor/common/wordHelper.js +0 -127
- package/dist/workers/language/cssMode.js +0 -198
- package/dist/workers/language/cssWorker.js +0 -183
- package/dist/workers/language/htmlMode.js +0 -213
- package/dist/workers/language/htmlWorker.js +0 -126
- package/dist/workers/language/jsonMode.js +0 -224
- package/dist/workers/language/jsonWorker.js +0 -187
- package/dist/workers/language/languageFeatures.js +0 -1009
- package/dist/workers/language/lib.index.js +0 -103
- package/dist/workers/language/lib.js +0 -1107
- package/dist/workers/language/lspLanguageFeatures.js +0 -716
- package/dist/workers/language/monaco.contribution.js +0 -144
- package/dist/workers/language/tokenization.js +0 -189
- package/dist/workers/language/tsMode.js +0 -212
- package/dist/workers/language/tsWorker.js +0 -352
- package/dist/workers/language/typescriptServices.js +0 -210154
- package/dist/workers/language/typescriptServicesMetadata.js +0 -3
- package/dist/workers/language/workerManager.js +0 -65
- /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
- /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
- /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
- /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
- /package/dist/workers/{language/ts.worker.js → ts.worker.js} +0 -0
|
@@ -1,1009 +0,0 @@
|
|
|
1
|
-
import { typescriptDefaults } from './monaco.contribution.js';
|
|
2
|
-
import { libFileSet } from './lib/lib.index.js';
|
|
3
|
-
import '../../editor/browser/coreCommands.js';
|
|
4
|
-
import '../../editor/browser/widget/codeEditor/codeEditorWidget.js';
|
|
5
|
-
import '../../editor/browser/widget/diffEditor/diffEditor.contribution.js';
|
|
6
|
-
import '../../editor/contrib/anchorSelect/browser/anchorSelect.js';
|
|
7
|
-
import '../../editor/contrib/bracketMatching/browser/bracketMatching.js';
|
|
8
|
-
import '../../editor/contrib/caretOperations/browser/caretOperations.js';
|
|
9
|
-
import '../../editor/contrib/caretOperations/browser/transpose.js';
|
|
10
|
-
import '../../editor/contrib/clipboard/browser/clipboard.js';
|
|
11
|
-
import '../../editor/contrib/codeAction/browser/codeActionContributions.js';
|
|
12
|
-
import '../../editor/contrib/codelens/browser/codelensController.js';
|
|
13
|
-
import '../../editor/contrib/colorPicker/browser/colorPickerContribution.js';
|
|
14
|
-
import '../../editor/contrib/comment/browser/comment.js';
|
|
15
|
-
import '../../editor/contrib/contextmenu/browser/contextmenu.js';
|
|
16
|
-
import '../../editor/contrib/cursorUndo/browser/cursorUndo.js';
|
|
17
|
-
import '../../editor/contrib/dnd/browser/dnd.js';
|
|
18
|
-
import '../../editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js';
|
|
19
|
-
import '../../editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js';
|
|
20
|
-
import '../../editor/contrib/find/browser/findController.js';
|
|
21
|
-
import '../../editor/contrib/folding/browser/folding.js';
|
|
22
|
-
import '../../editor/contrib/fontZoom/browser/fontZoom.js';
|
|
23
|
-
import '../../editor/contrib/format/browser/formatActions.js';
|
|
24
|
-
import '../../editor/contrib/documentSymbols/browser/documentSymbols.js';
|
|
25
|
-
import '../../editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js';
|
|
26
|
-
import '../../editor/contrib/inlineProgress/browser/inlineProgress.js';
|
|
27
|
-
import '../../editor/contrib/gotoSymbol/browser/goToCommands.js';
|
|
28
|
-
import '../../editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js';
|
|
29
|
-
import '../../editor/contrib/gotoError/browser/gotoError.js';
|
|
30
|
-
import '../../editor/contrib/gpu/browser/gpuActions.js';
|
|
31
|
-
import '../../editor/contrib/hover/browser/hoverContribution.js';
|
|
32
|
-
import '../../editor/contrib/indentation/browser/indentation.js';
|
|
33
|
-
import '../../editor/contrib/inlayHints/browser/inlayHintsContribution.js';
|
|
34
|
-
import '../../editor/contrib/inPlaceReplace/browser/inPlaceReplace.js';
|
|
35
|
-
import '../../editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js';
|
|
36
|
-
import '../../editor/contrib/lineSelection/browser/lineSelection.js';
|
|
37
|
-
import '../../editor/contrib/linesOperations/browser/linesOperations.js';
|
|
38
|
-
import '../../editor/contrib/linkedEditing/browser/linkedEditing.js';
|
|
39
|
-
import '../../editor/contrib/links/browser/links.js';
|
|
40
|
-
import '../../editor/contrib/longLinesHelper/browser/longLinesHelper.js';
|
|
41
|
-
import '../../editor/contrib/middleScroll/browser/middleScroll.contribution.js';
|
|
42
|
-
import '../../editor/contrib/multicursor/browser/multicursor.js';
|
|
43
|
-
import '../../editor/contrib/parameterHints/browser/parameterHints.js';
|
|
44
|
-
import '../../editor/contrib/placeholderText/browser/placeholderText.contribution.js';
|
|
45
|
-
import '../../editor/contrib/rename/browser/rename.js';
|
|
46
|
-
import '../../editor/contrib/sectionHeaders/browser/sectionHeaders.js';
|
|
47
|
-
import '../../editor/contrib/semanticTokens/browser/documentSemanticTokens.js';
|
|
48
|
-
import '../../editor/contrib/semanticTokens/browser/viewportSemanticTokens.js';
|
|
49
|
-
import '../../editor/contrib/smartSelect/browser/smartSelect.js';
|
|
50
|
-
import '../../editor/contrib/snippet/browser/snippetController2.js';
|
|
51
|
-
import '../../editor/contrib/stickyScroll/browser/stickyScrollContribution.js';
|
|
52
|
-
import '../../editor/contrib/suggest/browser/suggestController.js';
|
|
53
|
-
import '../../editor/contrib/suggest/browser/suggestInlineCompletions.js';
|
|
54
|
-
import '../../editor/contrib/tokenization/browser/tokenization.js';
|
|
55
|
-
import '../../editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js';
|
|
56
|
-
import '../../editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js';
|
|
57
|
-
import '../../editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js';
|
|
58
|
-
import '../../editor/contrib/wordHighlighter/browser/wordHighlighter.js';
|
|
59
|
-
import '../../editor/contrib/wordOperations/browser/wordOperations.js';
|
|
60
|
-
import '../../editor/contrib/wordPartOperations/browser/wordPartOperations.js';
|
|
61
|
-
import '../../editor/contrib/readOnlyMessage/browser/contribution.js';
|
|
62
|
-
import '../../editor/contrib/diffEditorBreadcrumbs/browser/contribution.js';
|
|
63
|
-
import '../../editor/contrib/floatingMenu/browser/floatingMenu.contribution.js';
|
|
64
|
-
import '../../editor/common/standaloneStrings.js';
|
|
65
|
-
import '../../base/browser/ui/codicons/codicon/codicon.css';
|
|
66
|
-
import '../../base/browser/ui/codicons/codicon/codicon-modifiers.css';
|
|
67
|
-
import '../../editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js';
|
|
68
|
-
import '../../editor/standalone/browser/inspectTokens/inspectTokens.js';
|
|
69
|
-
import '../../editor/standalone/browser/quickAccess/standaloneHelpQuickAccess.js';
|
|
70
|
-
import '../../editor/standalone/browser/quickAccess/standaloneGotoLineQuickAccess.js';
|
|
71
|
-
import '../../editor/standalone/browser/quickAccess/standaloneGotoSymbolQuickAccess.js';
|
|
72
|
-
import '../../editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess.js';
|
|
73
|
-
import '../../editor/standalone/browser/referenceSearch/standaloneReferenceSearch.js';
|
|
74
|
-
import '../../editor/standalone/browser/toggleHighContrast/toggleHighContrast.js';
|
|
75
|
-
import { Uri, editor, MarkerTag, MarkerSeverity, Range, languages } from '../../editor/editor.api2.js';
|
|
76
|
-
|
|
77
|
-
function flattenDiagnosticMessageText(diag, newLine, indent = 0) {
|
|
78
|
-
if (typeof diag === "string") {
|
|
79
|
-
return diag;
|
|
80
|
-
} else if (diag === void 0) {
|
|
81
|
-
return "";
|
|
82
|
-
}
|
|
83
|
-
let result = "";
|
|
84
|
-
if (indent) {
|
|
85
|
-
result += newLine;
|
|
86
|
-
for (let i = 0; i < indent; i++) {
|
|
87
|
-
result += " ";
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
result += diag.messageText;
|
|
91
|
-
indent++;
|
|
92
|
-
if (diag.next) {
|
|
93
|
-
for (const kid of diag.next) {
|
|
94
|
-
result += flattenDiagnosticMessageText(kid, newLine, indent);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
function displayPartsToString(displayParts) {
|
|
100
|
-
if (displayParts) {
|
|
101
|
-
return displayParts.map((displayPart) => displayPart.text).join("");
|
|
102
|
-
}
|
|
103
|
-
return "";
|
|
104
|
-
}
|
|
105
|
-
class Adapter {
|
|
106
|
-
constructor(_worker) {
|
|
107
|
-
this._worker = _worker;
|
|
108
|
-
}
|
|
109
|
-
// protected _positionToOffset(model: editor.ITextModel, position: monaco.IPosition): number {
|
|
110
|
-
// return model.getOffsetAt(position);
|
|
111
|
-
// }
|
|
112
|
-
// protected _offsetToPosition(model: editor.ITextModel, offset: number): monaco.IPosition {
|
|
113
|
-
// return model.getPositionAt(offset);
|
|
114
|
-
// }
|
|
115
|
-
_textSpanToRange(model, span) {
|
|
116
|
-
let p1 = model.getPositionAt(span.start);
|
|
117
|
-
let p2 = model.getPositionAt(span.start + span.length);
|
|
118
|
-
let { lineNumber: startLineNumber, column: startColumn } = p1;
|
|
119
|
-
let { lineNumber: endLineNumber, column: endColumn } = p2;
|
|
120
|
-
return { startLineNumber, startColumn, endLineNumber, endColumn };
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
class LibFiles {
|
|
124
|
-
constructor(_worker) {
|
|
125
|
-
this._worker = _worker;
|
|
126
|
-
this._libFiles = {};
|
|
127
|
-
this._hasFetchedLibFiles = false;
|
|
128
|
-
this._fetchLibFilesPromise = null;
|
|
129
|
-
}
|
|
130
|
-
isLibFile(uri) {
|
|
131
|
-
if (!uri) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (uri.path.indexOf("/lib.") === 0) {
|
|
135
|
-
return !!libFileSet[uri.path.slice(1)];
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
getOrCreateModel(fileName) {
|
|
140
|
-
const uri = Uri.parse(fileName);
|
|
141
|
-
const model = editor.getModel(uri);
|
|
142
|
-
if (model) {
|
|
143
|
-
return model;
|
|
144
|
-
}
|
|
145
|
-
if (this.isLibFile(uri) && this._hasFetchedLibFiles) {
|
|
146
|
-
return editor.createModel(this._libFiles[uri.path.slice(1)], "typescript", uri);
|
|
147
|
-
}
|
|
148
|
-
const matchedLibFile = typescriptDefaults.getExtraLibs()[fileName];
|
|
149
|
-
if (matchedLibFile) {
|
|
150
|
-
return editor.createModel(matchedLibFile.content, "typescript", uri);
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
_containsLibFile(uris) {
|
|
155
|
-
for (let uri of uris) {
|
|
156
|
-
if (this.isLibFile(uri)) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
async fetchLibFilesIfNecessary(uris) {
|
|
163
|
-
if (!this._containsLibFile(uris)) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
await this._fetchLibFiles();
|
|
167
|
-
}
|
|
168
|
-
_fetchLibFiles() {
|
|
169
|
-
if (!this._fetchLibFilesPromise) {
|
|
170
|
-
this._fetchLibFilesPromise = this._worker().then((w) => w.getLibFiles()).then((libFiles) => {
|
|
171
|
-
this._hasFetchedLibFiles = true;
|
|
172
|
-
this._libFiles = libFiles;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return this._fetchLibFilesPromise;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
class DiagnosticsAdapter extends Adapter {
|
|
179
|
-
constructor(_libFiles, _defaults, _selector, worker) {
|
|
180
|
-
super(worker);
|
|
181
|
-
this._libFiles = _libFiles;
|
|
182
|
-
this._defaults = _defaults;
|
|
183
|
-
this._selector = _selector;
|
|
184
|
-
this._disposables = [];
|
|
185
|
-
this._listener = /* @__PURE__ */ Object.create(null);
|
|
186
|
-
const onModelAdd = (model) => {
|
|
187
|
-
if (model.getLanguageId() !== _selector) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const maybeValidate = () => {
|
|
191
|
-
const { onlyVisible } = this._defaults.getDiagnosticsOptions();
|
|
192
|
-
if (onlyVisible) {
|
|
193
|
-
if (model.isAttachedToEditor()) {
|
|
194
|
-
this._doValidate(model);
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
this._doValidate(model);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
let handle;
|
|
201
|
-
const changeSubscription = model.onDidChangeContent(() => {
|
|
202
|
-
clearTimeout(handle);
|
|
203
|
-
handle = window.setTimeout(maybeValidate, 500);
|
|
204
|
-
});
|
|
205
|
-
const visibleSubscription = model.onDidChangeAttached(() => {
|
|
206
|
-
const { onlyVisible } = this._defaults.getDiagnosticsOptions();
|
|
207
|
-
if (onlyVisible) {
|
|
208
|
-
if (model.isAttachedToEditor()) {
|
|
209
|
-
maybeValidate();
|
|
210
|
-
} else {
|
|
211
|
-
editor.setModelMarkers(model, this._selector, []);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
this._listener[model.uri.toString()] = {
|
|
216
|
-
dispose() {
|
|
217
|
-
changeSubscription.dispose();
|
|
218
|
-
visibleSubscription.dispose();
|
|
219
|
-
clearTimeout(handle);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
maybeValidate();
|
|
223
|
-
};
|
|
224
|
-
const onModelRemoved = (model) => {
|
|
225
|
-
editor.setModelMarkers(model, this._selector, []);
|
|
226
|
-
const key = model.uri.toString();
|
|
227
|
-
if (this._listener[key]) {
|
|
228
|
-
this._listener[key].dispose();
|
|
229
|
-
delete this._listener[key];
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
this._disposables.push(
|
|
233
|
-
editor.onDidCreateModel((model) => onModelAdd(model))
|
|
234
|
-
);
|
|
235
|
-
this._disposables.push(editor.onWillDisposeModel(onModelRemoved));
|
|
236
|
-
this._disposables.push(
|
|
237
|
-
editor.onDidChangeModelLanguage((event) => {
|
|
238
|
-
onModelRemoved(event.model);
|
|
239
|
-
onModelAdd(event.model);
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
this._disposables.push({
|
|
243
|
-
dispose() {
|
|
244
|
-
for (const model of editor.getModels()) {
|
|
245
|
-
onModelRemoved(model);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
const recomputeDiagostics = () => {
|
|
250
|
-
for (const model of editor.getModels()) {
|
|
251
|
-
onModelRemoved(model);
|
|
252
|
-
onModelAdd(model);
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
this._disposables.push(this._defaults.onDidChange(recomputeDiagostics));
|
|
256
|
-
this._disposables.push(this._defaults.onDidExtraLibsChange(recomputeDiagostics));
|
|
257
|
-
editor.getModels().forEach((model) => onModelAdd(model));
|
|
258
|
-
}
|
|
259
|
-
dispose() {
|
|
260
|
-
this._disposables.forEach((d) => d && d.dispose());
|
|
261
|
-
this._disposables = [];
|
|
262
|
-
}
|
|
263
|
-
async _doValidate(model) {
|
|
264
|
-
const worker = await this._worker(model.uri);
|
|
265
|
-
if (model.isDisposed()) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
const promises = [];
|
|
269
|
-
const { noSyntaxValidation, noSemanticValidation, noSuggestionDiagnostics } = this._defaults.getDiagnosticsOptions();
|
|
270
|
-
if (!noSyntaxValidation) {
|
|
271
|
-
promises.push(worker.getSyntacticDiagnostics(model.uri.toString()));
|
|
272
|
-
}
|
|
273
|
-
if (!noSemanticValidation) {
|
|
274
|
-
promises.push(worker.getSemanticDiagnostics(model.uri.toString()));
|
|
275
|
-
}
|
|
276
|
-
if (!noSuggestionDiagnostics) {
|
|
277
|
-
promises.push(worker.getSuggestionDiagnostics(model.uri.toString()));
|
|
278
|
-
}
|
|
279
|
-
const allDiagnostics = await Promise.all(promises);
|
|
280
|
-
if (!allDiagnostics || model.isDisposed()) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const diagnostics = allDiagnostics.reduce((p, c) => c.concat(p), []).filter(
|
|
284
|
-
(d) => (this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore || []).indexOf(d.code) === -1
|
|
285
|
-
);
|
|
286
|
-
const relatedUris = diagnostics.map((d) => d.relatedInformation || []).reduce((p, c) => c.concat(p), []).map(
|
|
287
|
-
(relatedInformation) => relatedInformation.file ? Uri.parse(relatedInformation.file.fileName) : null
|
|
288
|
-
);
|
|
289
|
-
await this._libFiles.fetchLibFilesIfNecessary(relatedUris);
|
|
290
|
-
if (model.isDisposed()) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
editor.setModelMarkers(
|
|
294
|
-
model,
|
|
295
|
-
this._selector,
|
|
296
|
-
diagnostics.map((d) => this._convertDiagnostics(model, d))
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
_convertDiagnostics(model, diag) {
|
|
300
|
-
const diagStart = diag.start || 0;
|
|
301
|
-
const diagLength = diag.length || 1;
|
|
302
|
-
const { lineNumber: startLineNumber, column: startColumn } = model.getPositionAt(diagStart);
|
|
303
|
-
const { lineNumber: endLineNumber, column: endColumn } = model.getPositionAt(
|
|
304
|
-
diagStart + diagLength
|
|
305
|
-
);
|
|
306
|
-
const tags = [];
|
|
307
|
-
if (diag.reportsUnnecessary) {
|
|
308
|
-
tags.push(MarkerTag.Unnecessary);
|
|
309
|
-
}
|
|
310
|
-
if (diag.reportsDeprecated) {
|
|
311
|
-
tags.push(MarkerTag.Deprecated);
|
|
312
|
-
}
|
|
313
|
-
return {
|
|
314
|
-
severity: this._tsDiagnosticCategoryToMarkerSeverity(diag.category),
|
|
315
|
-
startLineNumber,
|
|
316
|
-
startColumn,
|
|
317
|
-
endLineNumber,
|
|
318
|
-
endColumn,
|
|
319
|
-
message: flattenDiagnosticMessageText(diag.messageText, "\n"),
|
|
320
|
-
code: diag.code.toString(),
|
|
321
|
-
tags,
|
|
322
|
-
relatedInformation: this._convertRelatedInformation(model, diag.relatedInformation)
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
_convertRelatedInformation(model, relatedInformation) {
|
|
326
|
-
if (!relatedInformation) {
|
|
327
|
-
return [];
|
|
328
|
-
}
|
|
329
|
-
const result = [];
|
|
330
|
-
relatedInformation.forEach((info) => {
|
|
331
|
-
let relatedResource = model;
|
|
332
|
-
if (info.file) {
|
|
333
|
-
relatedResource = this._libFiles.getOrCreateModel(info.file.fileName);
|
|
334
|
-
}
|
|
335
|
-
if (!relatedResource) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const infoStart = info.start || 0;
|
|
339
|
-
const infoLength = info.length || 1;
|
|
340
|
-
const { lineNumber: startLineNumber, column: startColumn } = relatedResource.getPositionAt(infoStart);
|
|
341
|
-
const { lineNumber: endLineNumber, column: endColumn } = relatedResource.getPositionAt(
|
|
342
|
-
infoStart + infoLength
|
|
343
|
-
);
|
|
344
|
-
result.push({
|
|
345
|
-
resource: relatedResource.uri,
|
|
346
|
-
startLineNumber,
|
|
347
|
-
startColumn,
|
|
348
|
-
endLineNumber,
|
|
349
|
-
endColumn,
|
|
350
|
-
message: flattenDiagnosticMessageText(info.messageText, "\n")
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
return result;
|
|
354
|
-
}
|
|
355
|
-
_tsDiagnosticCategoryToMarkerSeverity(category) {
|
|
356
|
-
switch (category) {
|
|
357
|
-
case 1 /* Error */:
|
|
358
|
-
return MarkerSeverity.Error;
|
|
359
|
-
case 3 /* Message */:
|
|
360
|
-
return MarkerSeverity.Info;
|
|
361
|
-
case 0 /* Warning */:
|
|
362
|
-
return MarkerSeverity.Warning;
|
|
363
|
-
case 2 /* Suggestion */:
|
|
364
|
-
return MarkerSeverity.Hint;
|
|
365
|
-
}
|
|
366
|
-
return MarkerSeverity.Info;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
class SuggestAdapter extends Adapter {
|
|
370
|
-
get triggerCharacters() {
|
|
371
|
-
return ["."];
|
|
372
|
-
}
|
|
373
|
-
async provideCompletionItems(model, position, _context, token) {
|
|
374
|
-
const wordInfo = model.getWordUntilPosition(position);
|
|
375
|
-
const wordRange = new Range(
|
|
376
|
-
position.lineNumber,
|
|
377
|
-
wordInfo.startColumn,
|
|
378
|
-
position.lineNumber,
|
|
379
|
-
wordInfo.endColumn
|
|
380
|
-
);
|
|
381
|
-
const resource = model.uri;
|
|
382
|
-
const offset = model.getOffsetAt(position);
|
|
383
|
-
const worker = await this._worker(resource);
|
|
384
|
-
if (model.isDisposed()) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
const info = await worker.getCompletionsAtPosition(resource.toString(), offset);
|
|
388
|
-
if (!info || model.isDisposed()) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
const suggestions = info.entries.map((entry) => {
|
|
392
|
-
let range = wordRange;
|
|
393
|
-
if (entry.replacementSpan) {
|
|
394
|
-
const p1 = model.getPositionAt(entry.replacementSpan.start);
|
|
395
|
-
const p2 = model.getPositionAt(entry.replacementSpan.start + entry.replacementSpan.length);
|
|
396
|
-
range = new Range(p1.lineNumber, p1.column, p2.lineNumber, p2.column);
|
|
397
|
-
}
|
|
398
|
-
const tags = [];
|
|
399
|
-
if (entry.kindModifiers !== void 0 && entry.kindModifiers.indexOf("deprecated") !== -1) {
|
|
400
|
-
tags.push(languages.CompletionItemTag.Deprecated);
|
|
401
|
-
}
|
|
402
|
-
return {
|
|
403
|
-
uri: resource,
|
|
404
|
-
position,
|
|
405
|
-
offset,
|
|
406
|
-
range,
|
|
407
|
-
label: entry.name,
|
|
408
|
-
insertText: entry.name,
|
|
409
|
-
sortText: entry.sortText,
|
|
410
|
-
kind: SuggestAdapter.convertKind(entry.kind),
|
|
411
|
-
tags
|
|
412
|
-
};
|
|
413
|
-
});
|
|
414
|
-
return {
|
|
415
|
-
suggestions
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
async resolveCompletionItem(item, token) {
|
|
419
|
-
const myItem = item;
|
|
420
|
-
const resource = myItem.uri;
|
|
421
|
-
const position = myItem.position;
|
|
422
|
-
const offset = myItem.offset;
|
|
423
|
-
const worker = await this._worker(resource);
|
|
424
|
-
const details = await worker.getCompletionEntryDetails(
|
|
425
|
-
resource.toString(),
|
|
426
|
-
offset,
|
|
427
|
-
myItem.label
|
|
428
|
-
);
|
|
429
|
-
if (!details) {
|
|
430
|
-
return myItem;
|
|
431
|
-
}
|
|
432
|
-
return {
|
|
433
|
-
uri: resource,
|
|
434
|
-
position,
|
|
435
|
-
label: details.name,
|
|
436
|
-
kind: SuggestAdapter.convertKind(details.kind),
|
|
437
|
-
detail: displayPartsToString(details.displayParts),
|
|
438
|
-
documentation: {
|
|
439
|
-
value: SuggestAdapter.createDocumentationString(details)
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
static convertKind(kind) {
|
|
444
|
-
switch (kind) {
|
|
445
|
-
case Kind.primitiveType:
|
|
446
|
-
case Kind.keyword:
|
|
447
|
-
return languages.CompletionItemKind.Keyword;
|
|
448
|
-
case Kind.variable:
|
|
449
|
-
case Kind.localVariable:
|
|
450
|
-
return languages.CompletionItemKind.Variable;
|
|
451
|
-
case Kind.memberVariable:
|
|
452
|
-
case Kind.memberGetAccessor:
|
|
453
|
-
case Kind.memberSetAccessor:
|
|
454
|
-
return languages.CompletionItemKind.Field;
|
|
455
|
-
case Kind.function:
|
|
456
|
-
case Kind.memberFunction:
|
|
457
|
-
case Kind.constructSignature:
|
|
458
|
-
case Kind.callSignature:
|
|
459
|
-
case Kind.indexSignature:
|
|
460
|
-
return languages.CompletionItemKind.Function;
|
|
461
|
-
case Kind.enum:
|
|
462
|
-
return languages.CompletionItemKind.Enum;
|
|
463
|
-
case Kind.module:
|
|
464
|
-
return languages.CompletionItemKind.Module;
|
|
465
|
-
case Kind.class:
|
|
466
|
-
return languages.CompletionItemKind.Class;
|
|
467
|
-
case Kind.interface:
|
|
468
|
-
return languages.CompletionItemKind.Interface;
|
|
469
|
-
case Kind.warning:
|
|
470
|
-
return languages.CompletionItemKind.File;
|
|
471
|
-
}
|
|
472
|
-
return languages.CompletionItemKind.Property;
|
|
473
|
-
}
|
|
474
|
-
static createDocumentationString(details) {
|
|
475
|
-
let documentationString = displayPartsToString(details.documentation);
|
|
476
|
-
if (details.tags) {
|
|
477
|
-
for (const tag of details.tags) {
|
|
478
|
-
documentationString += `
|
|
479
|
-
|
|
480
|
-
${tagToString(tag)}`;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return documentationString;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
function tagToString(tag) {
|
|
487
|
-
let tagLabel = `*@${tag.name}*`;
|
|
488
|
-
if (tag.name === "param" && tag.text) {
|
|
489
|
-
const [paramName, ...rest] = tag.text;
|
|
490
|
-
tagLabel += `\`${paramName.text}\``;
|
|
491
|
-
if (rest.length > 0) tagLabel += ` \u2014 ${rest.map((r) => r.text).join(" ")}`;
|
|
492
|
-
} else if (Array.isArray(tag.text)) {
|
|
493
|
-
tagLabel += ` \u2014 ${tag.text.map((r) => r.text).join(" ")}`;
|
|
494
|
-
} else if (tag.text) {
|
|
495
|
-
tagLabel += ` \u2014 ${tag.text}`;
|
|
496
|
-
}
|
|
497
|
-
return tagLabel;
|
|
498
|
-
}
|
|
499
|
-
class SignatureHelpAdapter extends Adapter {
|
|
500
|
-
constructor() {
|
|
501
|
-
super(...arguments);
|
|
502
|
-
this.signatureHelpTriggerCharacters = ["(", ","];
|
|
503
|
-
}
|
|
504
|
-
static _toSignatureHelpTriggerReason(context) {
|
|
505
|
-
switch (context.triggerKind) {
|
|
506
|
-
case languages.SignatureHelpTriggerKind.TriggerCharacter:
|
|
507
|
-
if (context.triggerCharacter) {
|
|
508
|
-
if (context.isRetrigger) {
|
|
509
|
-
return { kind: "retrigger", triggerCharacter: context.triggerCharacter };
|
|
510
|
-
} else {
|
|
511
|
-
return { kind: "characterTyped", triggerCharacter: context.triggerCharacter };
|
|
512
|
-
}
|
|
513
|
-
} else {
|
|
514
|
-
return { kind: "invoked" };
|
|
515
|
-
}
|
|
516
|
-
case languages.SignatureHelpTriggerKind.ContentChange:
|
|
517
|
-
return context.isRetrigger ? { kind: "retrigger" } : { kind: "invoked" };
|
|
518
|
-
case languages.SignatureHelpTriggerKind.Invoke:
|
|
519
|
-
default:
|
|
520
|
-
return { kind: "invoked" };
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
async provideSignatureHelp(model, position, token, context) {
|
|
524
|
-
const resource = model.uri;
|
|
525
|
-
const offset = model.getOffsetAt(position);
|
|
526
|
-
const worker = await this._worker(resource);
|
|
527
|
-
if (model.isDisposed()) {
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
const info = await worker.getSignatureHelpItems(resource.toString(), offset, {
|
|
531
|
-
triggerReason: SignatureHelpAdapter._toSignatureHelpTriggerReason(context)
|
|
532
|
-
});
|
|
533
|
-
if (!info || model.isDisposed()) {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
const ret = {
|
|
537
|
-
activeSignature: info.selectedItemIndex,
|
|
538
|
-
activeParameter: info.argumentIndex,
|
|
539
|
-
signatures: []
|
|
540
|
-
};
|
|
541
|
-
info.items.forEach((item) => {
|
|
542
|
-
const signature = {
|
|
543
|
-
label: "",
|
|
544
|
-
parameters: []
|
|
545
|
-
};
|
|
546
|
-
signature.documentation = {
|
|
547
|
-
value: displayPartsToString(item.documentation)
|
|
548
|
-
};
|
|
549
|
-
signature.label += displayPartsToString(item.prefixDisplayParts);
|
|
550
|
-
item.parameters.forEach((p, i, a) => {
|
|
551
|
-
const label = displayPartsToString(p.displayParts);
|
|
552
|
-
const parameter = {
|
|
553
|
-
label,
|
|
554
|
-
documentation: {
|
|
555
|
-
value: displayPartsToString(p.documentation)
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
signature.label += label;
|
|
559
|
-
signature.parameters.push(parameter);
|
|
560
|
-
if (i < a.length - 1) {
|
|
561
|
-
signature.label += displayPartsToString(item.separatorDisplayParts);
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
signature.label += displayPartsToString(item.suffixDisplayParts);
|
|
565
|
-
ret.signatures.push(signature);
|
|
566
|
-
});
|
|
567
|
-
return {
|
|
568
|
-
value: ret,
|
|
569
|
-
dispose() {
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
class QuickInfoAdapter extends Adapter {
|
|
575
|
-
async provideHover(model, position, token) {
|
|
576
|
-
const resource = model.uri;
|
|
577
|
-
const offset = model.getOffsetAt(position);
|
|
578
|
-
const worker = await this._worker(resource);
|
|
579
|
-
if (model.isDisposed()) {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
const info = await worker.getQuickInfoAtPosition(resource.toString(), offset);
|
|
583
|
-
if (!info || model.isDisposed()) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
const documentation = displayPartsToString(info.documentation);
|
|
587
|
-
const tags = info.tags ? info.tags.map((tag) => tagToString(tag)).join(" \n\n") : "";
|
|
588
|
-
const contents = displayPartsToString(info.displayParts);
|
|
589
|
-
return {
|
|
590
|
-
range: this._textSpanToRange(model, info.textSpan),
|
|
591
|
-
contents: [
|
|
592
|
-
{
|
|
593
|
-
value: "```typescript\n" + contents + "\n```\n"
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
value: documentation + (tags ? "\n\n" + tags : "")
|
|
597
|
-
}
|
|
598
|
-
]
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
class DocumentHighlightAdapter extends Adapter {
|
|
603
|
-
async provideDocumentHighlights(model, position, token) {
|
|
604
|
-
const resource = model.uri;
|
|
605
|
-
const offset = model.getOffsetAt(position);
|
|
606
|
-
const worker = await this._worker(resource);
|
|
607
|
-
if (model.isDisposed()) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
const entries = await worker.getDocumentHighlights(resource.toString(), offset, [
|
|
611
|
-
resource.toString()
|
|
612
|
-
]);
|
|
613
|
-
if (!entries || model.isDisposed()) {
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
return entries.flatMap((entry) => {
|
|
617
|
-
return entry.highlightSpans.map((highlightSpans) => {
|
|
618
|
-
return {
|
|
619
|
-
range: this._textSpanToRange(model, highlightSpans.textSpan),
|
|
620
|
-
kind: highlightSpans.kind === "writtenReference" ? languages.DocumentHighlightKind.Write : languages.DocumentHighlightKind.Text
|
|
621
|
-
};
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
class DefinitionAdapter extends Adapter {
|
|
627
|
-
constructor(_libFiles, worker) {
|
|
628
|
-
super(worker);
|
|
629
|
-
this._libFiles = _libFiles;
|
|
630
|
-
}
|
|
631
|
-
async provideDefinition(model, position, token) {
|
|
632
|
-
const resource = model.uri;
|
|
633
|
-
const offset = model.getOffsetAt(position);
|
|
634
|
-
const worker = await this._worker(resource);
|
|
635
|
-
if (model.isDisposed()) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
const entries = await worker.getDefinitionAtPosition(resource.toString(), offset);
|
|
639
|
-
if (!entries || model.isDisposed()) {
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
await this._libFiles.fetchLibFilesIfNecessary(
|
|
643
|
-
entries.map((entry) => Uri.parse(entry.fileName))
|
|
644
|
-
);
|
|
645
|
-
if (model.isDisposed()) {
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
const result = [];
|
|
649
|
-
for (let entry of entries) {
|
|
650
|
-
const refModel = this._libFiles.getOrCreateModel(entry.fileName);
|
|
651
|
-
if (refModel) {
|
|
652
|
-
result.push({
|
|
653
|
-
uri: refModel.uri,
|
|
654
|
-
range: this._textSpanToRange(refModel, entry.textSpan)
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return result;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
class ReferenceAdapter extends Adapter {
|
|
662
|
-
constructor(_libFiles, worker) {
|
|
663
|
-
super(worker);
|
|
664
|
-
this._libFiles = _libFiles;
|
|
665
|
-
}
|
|
666
|
-
async provideReferences(model, position, context, token) {
|
|
667
|
-
const resource = model.uri;
|
|
668
|
-
const offset = model.getOffsetAt(position);
|
|
669
|
-
const worker = await this._worker(resource);
|
|
670
|
-
if (model.isDisposed()) {
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
const entries = await worker.getReferencesAtPosition(resource.toString(), offset);
|
|
674
|
-
if (!entries || model.isDisposed()) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
await this._libFiles.fetchLibFilesIfNecessary(
|
|
678
|
-
entries.map((entry) => Uri.parse(entry.fileName))
|
|
679
|
-
);
|
|
680
|
-
if (model.isDisposed()) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
const result = [];
|
|
684
|
-
for (let entry of entries) {
|
|
685
|
-
const refModel = this._libFiles.getOrCreateModel(entry.fileName);
|
|
686
|
-
if (refModel) {
|
|
687
|
-
result.push({
|
|
688
|
-
uri: refModel.uri,
|
|
689
|
-
range: this._textSpanToRange(refModel, entry.textSpan)
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
return result;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
class OutlineAdapter extends Adapter {
|
|
697
|
-
async provideDocumentSymbols(model, token) {
|
|
698
|
-
const resource = model.uri;
|
|
699
|
-
const worker = await this._worker(resource);
|
|
700
|
-
if (model.isDisposed()) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
const root = await worker.getNavigationTree(resource.toString());
|
|
704
|
-
if (!root || model.isDisposed()) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
const convert = (item, containerLabel) => {
|
|
708
|
-
const result2 = {
|
|
709
|
-
name: item.text,
|
|
710
|
-
detail: "",
|
|
711
|
-
kind: outlineTypeTable[item.kind] || languages.SymbolKind.Variable,
|
|
712
|
-
range: this._textSpanToRange(model, item.spans[0]),
|
|
713
|
-
selectionRange: this._textSpanToRange(model, item.spans[0]),
|
|
714
|
-
tags: [],
|
|
715
|
-
children: item.childItems?.map((child) => convert(child, item.text)),
|
|
716
|
-
containerName: containerLabel
|
|
717
|
-
};
|
|
718
|
-
return result2;
|
|
719
|
-
};
|
|
720
|
-
const result = root.childItems ? root.childItems.map((item) => convert(item)) : [];
|
|
721
|
-
return result;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
class Kind {
|
|
725
|
-
}
|
|
726
|
-
Kind.unknown = "";
|
|
727
|
-
Kind.keyword = "keyword";
|
|
728
|
-
Kind.script = "script";
|
|
729
|
-
Kind.module = "module";
|
|
730
|
-
Kind.class = "class";
|
|
731
|
-
Kind.interface = "interface";
|
|
732
|
-
Kind.type = "type";
|
|
733
|
-
Kind.enum = "enum";
|
|
734
|
-
Kind.variable = "var";
|
|
735
|
-
Kind.localVariable = "local var";
|
|
736
|
-
Kind.function = "function";
|
|
737
|
-
Kind.localFunction = "local function";
|
|
738
|
-
Kind.memberFunction = "method";
|
|
739
|
-
Kind.memberGetAccessor = "getter";
|
|
740
|
-
Kind.memberSetAccessor = "setter";
|
|
741
|
-
Kind.memberVariable = "property";
|
|
742
|
-
Kind.constructorImplementation = "constructor";
|
|
743
|
-
Kind.callSignature = "call";
|
|
744
|
-
Kind.indexSignature = "index";
|
|
745
|
-
Kind.constructSignature = "construct";
|
|
746
|
-
Kind.parameter = "parameter";
|
|
747
|
-
Kind.typeParameter = "type parameter";
|
|
748
|
-
Kind.primitiveType = "primitive type";
|
|
749
|
-
Kind.label = "label";
|
|
750
|
-
Kind.alias = "alias";
|
|
751
|
-
Kind.const = "const";
|
|
752
|
-
Kind.let = "let";
|
|
753
|
-
Kind.warning = "warning";
|
|
754
|
-
let outlineTypeTable = /* @__PURE__ */ Object.create(null);
|
|
755
|
-
outlineTypeTable[Kind.module] = languages.SymbolKind.Module;
|
|
756
|
-
outlineTypeTable[Kind.class] = languages.SymbolKind.Class;
|
|
757
|
-
outlineTypeTable[Kind.enum] = languages.SymbolKind.Enum;
|
|
758
|
-
outlineTypeTable[Kind.interface] = languages.SymbolKind.Interface;
|
|
759
|
-
outlineTypeTable[Kind.memberFunction] = languages.SymbolKind.Method;
|
|
760
|
-
outlineTypeTable[Kind.memberVariable] = languages.SymbolKind.Property;
|
|
761
|
-
outlineTypeTable[Kind.memberGetAccessor] = languages.SymbolKind.Property;
|
|
762
|
-
outlineTypeTable[Kind.memberSetAccessor] = languages.SymbolKind.Property;
|
|
763
|
-
outlineTypeTable[Kind.variable] = languages.SymbolKind.Variable;
|
|
764
|
-
outlineTypeTable[Kind.const] = languages.SymbolKind.Variable;
|
|
765
|
-
outlineTypeTable[Kind.localVariable] = languages.SymbolKind.Variable;
|
|
766
|
-
outlineTypeTable[Kind.variable] = languages.SymbolKind.Variable;
|
|
767
|
-
outlineTypeTable[Kind.function] = languages.SymbolKind.Function;
|
|
768
|
-
outlineTypeTable[Kind.localFunction] = languages.SymbolKind.Function;
|
|
769
|
-
class FormatHelper extends Adapter {
|
|
770
|
-
static _convertOptions(options) {
|
|
771
|
-
return {
|
|
772
|
-
ConvertTabsToSpaces: options.insertSpaces,
|
|
773
|
-
TabSize: options.tabSize,
|
|
774
|
-
IndentSize: options.tabSize,
|
|
775
|
-
IndentStyle: 2 /* Smart */,
|
|
776
|
-
NewLineCharacter: "\n",
|
|
777
|
-
InsertSpaceAfterCommaDelimiter: true,
|
|
778
|
-
InsertSpaceAfterSemicolonInForStatements: true,
|
|
779
|
-
InsertSpaceBeforeAndAfterBinaryOperators: true,
|
|
780
|
-
InsertSpaceAfterKeywordsInControlFlowStatements: true,
|
|
781
|
-
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: true,
|
|
782
|
-
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
|
783
|
-
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
|
784
|
-
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
|
785
|
-
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
|
786
|
-
PlaceOpenBraceOnNewLineForFunctions: false
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
_convertTextChanges(model, change) {
|
|
790
|
-
return {
|
|
791
|
-
text: change.newText,
|
|
792
|
-
range: this._textSpanToRange(model, change.span)
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
class FormatAdapter extends FormatHelper {
|
|
797
|
-
constructor() {
|
|
798
|
-
super(...arguments);
|
|
799
|
-
this.canFormatMultipleRanges = false;
|
|
800
|
-
}
|
|
801
|
-
async provideDocumentRangeFormattingEdits(model, range, options, token) {
|
|
802
|
-
const resource = model.uri;
|
|
803
|
-
const startOffset = model.getOffsetAt({
|
|
804
|
-
lineNumber: range.startLineNumber,
|
|
805
|
-
column: range.startColumn
|
|
806
|
-
});
|
|
807
|
-
const endOffset = model.getOffsetAt({
|
|
808
|
-
lineNumber: range.endLineNumber,
|
|
809
|
-
column: range.endColumn
|
|
810
|
-
});
|
|
811
|
-
const worker = await this._worker(resource);
|
|
812
|
-
if (model.isDisposed()) {
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
const edits = await worker.getFormattingEditsForRange(
|
|
816
|
-
resource.toString(),
|
|
817
|
-
startOffset,
|
|
818
|
-
endOffset,
|
|
819
|
-
FormatHelper._convertOptions(options)
|
|
820
|
-
);
|
|
821
|
-
if (!edits || model.isDisposed()) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
return edits.map((edit) => this._convertTextChanges(model, edit));
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
class FormatOnTypeAdapter extends FormatHelper {
|
|
828
|
-
get autoFormatTriggerCharacters() {
|
|
829
|
-
return [";", "}", "\n"];
|
|
830
|
-
}
|
|
831
|
-
async provideOnTypeFormattingEdits(model, position, ch, options, token) {
|
|
832
|
-
const resource = model.uri;
|
|
833
|
-
const offset = model.getOffsetAt(position);
|
|
834
|
-
const worker = await this._worker(resource);
|
|
835
|
-
if (model.isDisposed()) {
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
const edits = await worker.getFormattingEditsAfterKeystroke(
|
|
839
|
-
resource.toString(),
|
|
840
|
-
offset,
|
|
841
|
-
ch,
|
|
842
|
-
FormatHelper._convertOptions(options)
|
|
843
|
-
);
|
|
844
|
-
if (!edits || model.isDisposed()) {
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
return edits.map((edit) => this._convertTextChanges(model, edit));
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
class CodeActionAdaptor extends FormatHelper {
|
|
851
|
-
async provideCodeActions(model, range, context, token) {
|
|
852
|
-
const resource = model.uri;
|
|
853
|
-
const start = model.getOffsetAt({
|
|
854
|
-
lineNumber: range.startLineNumber,
|
|
855
|
-
column: range.startColumn
|
|
856
|
-
});
|
|
857
|
-
const end = model.getOffsetAt({
|
|
858
|
-
lineNumber: range.endLineNumber,
|
|
859
|
-
column: range.endColumn
|
|
860
|
-
});
|
|
861
|
-
const formatOptions = FormatHelper._convertOptions(model.getOptions());
|
|
862
|
-
const errorCodes = context.markers.filter((m) => m.code).map((m) => m.code).map(Number);
|
|
863
|
-
const worker = await this._worker(resource);
|
|
864
|
-
if (model.isDisposed()) {
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
const codeFixes = await worker.getCodeFixesAtPosition(
|
|
868
|
-
resource.toString(),
|
|
869
|
-
start,
|
|
870
|
-
end,
|
|
871
|
-
errorCodes,
|
|
872
|
-
formatOptions
|
|
873
|
-
);
|
|
874
|
-
if (!codeFixes || model.isDisposed()) {
|
|
875
|
-
return { actions: [], dispose: () => {
|
|
876
|
-
} };
|
|
877
|
-
}
|
|
878
|
-
const actions = codeFixes.filter((fix) => {
|
|
879
|
-
return fix.changes.filter((change) => change.isNewFile).length === 0;
|
|
880
|
-
}).map((fix) => {
|
|
881
|
-
return this._tsCodeFixActionToMonacoCodeAction(model, context, fix);
|
|
882
|
-
});
|
|
883
|
-
return {
|
|
884
|
-
actions,
|
|
885
|
-
dispose: () => {
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
}
|
|
889
|
-
_tsCodeFixActionToMonacoCodeAction(model, context, codeFix) {
|
|
890
|
-
const edits = [];
|
|
891
|
-
for (const change of codeFix.changes) {
|
|
892
|
-
for (const textChange of change.textChanges) {
|
|
893
|
-
edits.push({
|
|
894
|
-
resource: model.uri,
|
|
895
|
-
versionId: void 0,
|
|
896
|
-
textEdit: {
|
|
897
|
-
range: this._textSpanToRange(model, textChange.span),
|
|
898
|
-
text: textChange.newText
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
const action = {
|
|
904
|
-
title: codeFix.description,
|
|
905
|
-
edit: { edits },
|
|
906
|
-
diagnostics: context.markers,
|
|
907
|
-
kind: "quickfix"
|
|
908
|
-
};
|
|
909
|
-
return action;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
class RenameAdapter extends Adapter {
|
|
913
|
-
constructor(_libFiles, worker) {
|
|
914
|
-
super(worker);
|
|
915
|
-
this._libFiles = _libFiles;
|
|
916
|
-
}
|
|
917
|
-
async provideRenameEdits(model, position, newName, token) {
|
|
918
|
-
const resource = model.uri;
|
|
919
|
-
const fileName = resource.toString();
|
|
920
|
-
const offset = model.getOffsetAt(position);
|
|
921
|
-
const worker = await this._worker(resource);
|
|
922
|
-
if (model.isDisposed()) {
|
|
923
|
-
return;
|
|
924
|
-
}
|
|
925
|
-
const renameInfo = await worker.getRenameInfo(fileName, offset, {
|
|
926
|
-
allowRenameOfImportPath: false
|
|
927
|
-
});
|
|
928
|
-
if (renameInfo.canRename === false) {
|
|
929
|
-
return {
|
|
930
|
-
edits: [],
|
|
931
|
-
rejectReason: renameInfo.localizedErrorMessage
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
if (renameInfo.fileToRename !== void 0) {
|
|
935
|
-
throw new Error("Renaming files is not supported.");
|
|
936
|
-
}
|
|
937
|
-
const renameLocations = await worker.findRenameLocations(
|
|
938
|
-
fileName,
|
|
939
|
-
offset,
|
|
940
|
-
/*strings*/
|
|
941
|
-
false,
|
|
942
|
-
/*comments*/
|
|
943
|
-
false,
|
|
944
|
-
/*prefixAndSuffix*/
|
|
945
|
-
false
|
|
946
|
-
);
|
|
947
|
-
if (!renameLocations || model.isDisposed()) {
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
const edits = [];
|
|
951
|
-
for (const renameLocation of renameLocations) {
|
|
952
|
-
const model2 = this._libFiles.getOrCreateModel(renameLocation.fileName);
|
|
953
|
-
if (model2) {
|
|
954
|
-
edits.push({
|
|
955
|
-
resource: model2.uri,
|
|
956
|
-
versionId: void 0,
|
|
957
|
-
textEdit: {
|
|
958
|
-
range: this._textSpanToRange(model2, renameLocation.textSpan),
|
|
959
|
-
text: newName
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
} else {
|
|
963
|
-
throw new Error(`Unknown file ${renameLocation.fileName}.`);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return { edits };
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
class InlayHintsAdapter extends Adapter {
|
|
970
|
-
async provideInlayHints(model, range, token) {
|
|
971
|
-
const resource = model.uri;
|
|
972
|
-
const fileName = resource.toString();
|
|
973
|
-
const start = model.getOffsetAt({
|
|
974
|
-
lineNumber: range.startLineNumber,
|
|
975
|
-
column: range.startColumn
|
|
976
|
-
});
|
|
977
|
-
const end = model.getOffsetAt({
|
|
978
|
-
lineNumber: range.endLineNumber,
|
|
979
|
-
column: range.endColumn
|
|
980
|
-
});
|
|
981
|
-
const worker = await this._worker(resource);
|
|
982
|
-
if (model.isDisposed()) {
|
|
983
|
-
return null;
|
|
984
|
-
}
|
|
985
|
-
const tsHints = await worker.provideInlayHints(fileName, start, end);
|
|
986
|
-
const hints = tsHints.map((hint) => {
|
|
987
|
-
return {
|
|
988
|
-
...hint,
|
|
989
|
-
label: hint.text,
|
|
990
|
-
position: model.getPositionAt(hint.position),
|
|
991
|
-
kind: this._convertHintKind(hint.kind)
|
|
992
|
-
};
|
|
993
|
-
});
|
|
994
|
-
return { hints, dispose: () => {
|
|
995
|
-
} };
|
|
996
|
-
}
|
|
997
|
-
_convertHintKind(kind) {
|
|
998
|
-
switch (kind) {
|
|
999
|
-
case "Parameter":
|
|
1000
|
-
return languages.InlayHintKind.Parameter;
|
|
1001
|
-
case "Type":
|
|
1002
|
-
return languages.InlayHintKind.Type;
|
|
1003
|
-
default:
|
|
1004
|
-
return languages.InlayHintKind.Type;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
export { Adapter, CodeActionAdaptor, DefinitionAdapter, DiagnosticsAdapter, DocumentHighlightAdapter, FormatAdapter, FormatHelper, FormatOnTypeAdapter, InlayHintsAdapter, Kind, LibFiles, OutlineAdapter, QuickInfoAdapter, ReferenceAdapter, RenameAdapter, SignatureHelpAdapter, SuggestAdapter, flattenDiagnosticMessageText };
|