com.intellij.openapi.externalSystem.model.Key Java Examples

The following examples show how to use com.intellij.openapi.externalSystem.model.Key. 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: ProjectDataManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> void importData(@Nonnull Key<T> key, @Nonnull Collection<DataNode<T>> nodes, @Nonnull Project project, boolean synchronous) {
  ensureTheDataIsReadyToUse(nodes);
  List<ProjectDataService<?, ?>> services = myServices.getValue().get(key);
  if (services == null) {
    LOG.warn(String.format(
      "Can't import data nodes '%s'. Reason: no service is registered for key %s. Available services for %s",
      nodes, key, myServices.getValue().keySet()
    ));
  }
  else {
    for (ProjectDataService<?, ?> service : services) {
      ((ProjectDataService<T, ?>)service).importData(nodes, project, synchronous);
    }
  }

  Collection<DataNode<?>> children = ContainerUtilRt.newArrayList();
  for (DataNode<T> node : nodes) {
    children.addAll(node.getChildren());
  }
  importData(children, project, synchronous);
}
 
Example #2
Source File: ProjectDataManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> void ensureTheDataIsReadyToUse(@Nonnull Collection<DataNode<T>> nodes) {
  Map<Key<?>, List<ProjectDataService<?, ?>>> servicesByKey = myServices.getValue();
  Stack<DataNode<T>> toProcess = ContainerUtil.newStack(nodes);
  while (!toProcess.isEmpty()) {
    DataNode<T> node = toProcess.pop();
    List<ProjectDataService<?, ?>> services = servicesByKey.get(node.getKey());
    if (services != null) {
      for (ProjectDataService<?, ?> service : services) {
        node.prepareData(service.getClass().getClassLoader());
      }
    }

    for (DataNode<?> dataNode : node.getChildren()) {
      toProcess.push((DataNode<T>)dataNode);
    }
  }
}
 
Example #3
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nonnull
public static <T> Collection<DataNode<T>> getChildren(@Nonnull DataNode<?> node, @Nonnull Key<T> key) {
  Collection<DataNode<T>> result = null;
  for (DataNode<?> child : node.getChildren()) {
    if (!key.equals(child.getKey())) {
      continue;
    }
    if (result == null) {
      result = ContainerUtilRt.newArrayList();
    }
    result.add((DataNode<T>)child);
  }
  return result == null ? Collections.<DataNode<T>>emptyList() : result;
}
 
Example #4
Source File: ProjectDataManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> void importData(@Nonnull Collection<DataNode<?>> nodes, @Nonnull Project project, boolean synchronous) {
  Map<Key<?>, List<DataNode<?>>> grouped = ExternalSystemApiUtil.group(nodes);
  for (Map.Entry<Key<?>, List<DataNode<?>>> entry : grouped.entrySet()) {
    // Simple class cast makes ide happy but compiler fails.
    Collection<DataNode<T>> dummy = ContainerUtilRt.newArrayList();
    for (DataNode<?> node : entry.getValue()) {
      dummy.add((DataNode<T>)node);
    }
    importData((Key<T>)entry.getKey(), dummy, project, synchronous);
  }
}
 
Example #5
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nonnull
public static <T> Collection<DataNode<T>> findAll(@Nonnull DataNode<?> parent, @Nonnull Key<T> key) {
  Collection<DataNode<T>> result = null;
  for (DataNode<?> child : parent.getChildren()) {
    if (!key.equals(child.getKey())) {
      continue;
    }
    if (result == null) {
      result = ContainerUtilRt.newArrayList();
    }
    result.add((DataNode<T>)child);
  }
  return result == null ? Collections.<DataNode<T>>emptyList() : result;
}
 
Example #6
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@javax.annotation.Nullable
public static <T> DataNode<T> findParent(@Nonnull DataNode<?> node, @Nonnull Key<T> key, @Nullable BooleanFunction<DataNode<T>> predicate) {
  DataNode<?> parent = node.getParent();
  if (parent == null) return null;
  return key.equals(parent.getKey()) && (predicate == null || predicate.fun((DataNode<T>)parent)) ? (DataNode<T>)parent : findParent(parent, key, predicate);
}
 
Example #7
Source File: ProjectDataManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T> void removeData(@Nonnull Key<?> key, @Nonnull Collection<T> toRemove, @Nonnull Project project, boolean synchronous) {
  List<ProjectDataService<?, ?>> services = myServices.getValue().get(key);
  for (ProjectDataService<?, ?> service : services) {
    ((ProjectDataService<?, T>)service).removeData(toRemove, project, synchronous);
  }
}
 
