How do I create a package with out user dialog?

Whats the best api call for creating a Java package?

Using this causes an user dialog:
PsiDirectory psiDir = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, baseDir, false, false);


Comment actions Permalink

In order to create a package you need to create a directory somethere. If you don't want to ask user about that you need to somehow decide where you
want to create the directory, then use PsiDirectory#createSubdirectory method to create it and JavaDirectoryService#getPackage to get a package for
the created directory.

Nikolay Chashnikov
Software Developer
"Develop with pleasure!"

Comment actions Permalink

While you said makes sense because a package is a list of directories, it would be nice to use a utility to create a package, since it seems the open api doesn't have one I'll create my own package maker then. But maybe I'm missing something. Compared to Eclipse creating a package seems laborious so far.

Eclipse has a simple method of creating a package, that is when I want to talk in java talk, packages instead of directories.

createdPackage = selectedPackageRoot.createPackageFragment(packageName, forceWriting, progressMonitor);

Do you think there is a method like the Eclipse method or is that a feature request?



Please sign in to leave a comment.