Search in sources :

Example 6 with NullableComputable

use of com.intellij.openapi.util.NullableComputable in project intellij-plugins by JetBrains.

the class FlexModuleBuilder method createSourceRoot.

@Nullable
private VirtualFile createSourceRoot(final ContentEntry contentEntry) {
    final VirtualFile contentRoot = contentEntry.getFile();
    if (contentRoot == null)
        return null;
    VirtualFile sourceRoot = VfsUtil.findRelativeFile(contentRoot, "src");
    if (sourceRoot == null) {
        sourceRoot = ApplicationManager.getApplication().runWriteAction(new NullableComputable<VirtualFile>() {

            public VirtualFile compute() {
                try {
                    return contentRoot.createChildDirectory(this, "src");
                } catch (IOException e) {
                    return null;
                }
            }
        });
    }
    if (sourceRoot != null) {
        contentEntry.addSourceFolder(sourceRoot, false);
        return sourceRoot;
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NullableComputable(com.intellij.openapi.util.NullableComputable) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

NullableComputable (com.intellij.openapi.util.NullableComputable)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Nullable (org.jetbrains.annotations.Nullable)3 ProjectRootManager (com.intellij.openapi.roots.ProjectRootManager)2 PsiFile (com.intellij.psi.PsiFile)2 PackageWrapper (com.intellij.refactoring.PackageWrapper)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 Project (com.intellij.openapi.project.Project)1 AtomicNotNullLazyValue (com.intellij.openapi.util.AtomicNotNullLazyValue)1 RecursionGuard (com.intellij.openapi.util.RecursionGuard)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PsiElementVisitor (com.intellij.psi.PsiElementVisitor)1 XmlElementType (com.intellij.psi.xml.XmlElementType)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 EvaluatedXmlName (com.intellij.util.xml.EvaluatedXmlName)1 EvaluatedXmlNameImpl (com.intellij.util.xml.EvaluatedXmlNameImpl)1 XmlName (com.intellij.util.xml.XmlName)1 CustomDomChildrenDescription (com.intellij.util.xml.reflect.CustomDomChildrenDescription)1