Path (@NotNull String path) { Path root; int startIndex; if (path.startsWith(PROJECT_DIR_MACRO)) { root = getProjectDirPath(); startIndex = PROJECT_DIR_MACRO.length(); } else if (path.startsWith(MAVEN_REPO_MACRO)) { root = getMavenRepositoryPath(); startIndex = MAVEN_REPO_MACRO.length(); } else { throw new MalformedRepositoryException("Unknown macro in " + path); } if (path.length() <= startIndex + 1 || path.charAt(startIndex) != '/') { throw new MalformedRepositoryException("Incorrect macro usage in " + path); } if (path.contains("/../") || path.endsWith("/..")) { throw new MalformedRepositoryException("Path '" + path + "' points to a file outside macro directory"); } return root.resolve(path.substring(startIndex + 1)); }