resolveInWorkspace function
path — absolute, or relative to base — resolved under rootPath's path
rules (idePathContext), or null when it falls outside rootPath (the
IDE's sandbox for the agent's and the tree's paths). A Windows
drive-relative path (C:x, relative to a drive's own current directory,
which the IDE cannot know) is refused too.
Implementation
String? resolveInWorkspace(String rootPath, String base, String path) {
final paths = idePathContext(rootPath);
if (paths.style == p.Style.windows && _driveRelative.hasMatch(path)) {
return null;
}
final root = normalizeIdePath(paths, rootPath);
final abs = normalizeIdePath(
paths,
paths.isAbsolute(path) ? path : paths.join(base, path),
);
return paths.equals(abs, root) || paths.isWithin(root, abs) ? abs : null;
}