PathFromRoot (@NotNull NewVirtualFileSystem vfs, @NotNull String path) { String normalizedPath = vfs.normalize(path); if (normalizedPath == null || normalizedPath.isBlank()) { return null; } String rootPath = vfs.extractRootPath(normalizedPath); if (rootPath.isBlank() || rootPath.length() > normalizedPath.length()) { LOG.warn(vfs + " has extracted incorrect root '" + rootPath + "' from '" + normalizedPath + "' (original '" + path + "')"); return null; } NewVirtualFile root = ManagingFS.getInstance().findRoot(rootPath, vfs); if (root == null || !root.exists()) { return null; } int restPathStart = rootPath.length(); if (restPathStart < normalizedPath.length() && normalizedPath.charAt(restPathStart) == '/') restPathStart++; return new PathFromRoot(root, normalizedPath.substring(restPathStart)); }