Search in sources :

Example 1 with ExternalDependenciesManager

use of com.intellij.externalDependencies.ExternalDependenciesManager in project intellij by bazelbuild.

the class PluginDependencyHelper method addDependency.

/**
 * Adds dependency, or replaces existing dependency of same type. Doesn't trigger any update
 * checking
 */
private static void addDependency(Project project, DependencyOnPlugin newDep) {
    ExternalDependenciesManager manager = ExternalDependenciesManager.getInstance(project);
    List<ProjectExternalDependency> deps = Lists.newArrayList(manager.getAllDependencies());
    boolean added = false;
    for (int i = 0; i < deps.size(); i++) {
        ProjectExternalDependency dep = deps.get(i);
        if (!(dep instanceof DependencyOnPlugin)) {
            continue;
        }
        DependencyOnPlugin pluginDep = (DependencyOnPlugin) dep;
        if (pluginDep.getPluginId().equals(newDep.getPluginId())) {
            added = true;
            deps.set(i, newDep);
        }
    }
    if (!added) {
        deps.add(newDep);
    }
    manager.setAllDependencies(deps);
}
Also used : ExternalDependenciesManager(com.intellij.externalDependencies.ExternalDependenciesManager) ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Example 2 with ExternalDependenciesManager

use of com.intellij.externalDependencies.ExternalDependenciesManager in project intellij by bazelbuild.

the class PluginDependencyHelper method removeDependencyOnOldPlugin.

/**
 * Removes a project depedency on a given plugin, if one exists. Doesn't trigger any update
 * checking. This is to handle migration of the IntelliJ-with-Bazel plugin to a different plugin
 * ID. This is introduced in v1.9, remove in v2.2+
 */
@Deprecated
public static void removeDependencyOnOldPlugin(Project project, String pluginId) {
    ExternalDependenciesManager manager = ExternalDependenciesManager.getInstance(project);
    List<ProjectExternalDependency> deps = Lists.newArrayList(manager.getAllDependencies());
    Iterator<ProjectExternalDependency> iter = deps.iterator();
    while (iter.hasNext()) {
        ProjectExternalDependency dep = iter.next();
        if (!(dep instanceof DependencyOnPlugin)) {
            continue;
        }
        DependencyOnPlugin pluginDep = (DependencyOnPlugin) dep;
        if (pluginDep.getPluginId().equals(pluginId)) {
            iter.remove();
        }
    }
    manager.setAllDependencies(deps);
}
Also used : ExternalDependenciesManager(com.intellij.externalDependencies.ExternalDependenciesManager) ProjectExternalDependency(com.intellij.externalDependencies.ProjectExternalDependency) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Aggregations

DependencyOnPlugin (com.intellij.externalDependencies.DependencyOnPlugin)2 ExternalDependenciesManager (com.intellij.externalDependencies.ExternalDependenciesManager)2 ProjectExternalDependency (com.intellij.externalDependencies.ProjectExternalDependency)2