Search in sources :

Example 26 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class ExternalSystemApiUtil method findInQueue.

@Nullable
private static DataNode<?> findInQueue(@NotNull Queue<DataNode<?>> queue, @NotNull BooleanFunction<DataNode<?>> predicate) {
    while (!queue.isEmpty()) {
        DataNode node = (DataNode) queue.remove();
        if (predicate.fun(node)) {
            return node;
        }
        //noinspection unchecked
        queue.addAll(node.getChildren());
    }
    return null;
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) Nullable(org.jetbrains.annotations.Nullable)

Example 27 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class ExternalSystemResolveProjectTask method doExecute.

@SuppressWarnings("unchecked")
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    Project ideProject = getIdeProject();
    RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(ideProject, myProjectPath, getExternalSystemId());
    if (StringUtil.isNotEmpty(myVmOptions)) {
        settings.withVmOptions(ParametersListUtil.parse(myVmOptions));
    }
    if (StringUtil.isNotEmpty(myArguments)) {
        settings.withArguments(ParametersListUtil.parse(myArguments));
    }
    ExternalSystemProgressNotificationManagerImpl progressNotificationManager = (ExternalSystemProgressNotificationManagerImpl) ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
    ExternalSystemTaskId id = getId();
    progressNotificationManager.onStart(id, myProjectPath);
    try {
        DataNode<ProjectData> project = resolver.resolveProjectInfo(id, myProjectPath, myIsPreviewMode, settings);
        if (project != null) {
            myExternalProject.set(project);
            ExternalSystemManager<?, ?, ?, ?, ?> systemManager = ExternalSystemApiUtil.getManager(getExternalSystemId());
            assert systemManager != null;
            Set<String> externalModulePaths = ContainerUtil.newHashSet();
            Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(project, ProjectKeys.MODULE);
            for (DataNode<ModuleData> node : moduleNodes) {
                externalModulePaths.add(node.getData().getLinkedExternalProjectPath());
            }
            String projectPath = project.getData().getLinkedExternalProjectPath();
            ExternalProjectSettings linkedProjectSettings = systemManager.getSettingsProvider().fun(ideProject).getLinkedProjectSettings(projectPath);
            if (linkedProjectSettings != null) {
                linkedProjectSettings.setModules(externalModulePaths);
            }
        }
        progressNotificationManager.onSuccess(id);
    } finally {
        progressNotificationManager.onEnd(id);
    }
}
Also used : ExternalSystemTaskId(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId) ExternalSystemProgressNotificationManagerImpl(com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) ExternalSystemProgressNotificationManager(com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Project(com.intellij.openapi.project.Project) RemoteExternalSystemProjectResolver(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 28 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class AbstractModuleDataService method filterExistingModules.

@NotNull
private Collection<DataNode<E>> filterExistingModules(@NotNull Collection<DataNode<E>> modules, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull Project project) {
    Collection<DataNode<E>> result = ContainerUtilRt.newArrayList();
    for (DataNode<E> node : modules) {
        ModuleData moduleData = node.getData();
        Module module = modelsProvider.findIdeModule(moduleData);
        if (module == null) {
            result.add(node);
        } else {
            node.putUserData(MODULE_KEY, module);
        }
    }
    return result;
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class AbstractModuleDataService method importData.

@Override
public void importData(@NotNull final Collection<DataNode<E>> toImport, @Nullable ProjectData projectData, @NotNull final Project project, @NotNull IdeModifiableModelsProvider modelsProvider) {
    if (toImport.isEmpty()) {
        return;
    }
    final Collection<DataNode<E>> toCreate = filterExistingModules(toImport, modelsProvider, project);
    if (!toCreate.isEmpty()) {
        createModules(toCreate, modelsProvider, project);
    }
    for (DataNode<E> node : toImport) {
        Module module = node.getUserData(MODULE_KEY);
        if (module != null) {
            String productionModuleId = node.getData().getProductionModuleId();
            modelsProvider.setTestModuleProperties(module, productionModuleId);
            setModuleOptions(module, node);
            ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
            syncPaths(module, modifiableRootModel, node.getData());
            setLanguageLevel(modifiableRootModel, node.getData());
        }
    }
    for (DataNode<E> node : toImport) {
        Module module = node.getUserData(MODULE_KEY);
        if (module != null) {
            final String[] groupPath;
            groupPath = node.getData().getIdeModuleGroup();
            final ModifiableModuleModel modifiableModel = modelsProvider.getModifiableModuleModel();
            modifiableModel.setModuleGroupPath(module, groupPath);
        }
    }
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) Module(com.intellij.openapi.module.Module)

Example 30 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class GradleManager method configureExecutionWorkspace.

/**
   * Add composite participants
   */
private static void configureExecutionWorkspace(@Nullable GradleProjectSettings compositeRootSettings, GradleSettings settings, GradleExecutionSettings result, Project project, String projectPath) {
    if (compositeRootSettings == null || compositeRootSettings.getCompositeBuild() == null)
        return;
    GradleProjectSettings.CompositeBuild compositeBuild = compositeRootSettings.getCompositeBuild();
    if (compositeBuild.getCompositeDefinitionSource() == CompositeDefinitionSource.SCRIPT) {
        if (pathsEqual(compositeRootSettings.getExternalProjectPath(), projectPath))
            return;
        for (BuildParticipant buildParticipant : compositeBuild.getCompositeParticipants()) {
            if (pathsEqual(buildParticipant.getRootPath(), projectPath))
                continue;
            if (buildParticipant.getProjects().stream().anyMatch(path -> pathsEqual(path, projectPath))) {
                continue;
            }
            result.getExecutionWorkspace().addBuildParticipant(new GradleBuildParticipant(buildParticipant.getRootPath()));
        }
        return;
    }
    for (GradleProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
        if (projectSettings == compositeRootSettings)
            continue;
        if (compositeBuild.getCompositeParticipants().stream().noneMatch(participant -> pathsEqual(participant.getRootPath(), projectSettings.getExternalProjectPath()))) {
            continue;
        }
        GradleBuildParticipant buildParticipant = new GradleBuildParticipant(projectSettings.getExternalProjectPath());
        ExternalProjectInfo projectData = ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, projectSettings.getExternalProjectPath());
        if (projectData == null || projectData.getExternalProjectStructure() == null)
            continue;
        Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(projectData.getExternalProjectStructure(), ProjectKeys.MODULE);
        for (DataNode<ModuleData> moduleNode : moduleNodes) {
            ModuleData moduleData = moduleNode.getData();
            if (moduleData.getArtifacts().isEmpty()) {
                Collection<DataNode<GradleSourceSetData>> sourceSetNodes = ExternalSystemApiUtil.findAll(moduleNode, GradleSourceSetData.KEY);
                for (DataNode<GradleSourceSetData> sourceSetNode : sourceSetNodes) {
                    buildParticipant.addModule(sourceSetNode.getData());
                }
            } else {
                buildParticipant.addModule(moduleData);
            }
        }
        result.getExecutionWorkspace().addBuildParticipant(buildParticipant);
    }
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) DataNode(com.intellij.openapi.externalSystem.model.DataNode) GradleSourceSetData(org.jetbrains.plugins.gradle.model.data.GradleSourceSetData) BuildParticipant(org.jetbrains.plugins.gradle.model.data.BuildParticipant) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData)

Aggregations

DataNode (com.intellij.openapi.externalSystem.model.DataNode)51 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)22 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)14 NotNull (org.jetbrains.annotations.NotNull)12 Module (com.intellij.openapi.module.Module)11 File (java.io.File)9 Project (com.intellij.openapi.project.Project)7 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)6 Nullable (org.jetbrains.annotations.Nullable)6 GradleSourceSetData (org.jetbrains.plugins.gradle.model.data.GradleSourceSetData)5 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)4 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)4 IdeaModule (org.gradle.tooling.model.idea.IdeaModule)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Task (com.intellij.openapi.progress.Task)3 Pair (com.intellij.openapi.util.Pair)3 MultiMap (com.intellij.util.containers.MultiMap)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)2 JavaProjectData (com.intellij.externalSystem.JavaProjectData)2