Path: blob/main/extensions/copilot/src/extension/prompt/common/importStatement.ts
13399 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*--------------------------------------------------------------------------------------------*/45export function isImportStatement(line: string, languageId: string): boolean {6switch (languageId) {7case 'java':8return !!line.match(/^\s*import\s/);9case 'typescript':10case 'typescriptreact':11case 'javascript':12case 'javascriptreact':13return !!line.match(/^\s*import[\s{*]|^\s*[var|const|let].*=\s*require\(/);14case 'php':15return !!line.match(/^\s*use/);16case 'rust':17return !!line.match(/^\s*use\s+[\w:{}, ]+\s*(as\s+\w+)?;/);18case 'python':19return !!line.match(/^\s*from\s+[\w.]+\s+import\s+[\w, *]+$/)20|| !!line.match(/^\s*import\s+[\w, ]+$/);21default:22return false;23}24}252627