当前位置: 首页>>代码示例>>Java>>正文


Java ProjectFileIndex.getPackageNameByDirectory方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.ProjectFileIndex.getPackageNameByDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectFileIndex.getPackageNameByDirectory方法的具体用法?Java ProjectFileIndex.getPackageNameByDirectory怎么用?Java ProjectFileIndex.getPackageNameByDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.ProjectFileIndex的用法示例。


在下文中一共展示了ProjectFileIndex.getPackageNameByDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPackage

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public PsiPackage getPackage(@NotNull PsiDirectory dir) {
  ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(dir.getProject()).getFileIndex();
  String packageName = projectFileIndex.getPackageNameByDirectory(dir.getVirtualFile());
  if (packageName == null) return null;
  return JavaPsiFacade.getInstance(dir.getProject()).findPackage(packageName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JavaDirectoryServiceImpl.java

示例2: createCopyTask

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static Generator createCopyTask(final Project project,
                                        ModuleChunk chunk,
                                        VirtualFile[] sourceRoots,
                                        String toDir,
                                        File baseDir,
                                        final GenerationOptions genOptions) {
  //noinspection HardCodedStringLiteral
  final Tag filesSelector = new Tag("type", Couple.of("type", "file"));
  final PatternSetRef excludes = CompilerExcludes.isAvailable(project) ? new PatternSetRef(
    BuildProperties.getExcludedFromCompilationProperty(chunk.getName())) : null;
  final PatternSetRef resourcePatternsPatternSet = new PatternSetRef(BuildProperties.PROPERTY_COMPILER_RESOURCE_PATTERNS);
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  final CompositeGenerator composite = new CompositeGenerator();
  final Map<String, Copy> outputDirToTaskMap = new HashMap<String, Copy>();
  for (final VirtualFile root : sourceRoots) {
    final String packagePrefix = fileIndex.getPackageNameByDirectory(root);
    final String targetDir =
      packagePrefix != null && packagePrefix.length() > 0 ? toDir + "/" + packagePrefix.replace('.', '/') : toDir;
    Copy copy = outputDirToTaskMap.get(targetDir);
    if (copy == null) {
      copy = new Copy(targetDir);
      outputDirToTaskMap.put(targetDir, copy);
      composite.add(copy);
    }
    final FileSet fileSet = new FileSet(
      GenerationUtils.toRelativePath(root, baseDir, BuildProperties.getModuleChunkBasedirProperty(chunk), genOptions));
    fileSet.add(resourcePatternsPatternSet);
    fileSet.add(filesSelector);
    if (excludes != null) {
      fileSet.add(excludes);
    }
    copy.add(fileSet);
  }
  return composite;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:CompileModuleChunkTarget.java

示例3: getPackage

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
public static String getPackage(@NotNull PsiDirectory directory) {
  final VirtualFile virtualFile = directory.getVirtualFile();
  final Project project = directory.getProject();
  final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
  final ProjectFileIndex fileIndex = projectRootManager.getFileIndex();
  return fileIndex.getPackageNameByDirectory(virtualFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PackageDotHtmlMayBePackageInfoInspectionBase.java

示例4: isPackage

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean isPackage(@NotNull PsiDirectory directory) {
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myManager.getProject()).getFileIndex();
  VirtualFile virtualFile = directory.getVirtualFile();
  return fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES) && fileIndex.getPackageNameByDirectory(virtualFile) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PsiJavaDirectoryFactory.java


注:本文中的com.intellij.openapi.roots.ProjectFileIndex.getPackageNameByDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。