Java Code Examples for com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil#findAll()

The following examples show how to use com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil#findAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PantsResolverTestBase.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
public void assertSourceRoot(String moduleName, final String path) {
  final DataNode<ModuleData> moduleNode = findModule(moduleName);
  assertModuleExists(moduleName, moduleNode);
  final Collection<DataNode<ContentRootData>> contentRoots = ExternalSystemApiUtil.findAll(moduleNode, ProjectKeys.CONTENT_ROOT);
  assertFalse(String.format("No content root for module %s", moduleName), contentRoots.isEmpty());
  for (DataNode<ContentRootData> contentRoot : contentRoots) {
    final ContentRootData contentRootData = contentRoot.getData();
    for (PantsSourceType type : PantsSourceType.values()) {
      for (ContentRootData.SourceRoot sourceRoot : contentRootData.getPaths(type.toExternalSystemSourceType())) {
        final File expectedFile = new File(new File(""), path);
        if (StringUtil.equalsIgnoreCase(expectedFile.getPath(), sourceRoot.getPath())) {
          return;
        }
      }
    }
  }
  fail(String.format("Source root %s is not found for %s!", path, moduleName));
}
 
Example 2
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
private boolean containsContentRoot(@NotNull DataNode<ProjectData> projectDataNode, @NotNull String path) {
  for (DataNode<ModuleData> moduleDataNode : ExternalSystemApiUtil.findAll(projectDataNode, ProjectKeys.MODULE)) {
    for (DataNode<ContentRootData> contentRootDataNode : ExternalSystemApiUtil.findAll(moduleDataNode, ProjectKeys.CONTENT_ROOT)) {
      final ContentRootData contentRootData = contentRootDataNode.getData();
      if (FileUtil.isAncestor(contentRootData.getRootPath(), path, false)) {
        return true;
      }
    }
  }

  return false;
}
 
Example 3
Source File: PantsResolverTestBase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public void assertNoContentRoot(String moduleName) {
  final DataNode<ModuleData> moduleNode = findModule(moduleName);
  assertModuleExists(moduleName, moduleNode);
  final Collection<DataNode<ContentRootData>> contentRoots = ExternalSystemApiUtil.findAll(moduleNode, ProjectKeys.CONTENT_ROOT);
  for (DataNode<ContentRootData> contentRoot : contentRoots) {
    assertNull(
      String
        .format("Content root %s is defined for module %s", contentRoot.getData().getRootPath(), moduleName),
      contentRoot
    );
  }
}
 
Example 4
Source File: PantsResolverTestBase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public void assertContentRoots(String moduleName, String... roots) {
  final DataNode<ModuleData> moduleNode = findModule(moduleName);
  assertModuleExists(moduleName, moduleNode);
  final Collection<DataNode<ContentRootData>> contentRoots = ExternalSystemApiUtil.findAll(moduleNode, ProjectKeys.CONTENT_ROOT);
  final List<String> actualRootPaths = contentRoots.stream().map(s -> s.getData().getRootPath()).collect(Collectors.toList());
  List<String> expected = Arrays.asList(roots);
  Collections.sort(expected);
  Collections.sort(actualRootPaths);
  assertEquals("Content roots", expected, actualRootPaths);
}
 
Example 5
Source File: PantsResolverTestBase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
private DataNode<ModuleData> findModule(final String moduleName) {
  final Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(getProjectNode(), ProjectKeys.MODULE);
  return moduleNodes.stream()
    .filter(node -> StringUtil.equalsIgnoreCase(moduleName, node.getData().getExternalName()))
    .findFirst()
    .orElse(null);
}
 
Example 6
Source File: PantsResolverTestBase.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public void assertModulesCreated(final String... expectedModules) {
  final Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(getProjectNode(), ProjectKeys.MODULE);
  final Set<String> actualModules = moduleNodes.stream().map(n -> n.getData().getExternalName()).collect(Collectors.toSet());
  assertEquals(Arrays.stream(expectedModules).collect(Collectors.toSet()), actualModules);
}