Skip to content

Commit

Permalink
[1397] Improve support for canonical tools of reused node descriptions
Browse files Browse the repository at this point in the history
Bug: #1397
Signed-off-by: Stéphane Bégaudeau <[email protected]>
Signed-off-by: Guillaume Coutable <[email protected]>
  • Loading branch information
gcoutable committed Nov 21, 2022
1 parent c93f087 commit 6994264
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext;
Expand Down Expand Up @@ -401,8 +404,17 @@ private List<NodeDescription> getAllTargetDescriptions(org.eclipse.sirius.compon
var targetDescriptions = Optional.ofNullable(nodeDescription.eContainer()).map(converterContext.getConvertedNodes()::get).stream().collect(Collectors.toList());
allTargetDescriptions.addAll(targetDescriptions);

var crossReferencesAdapter = nodeDescription.eResource().getResourceSet().eAdapters().stream().filter(ECrossReferenceAdapter.class::isInstance).map(ECrossReferenceAdapter.class::cast)
.findFirst().orElse(new ECrossReferenceAdapter());
// @formatter:off
var crossReferencesAdapter = Optional.ofNullable(nodeDescription.eResource())
.map(Resource::getResourceSet)
.map(ResourceSet::eAdapters)
.orElseGet(BasicEList::new)
.stream()
.filter(ECrossReferenceAdapter.class::isInstance)
.map(ECrossReferenceAdapter.class::cast)
.findFirst()
.orElse(new ECrossReferenceAdapter());
// @formatter:on
var crossReferences = crossReferencesAdapter.getInverseReferences(nodeDescription);
for (Setting setting : crossReferences) {
if (setting.getEObject() instanceof org.eclipse.sirius.components.view.NodeDescription) {
Expand Down

0 comments on commit 6994264

Please sign in to comment.