Java 类com.intellij.psi.PsiDirectoryContainer 实例源码

项目:intellij-ce-playground    文件:VirtualFileArrayRule.java   
private static Set<VirtualFile> addFilesFromPsiElement(Set<VirtualFile> files, @NotNull PsiElement elem) {
  if (elem instanceof PsiDirectory) {
    files = addFile(files, ((PsiDirectory)elem).getVirtualFile());
  }
  else if (elem instanceof PsiFile) {
    files = addFile(files, ((PsiFile)elem).getVirtualFile());
  }
  else if (elem instanceof PsiDirectoryContainer) {
    for (PsiDirectory dir : ((PsiDirectoryContainer)elem).getDirectories()) {
      files = addFile(files, dir.getVirtualFile());
    }
  }
  else {
    PsiFile file = elem.getContainingFile();
    if (file != null) {
      files = addFile(files, file.getVirtualFile());
    }
  }
  return files;
}
项目:tools-idea    文件:VirtualFileArrayRule.java   
private static Set<VirtualFile> addFilesFromPsiElement(Set<VirtualFile> files, @NotNull PsiElement elem) {
  if (elem instanceof PsiDirectory) {
    files = addFile(files, ((PsiDirectory)elem).getVirtualFile());
  }
  else if (elem instanceof PsiFile) {
    files = addFile(files, ((PsiFile)elem).getVirtualFile());
  }
  else if (elem instanceof PsiDirectoryContainer) {
    for (PsiDirectory dir : ((PsiDirectoryContainer)elem).getDirectories()) {
      files = addFile(files, dir.getVirtualFile());
    }
  }
  else {
    PsiFile file = elem.getContainingFile();
    if (file != null) {
      files = addFile(files, file.getVirtualFile());
    }
  }
  return files;
}
项目:intellij-ce-playground    文件:FindInPathAction.java   
private static boolean isValidSearchScope(AnActionEvent e) {
  final PsiElement[] elements = e.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  if (elements != null && elements.length == 1 && elements[0] instanceof PsiDirectoryContainer) {
    return true;
  }
  final VirtualFile[] virtualFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  return virtualFiles != null && virtualFiles.length == 1 && virtualFiles[0].isDirectory();
}
项目:intellij-ce-playground    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    } else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    } else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        } else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:intellij-ce-playground    文件:DirectoryAsPackageRenameHandlerBase.java   
private static PsiElement adjustForRename(DataContext dataContext, PsiElement element) {
  if (element instanceof PsiDirectoryContainer) {
    final Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module != null) {
      final PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories(GlobalSearchScope.moduleScope(module));
      if (directories.length >= 1) {
        element = directories[0];
      }
    }
  }
  return element;
}
项目:tools-idea    文件:FindInPathAction.java   
private static boolean isValidSearchScope(AnActionEvent e) {
  final PsiElement[] elements = e.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  if (elements != null && elements.length == 1 && elements[0] instanceof PsiDirectoryContainer) {
    return true;
  }
  final VirtualFile[] virtualFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
  return virtualFiles != null && virtualFiles.length == 1 && virtualFiles[0].isDirectory();
}
项目:tools-idea    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    } else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    } else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        } else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:tools-idea    文件:DirectoryAsPackageRenameHandlerBase.java   
private static PsiElement adjustForRename(DataContext dataContext, PsiElement element) {
  if (element instanceof PsiDirectoryContainer) {
    final Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module != null) {
      final PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories(GlobalSearchScope.moduleScope(module));
      if (directories.length >= 1) {
        element = directories[0];
      }
    }
  }
  return element;
}
项目:consulo    文件:FindInPathAction.java   
private static boolean isValidSearchScope(AnActionEvent e) {
  final PsiElement[] elements = e.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  if (elements != null && elements.length == 1 && elements[0] instanceof PsiDirectoryContainer) {
    return true;
  }
  final VirtualFile[] virtualFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  return virtualFiles != null && virtualFiles.length == 1 && virtualFiles[0].isDirectory();
}
项目:consulo    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @Nonnull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    }
    else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    }
    else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        }
        else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:consulo    文件:DirectoryAsPackageRenameHandlerBase.java   
private static PsiElement adjustForRename(DataContext dataContext, PsiElement element) {
  if (element instanceof PsiDirectoryContainer) {
    final Module module = dataContext.getData(LangDataKeys.MODULE);
    if (module != null) {
      final PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories(GlobalSearchScope.moduleScope(module));
      if (directories.length >= 1) {
        element = directories[0];
      }
    }
  }
  return element;
}
项目:intellij-ce-playground    文件:PsiDirectoryFactoryImpl.java   
@Override
public PsiDirectoryContainer getDirectoryContainer(@NotNull PsiDirectory directory) {
  return null;
}
项目:intellij-ce-playground    文件:PsiDirectoryFactory.java   
@Nullable
public abstract PsiDirectoryContainer getDirectoryContainer(@NotNull PsiDirectory directory);
项目:tools-idea    文件:PsiDirectoryFactoryImpl.java   
@Override
public PsiDirectoryContainer getDirectoryContainer(@NotNull PsiDirectory directory) {
  return null;
}
项目:tools-idea    文件:PsiDirectoryFactory.java   
@Nullable
public abstract PsiDirectoryContainer getDirectoryContainer(@NotNull PsiDirectory directory);
项目:consulo    文件:PsiPackageHelperImpl.java   
@Override
public PsiDirectoryContainer getDirectoryContainer(@Nonnull PsiDirectory directory) {
  return PsiPackageManager.getInstance(myManager.getProject()).findAnyPackage(directory);
}
项目:consulo    文件:PsiPackageHelper.java   
@Nullable
public abstract PsiDirectoryContainer getDirectoryContainer(@Nonnull PsiDirectory directory);
项目:consulo-javascript    文件:JSPsiImplUtils.java   
static
@Nullable
String getQNameForMove(@NotNull PsiElement targetElement, PsiElement elementToBind)
{
    String qName = null;
    Project project = targetElement.getProject();

    if(elementToBind instanceof PsiFile)
    {
        String newName = ((PsiNamedElement) elementToBind).getName();
        int index = newName.lastIndexOf('.');
        if(index != -1)
        {
            newName = newName.substring(0, index);
        }
        VirtualFile elementToBindFile = elementToBind.getContainingFile().getVirtualFile();

        String packageName = JSResolveUtil.getExpectedPackageNameFromFile(elementToBindFile, project, false);

        if(targetElement instanceof JSReferenceExpression)
        {
            JSExpression qualifier = ((JSReferenceExpression) targetElement).getQualifier();
            String targetElementPackageName = qualifier != null ? qualifier.getText() : JSResolveUtil.getExpectedPackageNameFromFile(targetElement.getContainingFile().getVirtualFile(), project,
                    false);
            if(!differentPackageName(targetElementPackageName, packageName))
            {
                return null;
            }
            if(qualifier == null)
            {
                if(!(targetElement.getParent() instanceof JSImportStatement))
                {
                    return null;
                }
            }
        }

        qName = packageName.isEmpty() ? newName : packageName + "." + newName;
    }
    else if(elementToBind instanceof PsiDirectoryContainer)
    {
        PsiDirectory[] directories = ((PsiDirectoryContainer) elementToBind).getDirectories(targetElement.getResolveScope());
        if(directories.length > 0)
        {
            qName = JSResolveUtil.getExpectedPackageNameFromFile(directories[0].getVirtualFile(), project, false);
        }
    }
    return qName;
}