use of com.intellij.openapi.roots.impl.ModuleOrderEntryImpl in project intellij-community by JetBrains.
the class MavenRootModelAdapter method addModuleDependency.
public void addModuleDependency(@NotNull String moduleName, @NotNull DependencyScope scope, boolean testJar) {
Module m = findModuleByName(moduleName);
ModuleOrderEntry e;
if (m != null) {
e = myRootModel.addModuleOrderEntry(m);
} else {
AccessToken accessToken = ReadAction.start();
try {
e = myRootModel.addInvalidModuleEntry(moduleName);
} finally {
accessToken.finish();
}
}
e.setScope(scope);
if (testJar) {
((ModuleOrderEntryImpl) e).setProductionOnTestDependency(true);
}
if (myOrderEntriesBeforeJdk.contains(moduleName)) {
moveLastOrderEntryBeforeJdk();
}
}
use of com.intellij.openapi.roots.impl.ModuleOrderEntryImpl in project intellij-community by JetBrains.
the class ModuleDependencyDataService method importData.
@Override
protected Map<OrderEntry, OrderAware> importData(@NotNull final Collection<DataNode<ModuleDependencyData>> toImport, @NotNull final Module module, @NotNull final IdeModifiableModelsProvider modelsProvider) {
final Map<Pair<String, DependencyScope>, ModuleOrderEntry> /* dependency module scope */
toRemove = ContainerUtilRt.newHashMap();
final Map<OrderEntry, OrderAware> orderEntryDataMap = ContainerUtil.newLinkedHashMap();
for (OrderEntry entry : modelsProvider.getOrderEntries(module)) {
if (entry instanceof ModuleOrderEntry) {
ModuleOrderEntry e = (ModuleOrderEntry) entry;
toRemove.put(Pair.create(e.getModuleName(), e.getScope()), e);
}
}
final Set<ModuleDependencyData> processed = ContainerUtil.newHashSet();
final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
for (DataNode<ModuleDependencyData> dependencyNode : toImport) {
final ModuleDependencyData dependencyData = dependencyNode.getData();
if (processed.contains(dependencyData))
continue;
processed.add(dependencyData);
toRemove.remove(Pair.create(dependencyData.getInternalName(), dependencyData.getScope()));
final ModuleData moduleData = dependencyData.getTarget();
Module ideDependencyModule = modelsProvider.findIdeModule(moduleData);
ModuleOrderEntry orderEntry;
if (module.equals(ideDependencyModule)) {
// skip recursive module dependency check
continue;
} else {
if (ideDependencyModule == null) {
LOG.warn(String.format("Can't import module dependency for '%s' module. Reason: target module (%s) is not found at the ide", module.getName(), dependencyData));
}
orderEntry = modelsProvider.findIdeModuleDependency(dependencyData, module);
if (orderEntry == null) {
orderEntry = ReadAction.compute(() -> ideDependencyModule == null ? modifiableRootModel.addInvalidModuleEntry(moduleData.getInternalName()) : modifiableRootModel.addModuleOrderEntry(ideDependencyModule));
}
}
orderEntry.setScope(dependencyData.getScope());
orderEntry.setExported(dependencyData.isExported());
final boolean productionOnTestDependency = dependencyData.isProductionOnTestDependency();
if (orderEntry instanceof ModuleOrderEntryImpl) {
((ModuleOrderEntryImpl) orderEntry).setProductionOnTestDependency(productionOnTestDependency);
} else if (productionOnTestDependency) {
LOG.warn("Unable to set productionOnTestDependency for entry: " + orderEntry);
}
orderEntryDataMap.put(orderEntry, dependencyData);
}
if (!toRemove.isEmpty()) {
removeData(toRemove.values(), module, modelsProvider);
}
return orderEntryDataMap;
}
Aggregations