"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateExclusionFunctionForUri = exports.pathToUri = exports.extractGlobsFromExcludeFilesGlobMap = void 0; const vscode_uri_1 = require("vscode-uri"); const minimatch = __importStar(require("minimatch")); const separator = '/'; const defaultAllowedSchemes = new Set(['file', 'untitled']); function extractGlobsFromExcludeFilesGlobMap(globMap) { const globs = Object.getOwnPropertyNames(globMap).filter((glob) => globMap[glob]); return globs; } exports.extractGlobsFromExcludeFilesGlobMap = extractGlobsFromExcludeFilesGlobMap; function pathToUri(filePath) { return vscode_uri_1.URI.file(filePath); } exports.pathToUri = pathToUri; function generateExclusionFunctionForUri(globs, root, allowedSchemes = defaultAllowedSchemes) { const rootUri = pathToUri(root || '/'); const fns = globs.map((glob) => minimatch.filter(glob, { matchBase: true })); function testPath(path) { return fns.reduce((prev, fn, idx) => prev || fn(path, idx, [path]), false); } function testPathStepByStep(path) { const parts = path.split(separator); for (let i = 0; i < parts.length; ++i) { const p = parts.slice(0, i + 1).join(separator); if (testPath(p)) { return true; } } return false; } function testUri(uri) { if (!allowedSchemes.has(uri.scheme)) { return true; } const relativeRoot = uri.path.slice(0, rootUri.path.length); if (relativeRoot === rootUri.path) { const relativeToRoot = uri.path.slice(rootUri.path.length); return testPathStepByStep(relativeToRoot); } // the uri is not relative to the root. return testPathStepByStep(uri.path); } function testUriPath(uriPath) { const uri = vscode_uri_1.URI.parse(uriPath); return testUri(uri); } return testUriPath; } exports.generateExclusionFunctionForUri = generateExclusionFunctionForUri; //# sourceMappingURL=exclusionHelper.js.map