/**
   * TODO: option - create via IDEA or via java.io. In latter case no need in Project parameter.
   * Creates directory inside a write action and returns the resulting reference to it.
   * If the directory already exists, does nothing.
   * @param parent Parent directory.
   * @param name   Name of the directory.
   * @return reference to the created or already existing directory.
   */
public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
    final Ref<VirtualFile> result = new Ref<VirtualFile>();
    new WriteCommandAction.Simple(project) {
      @Override
      protected void run() throws Throwable {
        try {
          VirtualFile dir = parent.findChild(name);
          if (dir == null) {
            dir = parent.createChildDirectory(this, name);
          }
          result.set(dir);
        }
        catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    }.execute();
    return result.get();
  }
public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
}
public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
}
public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
}