(
include: string,
exclude?: string,
maxResults?: number
)
| 1897 | }, |
| 1898 | |
| 1899 | async findFiles( |
| 1900 | include: string, |
| 1901 | exclude?: string, |
| 1902 | maxResults?: number |
| 1903 | ): Promise<Uri[]> { |
| 1904 | // Simple implementation that recursively finds files |
| 1905 | const workspaceFolder = mockState.workspaceFolders[0]; |
| 1906 | |
| 1907 | if (!workspaceFolder) { |
| 1908 | return []; |
| 1909 | } |
| 1910 | |
| 1911 | const findFilesRecursive = async (dir: string): Promise<string[]> => { |
| 1912 | const files: string[] = []; |
| 1913 | try { |
| 1914 | const entries = await fs.promises.readdir(dir, { withFileTypes: true }); |
| 1915 | |
| 1916 | for (const entry of entries) { |
| 1917 | const fullPath = path.join(dir, entry.name); |
| 1918 | const relativePath = path |
| 1919 | .relative(workspaceFolder.uri.fsPath, fullPath) |
| 1920 | .split(path.sep) |
| 1921 | .join('/'); |
| 1922 | |
| 1923 | if (entry.isDirectory()) { |
| 1924 | const subFiles = await findFilesRecursive(fullPath); |
| 1925 | files.push(...subFiles); |
| 1926 | } else if (entry.isFile()) { |
| 1927 | // Check if file matches include pattern |
| 1928 | if (micromatch.isMatch(relativePath, include)) { |
| 1929 | // Check if file matches exclude pattern |
| 1930 | if (!exclude || !micromatch.isMatch(relativePath, exclude)) { |
| 1931 | files.push(fullPath); |
| 1932 | } |
| 1933 | } |
| 1934 | } |
| 1935 | } |
| 1936 | } catch (error) { |
| 1937 | // Ignore errors accessing directories |
| 1938 | } |
| 1939 | |
| 1940 | return files; |
| 1941 | }; |
| 1942 | |
| 1943 | try { |
| 1944 | const files = await findFilesRecursive(workspaceFolder.uri.fsPath); |
| 1945 | |
| 1946 | let result = files.map(file => createVSCodeUri(URI.file(file))); |
| 1947 | |
| 1948 | if (maxResults && result.length > maxResults) { |
| 1949 | result = result.slice(0, maxResults); |
| 1950 | } |
| 1951 | |
| 1952 | return result; |
| 1953 | } catch (error) { |
| 1954 | return []; |
| 1955 | } |
| 1956 | }, |
nothing calls this directly
no test coverage detected