@vscode/chat-lib 0.0.1 → 0.0.2
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/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js +2 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +4 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +5 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts +5 -0
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +12 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +46 -19
- package/package.json +3 -6
- package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
- package/src/_internal/extension/common/constants.ts +0 -90
- package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
- package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
- package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
- package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
- package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
- package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
- package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
- package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
- package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
- package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
- package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
- package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
- package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
- package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
- package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
- package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
- package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
- package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
- package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
- package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
- package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
- package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
- package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
- package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
- package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
- package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
- package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
- package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
- package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
- package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
- package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
- package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
- package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
- package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
- package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
- package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
- package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
- package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
- package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
- package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
- package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
- package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
- package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
- package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
- package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
- package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
- package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
- package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
- package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
- package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
- package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
- package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
- package/src/_internal/platform/authentication/common/authentication.ts +0 -309
- package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
- package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
- package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
- package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
- package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
- package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
- package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
- package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
- package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
- package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
- package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
- package/src/_internal/platform/chat/common/interactionService.ts +0 -35
- package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
- package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
- package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
- package/src/_internal/platform/configuration/common/validator.ts +0 -242
- package/src/_internal/platform/diff/common/diffService.ts +0 -41
- package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
- package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
- package/src/_internal/platform/editing/common/abstractText.ts +0 -177
- package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
- package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
- package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
- package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
- package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
- package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
- package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
- package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
- package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
- package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
- package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
- package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
- package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
- package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
- package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
- package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
- package/src/_internal/platform/env/common/envService.ts +0 -134
- package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
- package/src/_internal/platform/env/common/packagejson.ts +0 -49
- package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
- package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
- package/src/_internal/platform/git/vscode/git.d.ts +0 -414
- package/src/_internal/platform/github/common/githubAPI.ts +0 -44
- package/src/_internal/platform/github/common/githubService.ts +0 -87
- package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
- package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
- package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
- package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
- package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
- package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
- package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
- package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
- package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
- package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
- package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
- package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
- package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
- package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
- package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
- package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
- package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
- package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
- package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
- package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
- package/src/_internal/platform/log/common/logService.ts +0 -232
- package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
- package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
- package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
- package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
- package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
- package/src/_internal/platform/networking/common/fetch.ts +0 -349
- package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
- package/src/_internal/platform/networking/common/networking.ts +0 -442
- package/src/_internal/platform/networking/common/openai.ts +0 -273
- package/src/_internal/platform/networking/node/chatStream.ts +0 -137
- package/src/_internal/platform/networking/node/stream.ts +0 -749
- package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
- package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
- package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
- package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
- package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
- package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
- package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
- package/src/_internal/platform/notebook/common/helpers.ts +0 -212
- package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
- package/src/_internal/platform/openai/node/fetch.ts +0 -596
- package/src/_internal/platform/parser/node/nodes.ts +0 -190
- package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
- package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
- package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
- package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
- package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
- package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
- package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
- package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
- package/src/_internal/platform/thinking/common/thinking.ts +0 -61
- package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
- package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
- package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
- package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
- package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
- package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
- package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
- package/src/_internal/util/common/anomalyDetection.ts +0 -112
- package/src/_internal/util/common/arrays.ts +0 -81
- package/src/_internal/util/common/async.ts +0 -155
- package/src/_internal/util/common/cache.ts +0 -183
- package/src/_internal/util/common/crypto.ts +0 -41
- package/src/_internal/util/common/errors.ts +0 -22
- package/src/_internal/util/common/globals.d.ts +0 -12
- package/src/_internal/util/common/imageUtils.ts +0 -154
- package/src/_internal/util/common/languages.ts +0 -940
- package/src/_internal/util/common/notebooks.ts +0 -286
- package/src/_internal/util/common/result.ts +0 -71
- package/src/_internal/util/common/services.ts +0 -43
- package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
- package/src/_internal/util/common/test/shims/editing.ts +0 -233
- package/src/_internal/util/common/test/shims/enums.ts +0 -61
- package/src/_internal/util/common/test/shims/l10n.ts +0 -37
- package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
- package/src/_internal/util/common/test/shims/terminal.ts +0 -33
- package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
- package/src/_internal/util/common/time.ts +0 -31
- package/src/_internal/util/common/tokenizer.ts +0 -30
- package/src/_internal/util/common/tracing.ts +0 -52
- package/src/_internal/util/common/types.ts +0 -33
- package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
- package/src/_internal/util/node/worker.ts +0 -130
- package/src/_internal/util/vs/base/common/arrays.ts +0 -926
- package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
- package/src/_internal/util/vs/base/common/assert.ts +0 -89
- package/src/_internal/util/vs/base/common/async.ts +0 -2582
- package/src/_internal/util/vs/base/common/buffer.ts +0 -501
- package/src/_internal/util/vs/base/common/cache.ts +0 -122
- package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
- package/src/_internal/util/vs/base/common/charCode.ts +0 -452
- package/src/_internal/util/vs/base/common/codicons.ts +0 -66
- package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
- package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
- package/src/_internal/util/vs/base/common/collections.ts +0 -156
- package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
- package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
- package/src/_internal/util/vs/base/common/equals.ts +0 -148
- package/src/_internal/util/vs/base/common/errors.ts +0 -342
- package/src/_internal/util/vs/base/common/event.ts +0 -1782
- package/src/_internal/util/vs/base/common/extpath.ts +0 -425
- package/src/_internal/util/vs/base/common/filters.ts +0 -928
- package/src/_internal/util/vs/base/common/functional.ts +0 -34
- package/src/_internal/util/vs/base/common/glob.ts +0 -839
- package/src/_internal/util/vs/base/common/hash.ts +0 -326
- package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
- package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
- package/src/_internal/util/vs/base/common/iterator.ts +0 -196
- package/src/_internal/util/vs/base/common/lazy.ts +0 -59
- package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
- package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
- package/src/_internal/util/vs/base/common/map.ts +0 -954
- package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
- package/src/_internal/util/vs/base/common/mime.ts +0 -136
- package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
- package/src/_internal/util/vs/base/common/network.ts +0 -429
- package/src/_internal/util/vs/base/common/numbers.ts +0 -166
- package/src/_internal/util/vs/base/common/objects.ts +0 -242
- package/src/_internal/util/vs/base/common/observable.ts +0 -10
- package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
- package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
- package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
- package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
- package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
- package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
- package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
- package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
- package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
- package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
- package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
- package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
- package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
- package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
- package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
- package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
- package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
- package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
- package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
- package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
- package/src/_internal/util/vs/base/common/path.ts +0 -1591
- package/src/_internal/util/vs/base/common/platform.ts +0 -282
- package/src/_internal/util/vs/base/common/process.ts +0 -78
- package/src/_internal/util/vs/base/common/resources.ts +0 -446
- package/src/_internal/util/vs/base/common/sequence.ts +0 -36
- package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
- package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
- package/src/_internal/util/vs/base/common/stream.ts +0 -792
- package/src/_internal/util/vs/base/common/strings.ts +0 -1364
- package/src/_internal/util/vs/base/common/symbols.ts +0 -11
- package/src/_internal/util/vs/base/common/themables.ts +0 -106
- package/src/_internal/util/vs/base/common/types.ts +0 -345
- package/src/_internal/util/vs/base/common/uint.ts +0 -61
- package/src/_internal/util/vs/base/common/uri.ts +0 -752
- package/src/_internal/util/vs/base/common/uuid.ts +0 -72
- package/src/_internal/util/vs/base-common.d.ts +0 -42
- package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
- package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
- package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
- package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
- package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
- package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
- package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
- package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
- package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
- package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
- package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
- package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
- package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
- package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
- package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
- package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
- package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
- package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
- package/src/_internal/util/vs/nls.messages.ts +0 -21
- package/src/_internal/util/vs/nls.ts +0 -243
- package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
- package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
- package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
- package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
- package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
- package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
- package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
- package/src/_internal/vscodeTypes.ts +0 -100
- package/src/main.ts +0 -207
- package/src/package.json +0 -4063
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
import { Lazy } from '../../../../../util/vs/base/common/lazy';
|
|
7
|
-
import { StringEdit, StringReplacement } from '../../../../../util/vs/editor/common/core/edits/stringEdit';
|
|
8
|
-
import { OffsetRange } from '../../../../../util/vs/editor/common/core/ranges/offsetRange';
|
|
9
|
-
import { TextLength } from '../../../../../util/vs/editor/common/core/text/textLength';
|
|
10
|
-
|
|
11
|
-
export abstract class StringFragment {
|
|
12
|
-
abstract get length(): number;
|
|
13
|
-
|
|
14
|
-
abstract get textLength(): TextLength;
|
|
15
|
-
|
|
16
|
-
abstract get text(): string;
|
|
17
|
-
|
|
18
|
-
toString() { return this.text; }
|
|
19
|
-
|
|
20
|
-
toEditFromOriginal(originalLength: number): StringEdit {
|
|
21
|
-
const replacements: StringReplacement[] = [];
|
|
22
|
-
let lastOriginalIdx = 0;
|
|
23
|
-
let text = '';
|
|
24
|
-
|
|
25
|
-
function emit(originalPos: number) {
|
|
26
|
-
if (lastOriginalIdx !== originalPos || text.length > 0) {
|
|
27
|
-
replacements.push(new StringReplacement(
|
|
28
|
-
new OffsetRange(lastOriginalIdx, originalPos),
|
|
29
|
-
text
|
|
30
|
-
));
|
|
31
|
-
text = '';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function process(fragment: StringFragment) {
|
|
36
|
-
if (fragment instanceof ConcatenatedStringFragment) {
|
|
37
|
-
for (const f of fragment.fragments) {
|
|
38
|
-
process(f);
|
|
39
|
-
}
|
|
40
|
-
} else if (fragment instanceof LiteralStringFragment) {
|
|
41
|
-
text += fragment.text;
|
|
42
|
-
} else if (fragment instanceof OriginalStringFragment) {
|
|
43
|
-
emit(fragment.range.start);
|
|
44
|
-
lastOriginalIdx = fragment.range.endExclusive;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
process(this);
|
|
49
|
-
emit(originalLength);
|
|
50
|
-
return new StringEdit(replacements);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class LiteralStringFragment extends StringFragment {
|
|
55
|
-
constructor(
|
|
56
|
-
public readonly text: string
|
|
57
|
-
) {
|
|
58
|
-
super();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get length(): number { return this.text.length; }
|
|
62
|
-
|
|
63
|
-
private readonly _textLength = new Lazy(() => TextLength.ofText(this.text));
|
|
64
|
-
|
|
65
|
-
get textLength() { return this._textLength.value; }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class OriginalStringFragment extends StringFragment {
|
|
69
|
-
constructor(
|
|
70
|
-
public readonly range: OffsetRange,
|
|
71
|
-
public readonly originalText: string
|
|
72
|
-
) {
|
|
73
|
-
super();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get length(): number { return this.range.length; }
|
|
77
|
-
|
|
78
|
-
get text(): string { return this.range.substring(this.originalText); }
|
|
79
|
-
|
|
80
|
-
trimStart(): OriginalStringFragment {
|
|
81
|
-
const trimmed = this.text.trimStart();
|
|
82
|
-
if (trimmed.length === this.length) { return this; }
|
|
83
|
-
return new OriginalStringFragment(new OffsetRange(this.range.endExclusive - trimmed.length, this.range.endExclusive), this.originalText);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
trimEnd(): OriginalStringFragment {
|
|
87
|
-
const trimmed = this.text.trimEnd();
|
|
88
|
-
if (trimmed.length === this.length) { return this; }
|
|
89
|
-
return new OriginalStringFragment(new OffsetRange(this.range.start, this.range.start + trimmed.length), this.originalText);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
startsWith(str: string): boolean { return this.text.startsWith(str); }
|
|
93
|
-
endsWith(str: string): boolean { return this.text.endsWith(str); }
|
|
94
|
-
|
|
95
|
-
tryJoin(other: OriginalStringFragment): OriginalStringFragment | null {
|
|
96
|
-
if (this.range.endExclusive === other.range.start) {
|
|
97
|
-
return new OriginalStringFragment(new OffsetRange(this.range.start, other.range.endExclusive), this.originalText);
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private readonly _textLength = new Lazy(() => TextLength.ofSubstr(this.originalText, this.range));
|
|
103
|
-
|
|
104
|
-
get textLength() { return this._textLength.value; }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export class ConcatenatedStringFragment extends StringFragment {
|
|
108
|
-
static from(result: StringFragment[]): StringFragment {
|
|
109
|
-
if (result.length === 0) {
|
|
110
|
-
return new LiteralStringFragment('');
|
|
111
|
-
}
|
|
112
|
-
if (result.length === 1) {
|
|
113
|
-
return result[0];
|
|
114
|
-
}
|
|
115
|
-
return new ConcatenatedStringFragment(result);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
readonly length = this.fragments.reduce((prev, cur) => prev + cur.length, 0);
|
|
119
|
-
|
|
120
|
-
constructor(
|
|
121
|
-
public readonly fragments: readonly StringFragment[]
|
|
122
|
-
) {
|
|
123
|
-
super();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get text(): string {
|
|
127
|
-
return this.fragments.map(f => f.text).join('');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private readonly _textLength = new Lazy(() => TextLength.sum(this.fragments, f => f.textLength));
|
|
131
|
-
|
|
132
|
-
get textLength() { return this._textLength.value; }
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function pushFragment(fragments: StringFragment[], fragment: StringFragment): void {
|
|
136
|
-
if (fragment.length === 0) { return; }
|
|
137
|
-
const last = fragments[fragments.length - 1];
|
|
138
|
-
if (last && last instanceof OriginalStringFragment && fragment instanceof OriginalStringFragment) {
|
|
139
|
-
const joined = last.tryJoin(fragment);
|
|
140
|
-
if (joined) {
|
|
141
|
-
fragments[fragments.length - 1] = joined;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
fragments.push(fragment);
|
|
146
|
-
}
|
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { AbstractDocument } from '../../../../../platform/editing/common/abstractText';
|
|
6
|
-
import { OverlayNode } from '../../../../../platform/parser/node/nodes';
|
|
7
|
-
import { min } from '../../../../../util/common/arrays';
|
|
8
|
-
import { compareBy, groupAdjacentBy, numberComparator, sumBy } from '../../../../../util/vs/base/common/arrays';
|
|
9
|
-
import { CachedFunction } from '../../../../../util/vs/base/common/cache';
|
|
10
|
-
import { StringEdit, StringReplacement } from '../../../../../util/vs/editor/common/core/edits/stringEdit';
|
|
11
|
-
import { Position } from '../../../../../util/vs/editor/common/core/position';
|
|
12
|
-
import { OffsetRange } from '../../../../../util/vs/editor/common/core/ranges/offsetRange';
|
|
13
|
-
import { PositionOffsetTransformer } from '../../../../../util/vs/editor/common/core/text/positionToOffset';
|
|
14
|
-
import { TextLength } from '../../../../../util/vs/editor/common/core/text/textLength';
|
|
15
|
-
import { Range } from '../../../../../util/common/test/shims/vscodeTypesShim';
|
|
16
|
-
import { IAstVisualization, subtractRange, toAstNode } from '../visualization';
|
|
17
|
-
import { ConcatenatedStringFragment, LiteralStringFragment, OriginalStringFragment, pushFragment, StringFragment } from './fragments';
|
|
18
|
-
import { ProjectedText } from './projectedText';
|
|
19
|
-
|
|
20
|
-
// Please avoid using vscode API types in this file!
|
|
21
|
-
// This makes testing and reusing much easier (e.g. for inline edits, where the original document is before the edits, which means vscode.TextDocument is not sufficient).
|
|
22
|
-
|
|
23
|
-
export interface IDocumentToSummarize<TDocument extends AbstractDocument> {
|
|
24
|
-
document: TDocument;
|
|
25
|
-
selection: Range | undefined; // TODO set this through a scoring function
|
|
26
|
-
overlayNodeRoot: OverlayNode;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ISummarizedDocumentSettings<TDocument extends AbstractDocument> {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Custom cost function. Return `false` to make sure a node is removed
|
|
33
|
-
*/
|
|
34
|
-
costFnOverride?: ((node: RemovableNode, currentCost: number, document: TDocument) => number | false) | ICostFnFactory<TDocument>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* If set to true, summarization tries to preserve type checking, e.g. by not removing important imports or removing used method signatures.
|
|
38
|
-
*/
|
|
39
|
-
tryPreserveTypeChecking?: boolean;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* If set to true, summarization always uses ellipsis for elisions, like in between sibling AST nodes.
|
|
43
|
-
*/
|
|
44
|
-
alwaysUseEllipsisForElisions?: boolean;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The style for line numbers in the summarized document.
|
|
48
|
-
*/
|
|
49
|
-
lineNumberStyle?: SummarizedDocumentLineNumberStyle;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface ICostFnFactory<TDocument extends AbstractDocument> {
|
|
53
|
-
createCostFn(doc: TDocument): (node: RemovableNode, currentCost: number) => number | false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class RemovableNode {
|
|
57
|
-
constructor(
|
|
58
|
-
public readonly parent: RemovableNode | undefined,
|
|
59
|
-
private readonly overlayNode: OverlayNode,
|
|
60
|
-
public readonly range: OffsetRange,
|
|
61
|
-
public readonly children: readonly RemovableNode[],
|
|
62
|
-
private readonly _document: AbstractDocument,
|
|
63
|
-
) { }
|
|
64
|
-
|
|
65
|
-
public get kind(): string {
|
|
66
|
-
return this.overlayNode.kind;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public get text(): string {
|
|
70
|
-
return this._document.getTextInOffsetRange(this.range);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export class ProjectedDocument<TDocument extends AbstractDocument = AbstractDocument> extends ProjectedText {
|
|
75
|
-
constructor(
|
|
76
|
-
public readonly baseDocument: TDocument,
|
|
77
|
-
edits: StringEdit,
|
|
78
|
-
) {
|
|
79
|
-
super(baseDocument.getText(), edits);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getLanguageId(this: ProjectedDocument<AbstractDocument & { languageId: string }>): string {
|
|
83
|
-
return this.baseDocument.languageId;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface IProjectedDocumentDebugInfo extends ProjectedText {
|
|
88
|
-
getVisualization?(): IAstVisualization;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function summarizeDocumentsSyncImpl<TDocument extends AbstractDocument>(
|
|
92
|
-
charLimit: number,
|
|
93
|
-
settings: ISummarizedDocumentSettings<TDocument>,
|
|
94
|
-
docs: IDocumentToSummarize<TDocument>[],
|
|
95
|
-
): ProjectedDocument<TDocument>[] {
|
|
96
|
-
|
|
97
|
-
const rootMarkedNodes: SurvivingTextNode[] = [];
|
|
98
|
-
const bestSummarizationResultsPerDocIdx: StringFragment[] = [];
|
|
99
|
-
|
|
100
|
-
const allNodesWithScores: { docIdx: number; node: SurvivingTextNode; cost: number }[] = [];
|
|
101
|
-
|
|
102
|
-
for (let i = 0; i < docs.length; i++) {
|
|
103
|
-
const { document, overlayNodeRoot, selection } = docs[i];
|
|
104
|
-
|
|
105
|
-
const text = document.getText();
|
|
106
|
-
const offsetSelection = selection ? document.rangeToOffsetRange(selection) : undefined;
|
|
107
|
-
const removableNodeRoot = createRemovableNodeFromOverlayNode(overlayNodeRoot, document);
|
|
108
|
-
const rootTextNode = TextNode.fromRootNode(removableNodeRoot, document);
|
|
109
|
-
const rootMarkedNode = SurvivingTextNode.fromNode(rootTextNode, !!settings.tryPreserveTypeChecking, !!settings.alwaysUseEllipsisForElisions, settings.lineNumberStyle ?? SummarizedDocumentLineNumberStyle.None);
|
|
110
|
-
|
|
111
|
-
if (offsetSelection) {
|
|
112
|
-
// mark all leaf nodes that intersect userSelection
|
|
113
|
-
rootMarkedNode.visitAll(node => {
|
|
114
|
-
if (!node.node.range.intersectsOrTouches(offsetSelection)) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (node.node.children.length === 0) {
|
|
118
|
-
node.markAsSurviving();
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
rootMarkedNodes.push(rootMarkedNode);
|
|
125
|
-
bestSummarizationResultsPerDocIdx.push(rootMarkedNode.getTextFragment());
|
|
126
|
-
|
|
127
|
-
const distanceScoreToSelection = (node: TextNode) => {
|
|
128
|
-
if (!offsetSelection) {
|
|
129
|
-
return 0;
|
|
130
|
-
}
|
|
131
|
-
if (node.range.endExclusive < offsetSelection.start) {
|
|
132
|
-
// this node is above
|
|
133
|
-
return offsetSelection.start - node.range.endExclusive;
|
|
134
|
-
}
|
|
135
|
-
if (node.range.start > offsetSelection.endExclusive) {
|
|
136
|
-
// this node is below
|
|
137
|
-
return 3 * (node.range.start - offsetSelection.endExclusive); // we will punish code that is below
|
|
138
|
-
}
|
|
139
|
-
// this node is intersecting
|
|
140
|
-
return 0;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const scopeDistanceDown: CachedFunction<TextNode, number> = new CachedFunction(node => {
|
|
144
|
-
if (!offsetSelection) {
|
|
145
|
-
return 0;
|
|
146
|
-
}
|
|
147
|
-
if (node.children.length === 0) {
|
|
148
|
-
return node.range.intersectsOrTouches(offsetSelection) ? 0 : Number.MAX_SAFE_INTEGER;
|
|
149
|
-
} else {
|
|
150
|
-
return min(node.children.map(n => scopeDistanceDown.get(n))) + 1;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
const scopeDistance: CachedFunction<TextNode, number> = new CachedFunction(node => {
|
|
154
|
-
const parentScopeDistance = node.parent ? scopeDistance.get(node.parent) : Number.MAX_SAFE_INTEGER;
|
|
155
|
-
const nodeScopeDistanceDown = scopeDistanceDown.get(node);
|
|
156
|
-
return Math.min(parentScopeDistance, nodeScopeDistanceDown);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const tryPreserveTypeChecking = !!settings.tryPreserveTypeChecking;
|
|
160
|
-
let costFn: (node: TextNode) => number | false = node => {
|
|
161
|
-
if (tryPreserveTypeChecking && node.node?.kind === 'import_statement') {
|
|
162
|
-
return 0;
|
|
163
|
-
}
|
|
164
|
-
return 100 * scopeDistance.get(node)
|
|
165
|
-
+ node.depth
|
|
166
|
-
+ 10 * (distanceScoreToSelection(node) / text.length);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const costFnOverride = typeof settings.costFnOverride === 'object' ? settings.costFnOverride.createCostFn(document) : settings.costFnOverride;
|
|
170
|
-
if (costFnOverride !== undefined) {
|
|
171
|
-
const oldCostFn = costFn;
|
|
172
|
-
|
|
173
|
-
costFn = (n: TextNode) => {
|
|
174
|
-
const currentScore = oldCostFn(n);
|
|
175
|
-
if (currentScore === false) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
if (!n.node) {
|
|
179
|
-
return currentScore;
|
|
180
|
-
}
|
|
181
|
-
return costFnOverride(n.node, currentScore, document);
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const allNodes = rootMarkedNode.getDescendantsAndSelf();
|
|
186
|
-
|
|
187
|
-
for (const node of allNodes) {
|
|
188
|
-
if (!node.node.node) {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
const cost = costFn(node.node);
|
|
192
|
-
if (cost === false) {
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
allNodesWithScores.push({
|
|
196
|
-
docIdx: i,
|
|
197
|
-
node,
|
|
198
|
-
cost
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
allNodesWithScores.sort(compareBy(n => n.cost, numberComparator));
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const getLineNumberText = (lineNumber: number) => {
|
|
207
|
-
return `${lineNumber}: `;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
for (const { node, docIdx } of allNodesWithScores) {
|
|
211
|
-
node.markAsSurviving();
|
|
212
|
-
|
|
213
|
-
// total length of all nodes
|
|
214
|
-
let totalLength = sumBy(rootMarkedNodes, c => c.getTextFragment().length);
|
|
215
|
-
if (settings.lineNumberStyle === SummarizedDocumentLineNumberStyle.Full) {
|
|
216
|
-
const textLen = TextLength.sum(rootMarkedNodes, c => c.getTextFragment().textLength);
|
|
217
|
-
const maxLineNumber = docs[docIdx].document.getLineCount();
|
|
218
|
-
const totalLineNumberChars = textLen.lineCount * getLineNumberText(maxLineNumber).length; // This is an upper bound approximation.
|
|
219
|
-
totalLength += totalLineNumberChars;
|
|
220
|
-
}
|
|
221
|
-
if (totalLength > charLimit) {
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
bestSummarizationResultsPerDocIdx[docIdx] = rootMarkedNodes[docIdx].getTextFragment();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const result: ProjectedDocument<TDocument>[] = [];
|
|
229
|
-
|
|
230
|
-
for (let i = 0; i < bestSummarizationResultsPerDocIdx.length; i++) {
|
|
231
|
-
const bestSummarizationResult = bestSummarizationResultsPerDocIdx[i];
|
|
232
|
-
const { document } = docs[i];
|
|
233
|
-
let e = bestSummarizationResult.toEditFromOriginal(document.getText().length);
|
|
234
|
-
|
|
235
|
-
if (settings.lineNumberStyle === SummarizedDocumentLineNumberStyle.Full) {
|
|
236
|
-
const summarizedDoc = e.apply(document.getText());
|
|
237
|
-
const t = new PositionOffsetTransformer(summarizedDoc);
|
|
238
|
-
const lineNumberReplacements: StringReplacement[] = [];
|
|
239
|
-
const lineCount = t.textLength.lineCount;
|
|
240
|
-
for (let curLine = 1; curLine <= lineCount; curLine++) {
|
|
241
|
-
const offset = t.getOffset(new Position(curLine, 1));
|
|
242
|
-
const offsetBefore = e.applyInverseToOffset(offset);
|
|
243
|
-
const pos = document.getPositionAtOffset(offsetBefore);
|
|
244
|
-
lineNumberReplacements.push(new StringReplacement(OffsetRange.emptyAt(offset), getLineNumberText(pos.line + 1)));
|
|
245
|
-
}
|
|
246
|
-
e = e.compose(new StringEdit(lineNumberReplacements));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const projectedDoc = new ProjectedDocument(document, e);
|
|
250
|
-
const r = projectedDoc as IProjectedDocumentDebugInfo;
|
|
251
|
-
|
|
252
|
-
const rootMarkedNode = rootMarkedNodes[i];
|
|
253
|
-
|
|
254
|
-
r.getVisualization = () => ({
|
|
255
|
-
...{ $fileExtension: 'ast.w' },
|
|
256
|
-
source: {
|
|
257
|
-
value: projectedDoc.originalText,
|
|
258
|
-
decorations: subtractRange(
|
|
259
|
-
OffsetRange.ofLength(projectedDoc.originalText.length),
|
|
260
|
-
projectedDoc.edits.replacements.map(e => e.replaceRange),
|
|
261
|
-
).map(r => ({
|
|
262
|
-
range: [r.start, r.endExclusive],
|
|
263
|
-
color: 'lime',
|
|
264
|
-
}))
|
|
265
|
-
},
|
|
266
|
-
root: toAstNode(rootMarkedNode, n => ({
|
|
267
|
-
label: (n.node.node?.kind || 'unknown') + ` (${allNodesWithScores.find(nws => nws.node === n)?.cost})`,
|
|
268
|
-
range: n.node.range,
|
|
269
|
-
children: n.childNodes,
|
|
270
|
-
isMarked: n['_surviving'],
|
|
271
|
-
}))
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
result.push(projectedDoc);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function createRemovableNodeFromOverlayNode(node: OverlayNode, document: AbstractDocument, parent: RemovableNode | undefined = undefined): RemovableNode {
|
|
281
|
-
const range = new OffsetRange(node.startIndex, node.endIndex);
|
|
282
|
-
const children: RemovableNode[] = [];
|
|
283
|
-
const result = new RemovableNode(parent, node, range, children, document);
|
|
284
|
-
for (const n of node.children) {
|
|
285
|
-
children.push(createRemovableNodeFromOverlayNode(n, document, result));
|
|
286
|
-
}
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* A dense representation of the text in a document.
|
|
292
|
-
* Based on overlay nodes.
|
|
293
|
-
*
|
|
294
|
-
* **Dense**: every character is contained by some leaf node.
|
|
295
|
-
*/
|
|
296
|
-
class TextNode {
|
|
297
|
-
public static fromRootNode(node: RemovableNode, document: AbstractDocument): TextNode {
|
|
298
|
-
const fullRange = new OffsetRange(0, document.length);
|
|
299
|
-
if (node.range.equals(fullRange)) {
|
|
300
|
-
return TextNode.fromNode(node, document);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// The root node does not cover the entire document!
|
|
304
|
-
// So we have to create a virtual root that actually does cover the entire document.
|
|
305
|
-
|
|
306
|
-
const startGap = new OffsetRange(0, node.range.start);
|
|
307
|
-
const endGap = new OffsetRange(node.range.endExclusive, document.length);
|
|
308
|
-
|
|
309
|
-
const children: TextNode[] = [];
|
|
310
|
-
const rootNode = new TextNode(undefined, fullRange, children, 0, null, document);
|
|
311
|
-
|
|
312
|
-
if (!startGap.isEmpty) {
|
|
313
|
-
children.push(new TextNode(undefined, startGap, [], 0, rootNode, document));
|
|
314
|
-
}
|
|
315
|
-
children.push(TextNode.fromNode(node, document, 1, null));
|
|
316
|
-
if (!endGap.isEmpty) {
|
|
317
|
-
children.push(new TextNode(undefined, endGap, [], 0, rootNode, document));
|
|
318
|
-
}
|
|
319
|
-
return rootNode;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private static fromNode(node: RemovableNode, document: AbstractDocument, depth = 0, parent: TextNode | null = null): TextNode {
|
|
323
|
-
const children: TextNode[] = [];
|
|
324
|
-
const result = new TextNode(node, node.range, children, depth, parent, document);
|
|
325
|
-
if (node.children.length > 0) {
|
|
326
|
-
let lastEnd = node.range.start;
|
|
327
|
-
for (const n of node.children) {
|
|
328
|
-
const gap = new OffsetRange(lastEnd, n.range.start);
|
|
329
|
-
if (!gap.isEmpty) {
|
|
330
|
-
children.push(new TextNode(undefined, gap, [], depth, result, document));
|
|
331
|
-
}
|
|
332
|
-
children.push(TextNode.fromNode(n, document, depth + 1, result));
|
|
333
|
-
lastEnd = n.range.endExclusive;
|
|
334
|
-
}
|
|
335
|
-
const gap = new OffsetRange(lastEnd, node.range.endExclusive);
|
|
336
|
-
if (!gap.isEmpty) {
|
|
337
|
-
children.push(new TextNode(undefined, gap, [], depth, result, document));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return result;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
constructor(
|
|
344
|
-
public readonly node: RemovableNode | undefined,
|
|
345
|
-
public readonly range: OffsetRange,
|
|
346
|
-
public readonly children: readonly TextNode[],
|
|
347
|
-
public readonly depth: number,
|
|
348
|
-
public readonly parent: TextNode | null,
|
|
349
|
-
public readonly document: AbstractDocument,
|
|
350
|
-
) { }
|
|
351
|
-
|
|
352
|
-
getLeadingWs(): string {
|
|
353
|
-
return getLeadingWs(this.document.getText(), this.range);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
getIndentation(): string {
|
|
357
|
-
let indentation = this.getLeadingWs();
|
|
358
|
-
const lastNewLineIdx = indentation.lastIndexOf('\n');
|
|
359
|
-
if (lastNewLineIdx !== -1) {
|
|
360
|
-
indentation = indentation.substring(lastNewLineIdx + 1);
|
|
361
|
-
}
|
|
362
|
-
return indentation;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
getTrailingWs(): string {
|
|
366
|
-
return getTrailingWs(this.document.getText(), this.range);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
function getLeadingWs(str: string, range: OffsetRange): string {
|
|
371
|
-
const val = range.substring(str);
|
|
372
|
-
const trimmed = val.length - val.trimStart().length;
|
|
373
|
-
const ws = val.substring(0, trimmed);
|
|
374
|
-
return ws;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function getTrailingWs(str: string, range: OffsetRange): string {
|
|
378
|
-
const val = range.substring(str);
|
|
379
|
-
const trimmed = val.length - val.trimEnd().length;
|
|
380
|
-
const ws = val.substring(val.length - trimmed);
|
|
381
|
-
return ws;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
export enum SummarizedDocumentLineNumberStyle {
|
|
385
|
-
None,
|
|
386
|
-
OmittedRanges,
|
|
387
|
-
Full,
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
class SurvivingTextNode {
|
|
391
|
-
public static fromNode(node: TextNode, tryPreserveTypeChecking: boolean, alwaysUseEllipsisForElisions: boolean, lineNumberStyle: SummarizedDocumentLineNumberStyle): SurvivingTextNode {
|
|
392
|
-
return SurvivingTextNode.fromNodeParent(node, null, tryPreserveTypeChecking, alwaysUseEllipsisForElisions, lineNumberStyle);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
private static fromNodeParent(node: TextNode, parent: SurvivingTextNode | null, tryPreserveTypeChecking: boolean, alwaysUseEllipsisForElisions: boolean, lineNumberStyle: SummarizedDocumentLineNumberStyle): SurvivingTextNode {
|
|
396
|
-
const children: SurvivingTextNode[] = [];
|
|
397
|
-
const result = new SurvivingTextNode(node, parent, children, tryPreserveTypeChecking, alwaysUseEllipsisForElisions, lineNumberStyle);
|
|
398
|
-
for (const child of node.children) {
|
|
399
|
-
const childNode = SurvivingTextNode.fromNodeParent(child, result, tryPreserveTypeChecking, alwaysUseEllipsisForElisions, lineNumberStyle);
|
|
400
|
-
children.push(childNode);
|
|
401
|
-
}
|
|
402
|
-
return result;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
private _surviving = false;
|
|
406
|
-
|
|
407
|
-
constructor(
|
|
408
|
-
public readonly node: TextNode,
|
|
409
|
-
public readonly parent: SurvivingTextNode | null,
|
|
410
|
-
public readonly childNodes: readonly SurvivingTextNode[],
|
|
411
|
-
private readonly _tryPreserveTypeChecking: boolean,
|
|
412
|
-
private readonly _alwaysUseEllipsisForElisions: boolean,
|
|
413
|
-
private readonly _lineNumberStyle: SummarizedDocumentLineNumberStyle,
|
|
414
|
-
) {
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
visitAll(fn: (node: SurvivingTextNode) => boolean): void {
|
|
418
|
-
if (!fn(this)) { return; }
|
|
419
|
-
for (const child of this.childNodes) {
|
|
420
|
-
child.visitAll(fn);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
markAsSurviving(): void {
|
|
425
|
-
if (this._surviving) { return; }
|
|
426
|
-
this._surviving = true;
|
|
427
|
-
if (this.parent) {
|
|
428
|
-
this.parent.markAsSurviving();
|
|
429
|
-
}
|
|
430
|
-
this.invalidate();
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
private _textFragment: StringFragment | null = null;
|
|
434
|
-
|
|
435
|
-
private invalidate(): void {
|
|
436
|
-
if (!this._textFragment) { return; }
|
|
437
|
-
this._textFragment = null;
|
|
438
|
-
if (this.parent) {
|
|
439
|
-
this.parent.invalidate();
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
getTextFragment(): StringFragment {
|
|
444
|
-
if (!this._textFragment) {
|
|
445
|
-
this._textFragment = this._computeSummarization();
|
|
446
|
-
}
|
|
447
|
-
return this._textFragment;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private _computeSummarization(): StringFragment {
|
|
451
|
-
if (this.childNodes.length === 0 && (this._surviving || !this.node.node)) {
|
|
452
|
-
return new OriginalStringFragment(this.node.range, this.node.document.getText());
|
|
453
|
-
}
|
|
454
|
-
if (!this._surviving) {
|
|
455
|
-
return new LiteralStringFragment('');
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const groups = Array.from(groupAdjacentBy(this.childNodes.map(n => ({ node: n, fragment: n.getTextFragment() })), (f1, f2) => (f1.fragment.length === 0) === (f2.fragment.length === 0)));
|
|
459
|
-
|
|
460
|
-
const getOmittedMessage = (omittedRange: OffsetRange): string => {
|
|
461
|
-
if (this._lineNumberStyle === SummarizedDocumentLineNumberStyle.OmittedRanges) {
|
|
462
|
-
const range = this.node.document.getPositionOffsetTransformer().getRange(omittedRange);
|
|
463
|
-
if (range.startLineNumber !== range.endLineNumber) {
|
|
464
|
-
return `/* Lines ${range.startLineNumber}-${range.endLineNumber} omitted */`;
|
|
465
|
-
}
|
|
466
|
-
return `/* Line ${range.startLineNumber} omitted */`;
|
|
467
|
-
}
|
|
468
|
-
return this._tryPreserveTypeChecking ? '/* ... */' : '…';
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
for (let i = 0; i < groups.length; i++) {
|
|
472
|
-
// in one group, all elements either are all empty or non-empty. Also, no group is empty.
|
|
473
|
-
const g = groups[i];
|
|
474
|
-
const isEmpty = g[0].fragment.length === 0;
|
|
475
|
-
|
|
476
|
-
if (isEmpty && i > 0 && i < groups.length - 1) {
|
|
477
|
-
// All our fragments are empty.
|
|
478
|
-
const prev = groups[i - 1].at(-1)!; // Non-empty before us
|
|
479
|
-
const next = groups[i + 1].at(0)!; // Non-empty after us
|
|
480
|
-
|
|
481
|
-
const fullRange = g.at(0)!.node.node.range.join(g.at(-1)!.node.node.range);
|
|
482
|
-
|
|
483
|
-
if (prev.fragment instanceof OriginalStringFragment && next.fragment instanceof OriginalStringFragment) {
|
|
484
|
-
const startTrimmed = prev.fragment.trimEnd();
|
|
485
|
-
const endTrimmed = next.fragment.trimStart();
|
|
486
|
-
if (startTrimmed.endsWith('{') && endTrimmed.startsWith('}')) {
|
|
487
|
-
groups[i - 1][groups[i - 1].length - 1].fragment = startTrimmed;
|
|
488
|
-
g.length = 1;
|
|
489
|
-
|
|
490
|
-
g[0].fragment = new LiteralStringFragment(getOmittedMessage(fullRange));
|
|
491
|
-
groups[i + 1][0].fragment = endTrimmed;
|
|
492
|
-
continue;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (this._alwaysUseEllipsisForElisions || this._lineNumberStyle === SummarizedDocumentLineNumberStyle.OmittedRanges) {
|
|
497
|
-
const indentation = g.at(0)!.node.node.getIndentation();
|
|
498
|
-
const end = g.at(-1)!.node.node.getTrailingWs();
|
|
499
|
-
g.length = 1;
|
|
500
|
-
g[0].fragment = new LiteralStringFragment(indentation + getOmittedMessage(fullRange) + end);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const result: StringFragment[] = [];
|
|
506
|
-
for (const group of groups) {
|
|
507
|
-
for (const g of group) {
|
|
508
|
-
pushFragment(result, g.fragment);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
return ConcatenatedStringFragment.from(result);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
getDescendantsAndSelf(): SurvivingTextNode[] {
|
|
516
|
-
const result: SurvivingTextNode[] = [];
|
|
517
|
-
this._getDescendantsAndSelf(result);
|
|
518
|
-
return result;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
private _getDescendantsAndSelf(result: SurvivingTextNode[]): void {
|
|
522
|
-
result.push(this);
|
|
523
|
-
for (const child of this.childNodes) {
|
|
524
|
-
child._getDescendantsAndSelf(result);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|