Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private removeFromDirectoriesByDirPath(dirPath: string) {
if (FileUtils.isRootDirPath(dirPath))
return;
const parentDirPath = FileUtils.getDirPath(dirPath);
const directories = this.directoriesByDirPath.get(parentDirPath);
if (directories == null)
return;
directories.removeByKey(FileUtils.getBaseName(dirPath));
// clean up
if (!directories.hasItems())
this.directoriesByDirPath.removeByKey(parentDirPath);
}
function* getAncestorsUpToOneInProject(dir: Directory): IterableIterator {
if (FileUtils.isRootDirPath(dir.getPath()))
return;
const parentDirPath = FileUtils.getDirPath(dir.getPath());
const parentDir = compilerFactory.getDirectoryFromCacheOnlyIfInCache(parentDirPath);
if (parentDir == null)
return;
yield parentDir;
if (!inProjectCoordinator.isDirectoryInProject(parentDir))
yield* getAncestorsUpToOneInProject(parentDir);
}
}
private addToDirectoriesByDirPath(directory: Directory) {
if (FileUtils.isRootDirPath(directory.getPath()))
return;
const parentDirPath = FileUtils.getDirPath(directory.getPath());
const directories = this.directoriesByDirPath.getOrCreate(parentDirPath,
() => new SortedKeyValueArray(item => item.getBaseName(), LocaleStringComparer.instance));
directories.set(directory);
}