@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,839 +0,0 @@
|
|
|
1
|
-
//!!! DO NOT modify, this file was COPIED from 'microsoft/vscode'
|
|
2
|
-
|
|
3
|
-
/*---------------------------------------------------------------------------------------------
|
|
4
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
-
*--------------------------------------------------------------------------------------------*/
|
|
7
|
-
|
|
8
|
-
import { equals } from './arrays';
|
|
9
|
-
import { isThenable } from './async';
|
|
10
|
-
import { CharCode } from './charCode';
|
|
11
|
-
import { isEqualOrParent } from './extpath';
|
|
12
|
-
import { LRUCache } from './map';
|
|
13
|
-
import { basename, extname, posix, sep } from './path';
|
|
14
|
-
import { isLinux } from './platform';
|
|
15
|
-
import { escapeRegExpCharacters, ltrim } from './strings';
|
|
16
|
-
|
|
17
|
-
export interface IRelativePattern {
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A base file path to which this pattern will be matched against relatively.
|
|
21
|
-
*/
|
|
22
|
-
readonly base: string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A file glob pattern like `*.{ts,js}` that will be matched on file paths
|
|
26
|
-
* relative to the base path.
|
|
27
|
-
*
|
|
28
|
-
* Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
|
|
29
|
-
* the file glob pattern will match on `index.js`.
|
|
30
|
-
*/
|
|
31
|
-
readonly pattern: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface IExpression {
|
|
35
|
-
[pattern: string]: boolean | SiblingClause;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function getEmptyExpression(): IExpression {
|
|
39
|
-
return Object.create(null);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface SiblingClause {
|
|
43
|
-
when: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const GLOBSTAR = '**';
|
|
47
|
-
export const GLOB_SPLIT = '/';
|
|
48
|
-
|
|
49
|
-
const PATH_REGEX = '[/\\\\]'; // any slash or backslash
|
|
50
|
-
const NO_PATH_REGEX = '[^/\\\\]'; // any non-slash and non-backslash
|
|
51
|
-
const ALL_FORWARD_SLASHES = /\//g;
|
|
52
|
-
|
|
53
|
-
function starsToRegExp(starCount: number, isLastPattern?: boolean): string {
|
|
54
|
-
switch (starCount) {
|
|
55
|
-
case 0:
|
|
56
|
-
return '';
|
|
57
|
-
case 1:
|
|
58
|
-
return `${NO_PATH_REGEX}*?`; // 1 star matches any number of characters except path separator (/ and \) - non greedy (?)
|
|
59
|
-
default:
|
|
60
|
-
// Matches: (Path Sep OR Path Val followed by Path Sep) 0-many times except when it's the last pattern
|
|
61
|
-
// in which case also matches (Path Sep followed by Path Val)
|
|
62
|
-
// Group is non capturing because we don't need to capture at all (?:...)
|
|
63
|
-
// Overall we use non-greedy matching because it could be that we match too much
|
|
64
|
-
return `(?:${PATH_REGEX}|${NO_PATH_REGEX}+${PATH_REGEX}${isLastPattern ? `|${PATH_REGEX}${NO_PATH_REGEX}+` : ''})*?`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function splitGlobAware(pattern: string, splitChar: string): string[] {
|
|
69
|
-
if (!pattern) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const segments: string[] = [];
|
|
74
|
-
|
|
75
|
-
let inBraces = false;
|
|
76
|
-
let inBrackets = false;
|
|
77
|
-
|
|
78
|
-
let curVal = '';
|
|
79
|
-
for (const char of pattern) {
|
|
80
|
-
switch (char) {
|
|
81
|
-
case splitChar:
|
|
82
|
-
if (!inBraces && !inBrackets) {
|
|
83
|
-
segments.push(curVal);
|
|
84
|
-
curVal = '';
|
|
85
|
-
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case '{':
|
|
90
|
-
inBraces = true;
|
|
91
|
-
break;
|
|
92
|
-
case '}':
|
|
93
|
-
inBraces = false;
|
|
94
|
-
break;
|
|
95
|
-
case '[':
|
|
96
|
-
inBrackets = true;
|
|
97
|
-
break;
|
|
98
|
-
case ']':
|
|
99
|
-
inBrackets = false;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
curVal += char;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Tail
|
|
107
|
-
if (curVal) {
|
|
108
|
-
segments.push(curVal);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return segments;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function parseRegExp(pattern: string): string {
|
|
115
|
-
if (!pattern) {
|
|
116
|
-
return '';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
let regEx = '';
|
|
120
|
-
|
|
121
|
-
// Split up into segments for each slash found
|
|
122
|
-
const segments = splitGlobAware(pattern, GLOB_SPLIT);
|
|
123
|
-
|
|
124
|
-
// Special case where we only have globstars
|
|
125
|
-
if (segments.every(segment => segment === GLOBSTAR)) {
|
|
126
|
-
regEx = '.*';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Build regex over segments
|
|
130
|
-
else {
|
|
131
|
-
let previousSegmentWasGlobStar = false;
|
|
132
|
-
segments.forEach((segment, index) => {
|
|
133
|
-
|
|
134
|
-
// Treat globstar specially
|
|
135
|
-
if (segment === GLOBSTAR) {
|
|
136
|
-
|
|
137
|
-
// if we have more than one globstar after another, just ignore it
|
|
138
|
-
if (previousSegmentWasGlobStar) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
regEx += starsToRegExp(2, index === segments.length - 1);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Anything else, not globstar
|
|
146
|
-
else {
|
|
147
|
-
|
|
148
|
-
// States
|
|
149
|
-
let inBraces = false;
|
|
150
|
-
let braceVal = '';
|
|
151
|
-
|
|
152
|
-
let inBrackets = false;
|
|
153
|
-
let bracketVal = '';
|
|
154
|
-
|
|
155
|
-
for (const char of segment) {
|
|
156
|
-
|
|
157
|
-
// Support brace expansion
|
|
158
|
-
if (char !== '}' && inBraces) {
|
|
159
|
-
braceVal += char;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Support brackets
|
|
164
|
-
if (inBrackets && (char !== ']' || !bracketVal) /* ] is literally only allowed as first character in brackets to match it */) {
|
|
165
|
-
let res: string;
|
|
166
|
-
|
|
167
|
-
// range operator
|
|
168
|
-
if (char === '-') {
|
|
169
|
-
res = char;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// negation operator (only valid on first index in bracket)
|
|
173
|
-
else if ((char === '^' || char === '!') && !bracketVal) {
|
|
174
|
-
res = '^';
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// glob split matching is not allowed within character ranges
|
|
178
|
-
// see http://man7.org/linux/man-pages/man7/glob.7.html
|
|
179
|
-
else if (char === GLOB_SPLIT) {
|
|
180
|
-
res = '';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// anything else gets escaped
|
|
184
|
-
else {
|
|
185
|
-
res = escapeRegExpCharacters(char);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
bracketVal += res;
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
switch (char) {
|
|
193
|
-
case '{':
|
|
194
|
-
inBraces = true;
|
|
195
|
-
continue;
|
|
196
|
-
|
|
197
|
-
case '[':
|
|
198
|
-
inBrackets = true;
|
|
199
|
-
continue;
|
|
200
|
-
|
|
201
|
-
case '}': {
|
|
202
|
-
const choices = splitGlobAware(braceVal, ',');
|
|
203
|
-
|
|
204
|
-
// Converts {foo,bar} => [foo|bar]
|
|
205
|
-
const braceRegExp = `(?:${choices.map(choice => parseRegExp(choice)).join('|')})`;
|
|
206
|
-
|
|
207
|
-
regEx += braceRegExp;
|
|
208
|
-
|
|
209
|
-
inBraces = false;
|
|
210
|
-
braceVal = '';
|
|
211
|
-
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
case ']': {
|
|
216
|
-
regEx += ('[' + bracketVal + ']');
|
|
217
|
-
|
|
218
|
-
inBrackets = false;
|
|
219
|
-
bracketVal = '';
|
|
220
|
-
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
case '?':
|
|
225
|
-
regEx += NO_PATH_REGEX; // 1 ? matches any single character except path separator (/ and \)
|
|
226
|
-
continue;
|
|
227
|
-
|
|
228
|
-
case '*':
|
|
229
|
-
regEx += starsToRegExp(1);
|
|
230
|
-
continue;
|
|
231
|
-
|
|
232
|
-
default:
|
|
233
|
-
regEx += escapeRegExpCharacters(char);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Tail: Add the slash we had split on if there is more to
|
|
238
|
-
// come and the remaining pattern is not a globstar
|
|
239
|
-
// For example if pattern: some/**/*.js we want the "/" after
|
|
240
|
-
// some to be included in the RegEx to prevent a folder called
|
|
241
|
-
// "something" to match as well.
|
|
242
|
-
if (
|
|
243
|
-
index < segments.length - 1 && // more segments to come after this
|
|
244
|
-
(
|
|
245
|
-
segments[index + 1] !== GLOBSTAR || // next segment is not **, or...
|
|
246
|
-
index + 2 < segments.length // ...next segment is ** but there is more segments after that
|
|
247
|
-
)
|
|
248
|
-
) {
|
|
249
|
-
regEx += PATH_REGEX;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// update globstar state
|
|
254
|
-
previousSegmentWasGlobStar = (segment === GLOBSTAR);
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return regEx;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// regexes to check for trivial glob patterns that just check for String#endsWith
|
|
262
|
-
const T1 = /^\*\*\/\*\.[\w\.-]+$/; // **/*.something
|
|
263
|
-
const T2 = /^\*\*\/([\w\.-]+)\/?$/; // **/something
|
|
264
|
-
const T3 = /^{\*\*\/\*?[\w\.-]+\/?(,\*\*\/\*?[\w\.-]+\/?)*}$/; // {**/*.something,**/*.else} or {**/package.json,**/project.json}
|
|
265
|
-
const T3_2 = /^{\*\*\/\*?[\w\.-]+(\/(\*\*)?)?(,\*\*\/\*?[\w\.-]+(\/(\*\*)?)?)*}$/; // Like T3, with optional trailing /**
|
|
266
|
-
const T4 = /^\*\*((\/[\w\.-]+)+)\/?$/; // **/something/else
|
|
267
|
-
const T5 = /^([\w\.-]+(\/[\w\.-]+)*)\/?$/; // something/else
|
|
268
|
-
|
|
269
|
-
export type ParsedPattern = (path: string, basename?: string) => boolean;
|
|
270
|
-
|
|
271
|
-
// The `ParsedExpression` returns a `Promise`
|
|
272
|
-
// iff `hasSibling` returns a `Promise`.
|
|
273
|
-
export type ParsedExpression = (path: string, basename?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) => string | null | Promise<string | null> /* the matching pattern */;
|
|
274
|
-
|
|
275
|
-
interface IGlobOptions {
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Simplify patterns for use as exclusion filters during
|
|
279
|
-
* tree traversal to skip entire subtrees. Cannot be used
|
|
280
|
-
* outside of a tree traversal.
|
|
281
|
-
*/
|
|
282
|
-
trimForExclusions?: boolean;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
interface ParsedStringPattern {
|
|
286
|
-
(path: string, basename?: string): string | null | Promise<string | null> /* the matching pattern */;
|
|
287
|
-
basenames?: string[];
|
|
288
|
-
patterns?: string[];
|
|
289
|
-
allBasenames?: string[];
|
|
290
|
-
allPaths?: string[];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
interface ParsedExpressionPattern {
|
|
294
|
-
(path: string, basename?: string, name?: string, hasSibling?: (name: string) => boolean | Promise<boolean>): string | null | Promise<string | null> /* the matching pattern */;
|
|
295
|
-
requiresSiblings?: boolean;
|
|
296
|
-
allBasenames?: string[];
|
|
297
|
-
allPaths?: string[];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const CACHE = new LRUCache<string, ParsedStringPattern>(10000); // bounded to 10000 elements
|
|
301
|
-
|
|
302
|
-
const FALSE = function () {
|
|
303
|
-
return false;
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const NULL = function (): string | null {
|
|
307
|
-
return null;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Check if a provided parsed pattern or expression
|
|
312
|
-
* is empty - hence it won't ever match anything.
|
|
313
|
-
*
|
|
314
|
-
* See {@link FALSE} and {@link NULL}.
|
|
315
|
-
*/
|
|
316
|
-
export function isEmptyPattern(pattern: ParsedPattern | ParsedExpression): pattern is (typeof FALSE | typeof NULL) {
|
|
317
|
-
if (pattern === FALSE) {
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (pattern === NULL) {
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function parsePattern(arg1: string | IRelativePattern, options: IGlobOptions): ParsedStringPattern {
|
|
329
|
-
if (!arg1) {
|
|
330
|
-
return NULL;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Handle relative patterns
|
|
334
|
-
let pattern: string;
|
|
335
|
-
if (typeof arg1 !== 'string') {
|
|
336
|
-
pattern = arg1.pattern;
|
|
337
|
-
} else {
|
|
338
|
-
pattern = arg1;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Whitespace trimming
|
|
342
|
-
pattern = pattern.trim();
|
|
343
|
-
|
|
344
|
-
// Check cache
|
|
345
|
-
const patternKey = `${pattern}_${!!options.trimForExclusions}`;
|
|
346
|
-
let parsedPattern = CACHE.get(patternKey);
|
|
347
|
-
if (parsedPattern) {
|
|
348
|
-
return wrapRelativePattern(parsedPattern, arg1);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Check for Trivials
|
|
352
|
-
let match: RegExpExecArray | null;
|
|
353
|
-
if (T1.test(pattern)) {
|
|
354
|
-
parsedPattern = trivia1(pattern.substr(4), pattern); // common pattern: **/*.txt just need endsWith check
|
|
355
|
-
} else if (match = T2.exec(trimForExclusions(pattern, options))) { // common pattern: **/some.txt just need basename check
|
|
356
|
-
parsedPattern = trivia2(match[1], pattern);
|
|
357
|
-
} else if ((options.trimForExclusions ? T3_2 : T3).test(pattern)) { // repetition of common patterns (see above) {**/*.txt,**/*.png}
|
|
358
|
-
parsedPattern = trivia3(pattern, options);
|
|
359
|
-
} else if (match = T4.exec(trimForExclusions(pattern, options))) { // common pattern: **/something/else just need endsWith check
|
|
360
|
-
parsedPattern = trivia4and5(match[1].substr(1), pattern, true);
|
|
361
|
-
} else if (match = T5.exec(trimForExclusions(pattern, options))) { // common pattern: something/else just need equals check
|
|
362
|
-
parsedPattern = trivia4and5(match[1], pattern, false);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Otherwise convert to pattern
|
|
366
|
-
else {
|
|
367
|
-
parsedPattern = toRegExp(pattern);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Cache
|
|
371
|
-
CACHE.set(patternKey, parsedPattern);
|
|
372
|
-
|
|
373
|
-
return wrapRelativePattern(parsedPattern, arg1);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function wrapRelativePattern(parsedPattern: ParsedStringPattern, arg2: string | IRelativePattern): ParsedStringPattern {
|
|
377
|
-
if (typeof arg2 === 'string') {
|
|
378
|
-
return parsedPattern;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const wrappedPattern: ParsedStringPattern = function (path, basename) {
|
|
382
|
-
if (!isEqualOrParent(path, arg2.base, !isLinux)) {
|
|
383
|
-
// skip glob matching if `base` is not a parent of `path`
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Given we have checked `base` being a parent of `path`,
|
|
388
|
-
// we can now remove the `base` portion of the `path`
|
|
389
|
-
// and only match on the remaining path components
|
|
390
|
-
// For that we try to extract the portion of the `path`
|
|
391
|
-
// that comes after the `base` portion. We have to account
|
|
392
|
-
// for the fact that `base` might end in a path separator
|
|
393
|
-
// (https://github.com/microsoft/vscode/issues/162498)
|
|
394
|
-
|
|
395
|
-
return parsedPattern(ltrim(path.substr(arg2.base.length), sep), basename);
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
// Make sure to preserve associated metadata
|
|
399
|
-
wrappedPattern.allBasenames = parsedPattern.allBasenames;
|
|
400
|
-
wrappedPattern.allPaths = parsedPattern.allPaths;
|
|
401
|
-
wrappedPattern.basenames = parsedPattern.basenames;
|
|
402
|
-
wrappedPattern.patterns = parsedPattern.patterns;
|
|
403
|
-
|
|
404
|
-
return wrappedPattern;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function trimForExclusions(pattern: string, options: IGlobOptions): string {
|
|
408
|
-
return options.trimForExclusions && pattern.endsWith('/**') ? pattern.substr(0, pattern.length - 2) : pattern; // dropping **, tailing / is dropped later
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// common pattern: **/*.txt just need endsWith check
|
|
412
|
-
function trivia1(base: string, pattern: string): ParsedStringPattern {
|
|
413
|
-
return function (path: string, basename?: string) {
|
|
414
|
-
return typeof path === 'string' && path.endsWith(base) ? pattern : null;
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// common pattern: **/some.txt just need basename check
|
|
419
|
-
function trivia2(base: string, pattern: string): ParsedStringPattern {
|
|
420
|
-
const slashBase = `/${base}`;
|
|
421
|
-
const backslashBase = `\\${base}`;
|
|
422
|
-
|
|
423
|
-
const parsedPattern: ParsedStringPattern = function (path: string, basename?: string) {
|
|
424
|
-
if (typeof path !== 'string') {
|
|
425
|
-
return null;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
if (basename) {
|
|
429
|
-
return basename === base ? pattern : null;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return path === base || path.endsWith(slashBase) || path.endsWith(backslashBase) ? pattern : null;
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
const basenames = [base];
|
|
436
|
-
parsedPattern.basenames = basenames;
|
|
437
|
-
parsedPattern.patterns = [pattern];
|
|
438
|
-
parsedPattern.allBasenames = basenames;
|
|
439
|
-
|
|
440
|
-
return parsedPattern;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// repetition of common patterns (see above) {**/*.txt,**/*.png}
|
|
444
|
-
function trivia3(pattern: string, options: IGlobOptions): ParsedStringPattern {
|
|
445
|
-
const parsedPatterns = aggregateBasenameMatches(pattern.slice(1, -1)
|
|
446
|
-
.split(',')
|
|
447
|
-
.map(pattern => parsePattern(pattern, options))
|
|
448
|
-
.filter(pattern => pattern !== NULL), pattern);
|
|
449
|
-
|
|
450
|
-
const patternsLength = parsedPatterns.length;
|
|
451
|
-
if (!patternsLength) {
|
|
452
|
-
return NULL;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if (patternsLength === 1) {
|
|
456
|
-
return parsedPatterns[0];
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const parsedPattern: ParsedStringPattern = function (path: string, basename?: string) {
|
|
460
|
-
for (let i = 0, n = parsedPatterns.length; i < n; i++) {
|
|
461
|
-
if (parsedPatterns[i](path, basename)) {
|
|
462
|
-
return pattern;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return null;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
const withBasenames = parsedPatterns.find(pattern => !!pattern.allBasenames);
|
|
470
|
-
if (withBasenames) {
|
|
471
|
-
parsedPattern.allBasenames = withBasenames.allBasenames;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
const allPaths = parsedPatterns.reduce((all, current) => current.allPaths ? all.concat(current.allPaths) : all, [] as string[]);
|
|
475
|
-
if (allPaths.length) {
|
|
476
|
-
parsedPattern.allPaths = allPaths;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
return parsedPattern;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// common patterns: **/something/else just need endsWith check, something/else just needs and equals check
|
|
483
|
-
function trivia4and5(targetPath: string, pattern: string, matchPathEnds: boolean): ParsedStringPattern {
|
|
484
|
-
const usingPosixSep = sep === posix.sep;
|
|
485
|
-
const nativePath = usingPosixSep ? targetPath : targetPath.replace(ALL_FORWARD_SLASHES, sep);
|
|
486
|
-
const nativePathEnd = sep + nativePath;
|
|
487
|
-
const targetPathEnd = posix.sep + targetPath;
|
|
488
|
-
|
|
489
|
-
let parsedPattern: ParsedStringPattern;
|
|
490
|
-
if (matchPathEnds) {
|
|
491
|
-
parsedPattern = function (path: string, basename?: string) {
|
|
492
|
-
return typeof path === 'string' && ((path === nativePath || path.endsWith(nativePathEnd)) || !usingPosixSep && (path === targetPath || path.endsWith(targetPathEnd))) ? pattern : null;
|
|
493
|
-
};
|
|
494
|
-
} else {
|
|
495
|
-
parsedPattern = function (path: string, basename?: string) {
|
|
496
|
-
return typeof path === 'string' && (path === nativePath || (!usingPosixSep && path === targetPath)) ? pattern : null;
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
parsedPattern.allPaths = [(matchPathEnds ? '*/' : './') + targetPath];
|
|
501
|
-
|
|
502
|
-
return parsedPattern;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
function toRegExp(pattern: string): ParsedStringPattern {
|
|
506
|
-
try {
|
|
507
|
-
const regExp = new RegExp(`^${parseRegExp(pattern)}$`);
|
|
508
|
-
return function (path: string) {
|
|
509
|
-
regExp.lastIndex = 0; // reset RegExp to its initial state to reuse it!
|
|
510
|
-
|
|
511
|
-
return typeof path === 'string' && regExp.test(path) ? pattern : null;
|
|
512
|
-
};
|
|
513
|
-
} catch (error) {
|
|
514
|
-
return NULL;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Simplified glob matching. Supports a subset of glob patterns:
|
|
520
|
-
* * `*` to match zero or more characters in a path segment
|
|
521
|
-
* * `?` to match on one character in a path segment
|
|
522
|
-
* * `**` to match any number of path segments, including none
|
|
523
|
-
* * `{}` to group conditions (e.g. *.{ts,js} matches all TypeScript and JavaScript files)
|
|
524
|
-
* * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
|
|
525
|
-
* * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
|
|
526
|
-
*/
|
|
527
|
-
export function match(pattern: string | IRelativePattern, path: string): boolean;
|
|
528
|
-
export function match(expression: IExpression, path: string, hasSibling?: (name: string) => boolean): string /* the matching pattern */;
|
|
529
|
-
export function match(arg1: string | IExpression | IRelativePattern, path: string, hasSibling?: (name: string) => boolean): boolean | string | null | Promise<string | null> {
|
|
530
|
-
if (!arg1 || typeof path !== 'string') {
|
|
531
|
-
return false;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
return parse(arg1)(path, undefined, hasSibling);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* Simplified glob matching. Supports a subset of glob patterns:
|
|
539
|
-
* * `*` to match zero or more characters in a path segment
|
|
540
|
-
* * `?` to match on one character in a path segment
|
|
541
|
-
* * `**` to match any number of path segments, including none
|
|
542
|
-
* * `{}` to group conditions (e.g. *.{ts,js} matches all TypeScript and JavaScript files)
|
|
543
|
-
* * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
|
|
544
|
-
* * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
|
|
545
|
-
*/
|
|
546
|
-
export function parse(pattern: string | IRelativePattern, options?: IGlobOptions): ParsedPattern;
|
|
547
|
-
export function parse(expression: IExpression, options?: IGlobOptions): ParsedExpression;
|
|
548
|
-
export function parse(arg1: string | IExpression | IRelativePattern, options?: IGlobOptions): ParsedPattern | ParsedExpression;
|
|
549
|
-
export function parse(arg1: string | IExpression | IRelativePattern, options: IGlobOptions = {}): ParsedPattern | ParsedExpression {
|
|
550
|
-
if (!arg1) {
|
|
551
|
-
return FALSE;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Glob with String
|
|
555
|
-
if (typeof arg1 === 'string' || isRelativePattern(arg1)) {
|
|
556
|
-
const parsedPattern = parsePattern(arg1, options);
|
|
557
|
-
if (parsedPattern === NULL) {
|
|
558
|
-
return FALSE;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const resultPattern: ParsedPattern & { allBasenames?: string[]; allPaths?: string[] } = function (path: string, basename?: string) {
|
|
562
|
-
return !!parsedPattern(path, basename);
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
if (parsedPattern.allBasenames) {
|
|
566
|
-
resultPattern.allBasenames = parsedPattern.allBasenames;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
if (parsedPattern.allPaths) {
|
|
570
|
-
resultPattern.allPaths = parsedPattern.allPaths;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return resultPattern;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// Glob with Expression
|
|
577
|
-
return parsedExpression(<IExpression>arg1, options);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
export function isRelativePattern(obj: unknown): obj is IRelativePattern {
|
|
581
|
-
const rp = obj as IRelativePattern | undefined | null;
|
|
582
|
-
if (!rp) {
|
|
583
|
-
return false;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
return typeof rp.base === 'string' && typeof rp.pattern === 'string';
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
export function getBasenameTerms(patternOrExpression: ParsedPattern | ParsedExpression): string[] {
|
|
590
|
-
return (<ParsedStringPattern>patternOrExpression).allBasenames || [];
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export function getPathTerms(patternOrExpression: ParsedPattern | ParsedExpression): string[] {
|
|
594
|
-
return (<ParsedStringPattern>patternOrExpression).allPaths || [];
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function parsedExpression(expression: IExpression, options: IGlobOptions): ParsedExpression {
|
|
598
|
-
const parsedPatterns = aggregateBasenameMatches(Object.getOwnPropertyNames(expression)
|
|
599
|
-
.map(pattern => parseExpressionPattern(pattern, expression[pattern], options))
|
|
600
|
-
.filter(pattern => pattern !== NULL));
|
|
601
|
-
|
|
602
|
-
const patternsLength = parsedPatterns.length;
|
|
603
|
-
if (!patternsLength) {
|
|
604
|
-
return NULL;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
if (!parsedPatterns.some(parsedPattern => !!(<ParsedExpressionPattern>parsedPattern).requiresSiblings)) {
|
|
608
|
-
if (patternsLength === 1) {
|
|
609
|
-
return parsedPatterns[0] as ParsedStringPattern;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
const resultExpression: ParsedStringPattern = function (path: string, basename?: string) {
|
|
613
|
-
let resultPromises: Promise<string | null>[] | undefined = undefined;
|
|
614
|
-
|
|
615
|
-
for (let i = 0, n = parsedPatterns.length; i < n; i++) {
|
|
616
|
-
const result = parsedPatterns[i](path, basename);
|
|
617
|
-
if (typeof result === 'string') {
|
|
618
|
-
return result; // immediately return as soon as the first expression matches
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// If the result is a promise, we have to keep it for
|
|
622
|
-
// later processing and await the result properly.
|
|
623
|
-
if (isThenable(result)) {
|
|
624
|
-
if (!resultPromises) {
|
|
625
|
-
resultPromises = [];
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
resultPromises.push(result);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// With result promises, we have to loop over each and
|
|
633
|
-
// await the result before we can return any result.
|
|
634
|
-
if (resultPromises) {
|
|
635
|
-
return (async () => {
|
|
636
|
-
for (const resultPromise of resultPromises) {
|
|
637
|
-
const result = await resultPromise;
|
|
638
|
-
if (typeof result === 'string') {
|
|
639
|
-
return result;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
return null;
|
|
644
|
-
})();
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
return null;
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
const withBasenames = parsedPatterns.find(pattern => !!pattern.allBasenames);
|
|
651
|
-
if (withBasenames) {
|
|
652
|
-
resultExpression.allBasenames = withBasenames.allBasenames;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
const allPaths = parsedPatterns.reduce((all, current) => current.allPaths ? all.concat(current.allPaths) : all, [] as string[]);
|
|
656
|
-
if (allPaths.length) {
|
|
657
|
-
resultExpression.allPaths = allPaths;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
return resultExpression;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
const resultExpression: ParsedStringPattern = function (path: string, base?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) {
|
|
664
|
-
let name: string | undefined = undefined;
|
|
665
|
-
let resultPromises: Promise<string | null>[] | undefined = undefined;
|
|
666
|
-
|
|
667
|
-
for (let i = 0, n = parsedPatterns.length; i < n; i++) {
|
|
668
|
-
|
|
669
|
-
// Pattern matches path
|
|
670
|
-
const parsedPattern = (<ParsedExpressionPattern>parsedPatterns[i]);
|
|
671
|
-
if (parsedPattern.requiresSiblings && hasSibling) {
|
|
672
|
-
if (!base) {
|
|
673
|
-
base = basename(path);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
if (!name) {
|
|
677
|
-
name = base.substr(0, base.length - extname(path).length);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
const result = parsedPattern(path, base, name, hasSibling);
|
|
682
|
-
if (typeof result === 'string') {
|
|
683
|
-
return result; // immediately return as soon as the first expression matches
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// If the result is a promise, we have to keep it for
|
|
687
|
-
// later processing and await the result properly.
|
|
688
|
-
if (isThenable(result)) {
|
|
689
|
-
if (!resultPromises) {
|
|
690
|
-
resultPromises = [];
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
resultPromises.push(result);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// With result promises, we have to loop over each and
|
|
698
|
-
// await the result before we can return any result.
|
|
699
|
-
if (resultPromises) {
|
|
700
|
-
return (async () => {
|
|
701
|
-
for (const resultPromise of resultPromises) {
|
|
702
|
-
const result = await resultPromise;
|
|
703
|
-
if (typeof result === 'string') {
|
|
704
|
-
return result;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return null;
|
|
709
|
-
})();
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
return null;
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
const withBasenames = parsedPatterns.find(pattern => !!pattern.allBasenames);
|
|
716
|
-
if (withBasenames) {
|
|
717
|
-
resultExpression.allBasenames = withBasenames.allBasenames;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
const allPaths = parsedPatterns.reduce((all, current) => current.allPaths ? all.concat(current.allPaths) : all, [] as string[]);
|
|
721
|
-
if (allPaths.length) {
|
|
722
|
-
resultExpression.allPaths = allPaths;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return resultExpression;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
function parseExpressionPattern(pattern: string, value: boolean | SiblingClause, options: IGlobOptions): (ParsedStringPattern | ParsedExpressionPattern) {
|
|
729
|
-
if (value === false) {
|
|
730
|
-
return NULL; // pattern is disabled
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const parsedPattern = parsePattern(pattern, options);
|
|
734
|
-
if (parsedPattern === NULL) {
|
|
735
|
-
return NULL;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// Expression Pattern is <boolean>
|
|
739
|
-
if (typeof value === 'boolean') {
|
|
740
|
-
return parsedPattern;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// Expression Pattern is <SiblingClause>
|
|
744
|
-
if (value) {
|
|
745
|
-
const when = value.when;
|
|
746
|
-
if (typeof when === 'string') {
|
|
747
|
-
const result: ParsedExpressionPattern = (path: string, basename?: string, name?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) => {
|
|
748
|
-
if (!hasSibling || !parsedPattern(path, basename)) {
|
|
749
|
-
return null;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
const clausePattern = when.replace('$(basename)', () => name!);
|
|
753
|
-
const matched = hasSibling(clausePattern);
|
|
754
|
-
return isThenable(matched) ?
|
|
755
|
-
matched.then(match => match ? pattern : null) :
|
|
756
|
-
matched ? pattern : null;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
result.requiresSiblings = true;
|
|
760
|
-
|
|
761
|
-
return result;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// Expression is anything
|
|
766
|
-
return parsedPattern;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
function aggregateBasenameMatches(parsedPatterns: Array<ParsedStringPattern | ParsedExpressionPattern>, result?: string): Array<ParsedStringPattern | ParsedExpressionPattern> {
|
|
770
|
-
const basenamePatterns = parsedPatterns.filter(parsedPattern => !!(<ParsedStringPattern>parsedPattern).basenames);
|
|
771
|
-
if (basenamePatterns.length < 2) {
|
|
772
|
-
return parsedPatterns;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
const basenames = basenamePatterns.reduce<string[]>((all, current) => {
|
|
776
|
-
const basenames = (<ParsedStringPattern>current).basenames;
|
|
777
|
-
|
|
778
|
-
return basenames ? all.concat(basenames) : all;
|
|
779
|
-
}, [] as string[]);
|
|
780
|
-
|
|
781
|
-
let patterns: string[];
|
|
782
|
-
if (result) {
|
|
783
|
-
patterns = [];
|
|
784
|
-
|
|
785
|
-
for (let i = 0, n = basenames.length; i < n; i++) {
|
|
786
|
-
patterns.push(result);
|
|
787
|
-
}
|
|
788
|
-
} else {
|
|
789
|
-
patterns = basenamePatterns.reduce((all, current) => {
|
|
790
|
-
const patterns = (<ParsedStringPattern>current).patterns;
|
|
791
|
-
|
|
792
|
-
return patterns ? all.concat(patterns) : all;
|
|
793
|
-
}, [] as string[]);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
const aggregate: ParsedStringPattern = function (path: string, basename?: string) {
|
|
797
|
-
if (typeof path !== 'string') {
|
|
798
|
-
return null;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
if (!basename) {
|
|
802
|
-
let i: number;
|
|
803
|
-
for (i = path.length; i > 0; i--) {
|
|
804
|
-
const ch = path.charCodeAt(i - 1);
|
|
805
|
-
if (ch === CharCode.Slash || ch === CharCode.Backslash) {
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
basename = path.substr(i);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
const index = basenames.indexOf(basename);
|
|
814
|
-
return index !== -1 ? patterns[index] : null;
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
aggregate.basenames = basenames;
|
|
818
|
-
aggregate.patterns = patterns;
|
|
819
|
-
aggregate.allBasenames = basenames;
|
|
820
|
-
|
|
821
|
-
const aggregatedPatterns = parsedPatterns.filter(parsedPattern => !(<ParsedStringPattern>parsedPattern).basenames);
|
|
822
|
-
aggregatedPatterns.push(aggregate);
|
|
823
|
-
|
|
824
|
-
return aggregatedPatterns;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
export function patternsEquals(patternsA: Array<string | IRelativePattern> | undefined, patternsB: Array<string | IRelativePattern> | undefined): boolean {
|
|
828
|
-
return equals(patternsA, patternsB, (a, b) => {
|
|
829
|
-
if (typeof a === 'string' && typeof b === 'string') {
|
|
830
|
-
return a === b;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
if (typeof a !== 'string' && typeof b !== 'string') {
|
|
834
|
-
return a.base === b.base && a.pattern === b.pattern;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
return false;
|
|
838
|
-
});
|
|
839
|
-
}
|