void (ReplacePathToMacroMap result, String macroName, @Nullable String path, @Nullable String stopAt) { if (path == null) return; String macro = '$' + macroName + '$'; path = Strings.trimEnd(FileUtilRt.toSystemIndependentName(path), "/"); boolean overwrite = true; while (Strings.isNotEmpty(path) && path.contains("/") && !"/".equals(path)) { result.addReplacement(path, macro, overwrite); if (path.equals(stopAt)) break; macro += "/.."; path = OSAgnosticPathUtil.getParent(path); overwrite = false; } }