Path: blob/main/extensions/copilot/src/platform/remoteSearch/common/utils.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { ICodeOrDocsSearchBaseScopingQuery } from './codeOrDocsSearchClient';67export function formatScopingQuery(query: ICodeOrDocsSearchBaseScopingQuery) {8const repo: string[] = Array.isArray(query.repo) ? query.repo : [query.repo];9const parts: string[] = [10`(repo:${repo.join(' OR repo:')})`11];12if (query.lang) {13parts.push(`(lang:${query.lang.join(' OR lang:')})`);14}15if (query.notLang) {16parts.push(`NOT (lang:${query.notLang.join(' OR lang:')})`);17}18if (query.path) {19parts.push(`(path:${query.path.join(' OR path:')})`);20}21if (query.notPath) {22parts.push(`NOT (path:${query.notPath.join(' OR path:')})`);23}24return parts.join(' ');25}262728