String (@NotNull String path, @NotNull DataContext fallbackDataContext, boolean applyParameterEscaping) { if (!Registry.is("allow.macros.for.run.configurations")) { return path; } DataContext context = createContext(fallbackDataContext); for (Macro macro : MacroManager.getInstance().getMacros()) { boolean paramsMacro = macro instanceof MacroWithParams; String template = "$" + macro.getName() + (paramsMacro ? "(" : "$"); for (int index = path.indexOf(template); index != -1 && index < path.length() + template.length(); index = path.indexOf(template, index)) { String value; int tailIndex; if (paramsMacro) { int endIndex = path.indexOf(")$", index + template.length()); if (endIndex != -1) { value = StringUtil.notNullize(previewOrExpandMacro(macro, context, path.substring(index + template.length(), endIndex))); tailIndex = endIndex + 2; } else { //noinspection AssignmentToForLoopParameter index += template.length(); continue; } } else { tailIndex = index + template.length(); value = StringUtil.notNullize(previewOrExpandMacro(macro, context)); } if (applyParameterEscaping) { value = ParametersListUtil.escape(value); } path = path.substring(0, index) + value + path.substring(tailIndex); //noinspection AssignmentToForLoopParameter index += value.length(); } } return path; }