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;
}
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);
}
}
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;
}
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);
}
}
}
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);
}
}
Aggregations