Example #8
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@javax.annotation.Nullable
public static <T> DataNode<T> find(@Nonnull DataNode<?> node, @Nonnull Key<T> key, BooleanFunction<DataNode<T>> predicate) {
  for (DataNode<?> child : node.getChildren()) {
    if (key.equals(child.getKey()) && predicate.fun((DataNode<T>)child)) {
      return (DataNode<T>)child;
    }
  }
  return null;
}
 
Example #9
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@javax.annotation.Nullable
public static <T> DataNode<T> find(@Nonnull DataNode<?> node, @Nonnull Key<T> key) {
  for (DataNode<?> child : node.getChildren()) {
    if (key.equals(child.getKey())) {
      return (DataNode<T>)child;
    }
  }
  return null;
}
 
Example #10
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static <K, V> Map<DataNode<K>, List<DataNode<V>>> groupBy(@Nonnull Collection<DataNode<V>> nodes, @Nonnull final Key<K> key) {
  return groupBy(nodes, new NullableFunction<DataNode<V>, DataNode<K>>() {
    @Nullable
    @Override
    public DataNode<K> fun(DataNode<V> node) {
      return node.getDataNode(key);
    }
  });
}
 
Example #11
Source File: PantsUtil.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
public static <T> List<T> findChildren(@NotNull DataNode<?> dataNode, @NotNull Key<T> key) {
  return ContainerUtil.mapNotNull(
    ExternalSystemApiUtil.findAll(dataNode, key),
    new Function<DataNode<T>, T>() {
      @Override
      public T fun(DataNode<T> node) {
        return node.getData();
      }
    }
  );
}
 
Example #12
Source File: ToolWindowModuleService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ModuleData> getTargetDataKey() {
  return ProjectKeys.MODULE;
}
 
Example #13
Source File: ProjectDataServiceImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ProjectData> getTargetDataKey() {
  return ProjectKeys.PROJECT;
}
 
Example #14
Source File: ModuleDataService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ModuleData> getTargetDataKey() {
  return ProjectKeys.MODULE;
}
 
Example #15
Source File: LibraryDataService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<LibraryData> getTargetDataKey() {
  return ProjectKeys.LIBRARY;
}
 
Example #16
Source File: LibraryDependencyDataService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<LibraryDependencyData> getTargetDataKey() {
  return ProjectKeys.LIBRARY_DEPENDENCY;
}
 
Example #17
Source File: ToolWindowTaskService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<TaskData> getTargetDataKey() {
  return ProjectKeys.TASK;
}
 
Example #18
Source File: QuarkusProjectDataService.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@NotNull
@Override
public Key<LibraryDependencyData> getTargetDataKey() {
    return ProjectKeys.LIBRARY_DEPENDENCY;
}
 
Example #19
Source File: ContentRootDataService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ContentRootData> getTargetDataKey() {
  return ProjectKeys.CONTENT_ROOT;
}
 
Example #20
Source File: ModuleDependencyDataService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<ModuleDependencyData> getTargetDataKey() {
  return ProjectKeys.MODULE_DEPENDENCY;
}
 
Example #21
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
public static <T> DataNode<T> findParent(@Nonnull DataNode<?> node, @Nonnull Key<T> key) {
  return findParent(node, key, null);
}
 
Example #22
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static Map<Key<?>, List<DataNode<?>>> group(@Nonnull Collection<DataNode<?>> nodes) {
  return groupBy(nodes, GROUPER);
}
 
Example #23
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Key<?> fun(DataNode<?> node) {
  return node.getKey();
}
 
Example #24
Source File: PantsPythonSetupDataService.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Key<PythonSetupData> getTargetDataKey() {
  return PythonSetupData.KEY;
}
 
Example #25
Source File: PantsMetadataService.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Key<TargetMetadata> getTargetDataKey() {
  return TargetMetadata.KEY;
}
 
Example #26
Source File: GradleReindexingProjectDataService.java    From intellij-spring-assistant with MIT License 4 votes vote down vote up
@NotNull
@Override
public Key<ModuleData> getTargetDataKey() {
  return ProjectKeys.MODULE;
}
 
Example #27
Source File: ProjectDataService.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * @return key of project data supported by the current manager
 */
@Nonnull
Key<E> getTargetDataKey();