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