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


Java ContentEntry.getSourceFolders方法代码示例

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


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

示例1: suitableTestSourceFolders

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Nullable
private static SourceFolder suitableTestSourceFolders(Project project, Module module) {
  ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
  for (ContentEntry contentEntry : contentEntries) {
    List<SourceFolder> testSourceFolders =
        contentEntry.getSourceFolders(JavaSourceRootType.TEST_SOURCE);
    for (SourceFolder testSourceFolder : testSourceFolders) {
      if (testSourceFolder.getFile() != null) {
        if (!JavaProjectRootsUtil.isInGeneratedCode(testSourceFolder.getFile(), project)) {
          return testSourceFolder;
        }
      }
    }
  }

  return null;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:18,代码来源:GenerateAction.java

示例2: getSourceFolders

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private List<VirtualFile> getSourceFolders() {
  ModuleRootManager rootManager = ModuleRootManager.getInstance(getValue());
  List<VirtualFile> folders = Lists.newArrayList();

  ContentEntry[] contentEntries = rootManager.getContentEntries();
  for (ContentEntry entry : contentEntries) {
    List<SourceFolder> sources = entry.getSourceFolders(mySourceType.rootType);
    for (SourceFolder folder : sources) {
      VirtualFile file = folder.getFile();
      if (file != null) {
        folders.add(file);
      }
    }
  }

  return folders;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:NonAndroidSourceTypeNode.java

示例3: getNonEmptySourceTypes

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static Set<NonAndroidSourceType> getNonEmptySourceTypes(Module module) {
  ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  Set<NonAndroidSourceType> sourceTypes = Sets.newHashSetWithExpectedSize(NonAndroidSourceType.values().length);

  ContentEntry[] contentEntries = rootManager.getContentEntries();
  for (ContentEntry entry : contentEntries) {
    for (NonAndroidSourceType type : NonAndroidSourceType.values()) {
      for (SourceFolder sourceFolder : entry.getSourceFolders(type.rootType)) {
        if (sourceFolder.getFile() != null) {
          sourceTypes.add(type);
          break;
        }
      }
    }
  }

  return sourceTypes;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NonAndroidModuleNode.java

示例4: createSourceRootIfAbsent

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static void createSourceRootIfAbsent(
  @NotNull ContentEntry entry, @NotNull final SourceRoot root, @NotNull String moduleName,
  @NotNull JpsModuleSourceRootType<?> sourceRootType, boolean generated, boolean createEmptyContentRootDirectories) {
  List<SourceFolder> folders = entry.getSourceFolders(sourceRootType);
  for (SourceFolder folder : folders) {
    VirtualFile file = folder.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
      return;
    }
  }
  LOG.debug(String.format("Importing %s for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
  SourceFolder sourceFolder = entry.addSourceFolder(toVfsUrl(root.getPath()), sourceRootType);
  if (!StringUtil.isEmpty(root.getPackagePrefix())) {
    sourceFolder.setPackagePrefix(root.getPackagePrefix());
  }
  if (generated) {
    JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    if(properties != null) {
      properties.setForGeneratedSources(true);
    }
  }
  if(createEmptyContentRootDirectories) {
    ExternalSystemApiUtil.doWriteAction(new Runnable() {
      @Override
      public void run() {
        try {
          VfsUtil.createDirectoryIfMissing(root.getPath());
        }
        catch (IOException e) {
          LOG.warn(String.format("Unable to create directory for the path: %s", root.getPath()), e);
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ContentRootDataService.java

示例5: getPresentablePrefix

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static String getPresentablePrefix(final ContentEntry entry, final VirtualFile file) {
  for (final SourceFolder sourceFolder : entry.getSourceFolders()) {
    if (file.equals(sourceFolder.getFile())) {
      JpsModuleSourceRoot element = sourceFolder.getJpsElement();
      JavaSourceRootProperties properties = element.getProperties(JavaModuleSourceRootTypes.SOURCES);
      if (properties != null) return properties.getPackagePrefix();
      JavaResourceRootProperties resourceRootProperties = element.getProperties(JavaModuleSourceRootTypes.RESOURCES);
      if (resourceRootProperties != null) return resourceRootProperties.getRelativeOutputPath();
    }
  }
  return "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ContentEntryTreeCellRenderer.java

示例6: findSourceFolder

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Nullable
private static SourceFolder findSourceFolder(ContentEntry entry, VirtualFile file) {
  for (SourceFolder sourceFolder : entry.getSourceFolders()) {
    if (file.equals(sourceFolder.getFile())) {
      return sourceFolder;
    }
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:10,代码来源:JavaSyncTest.java


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