Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-05-13 06:01:33 -0400
committerEd Willink2016-05-18 09:17:51 -0400
commitf28b29fd477c595ec722421ed0f14b28614c4c18 (patch)
tree8d0c459d90392ec9311f258b675384f449410ec7
parent0805e9b910b1e782a05e0f88e076b76287ab1617 (diff)
downloadorg.eclipse.qvtd-f28b29fd477c595ec722421ed0f14b28614c4c18.tar.gz
org.eclipse.qvtd-f28b29fd477c595ec722421ed0f14b28614c4c18.tar.xz
org.eclipse.qvtd-f28b29fd477c595ec722421ed0f14b28614c4c18.zip
[486722] Use biggest realized node as name basis
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/AbstractRegion.java68
1 files changed, 57 insertions, 11 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/AbstractRegion.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/AbstractRegion.java
index 3062f9610..e6afe21d8 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/AbstractRegion.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/AbstractRegion.java
@@ -995,21 +995,54 @@ public abstract class AbstractRegion implements Region, ToDOT.ToDOTable
}
Collections.sort(names);
SymbolNameBuilder s = null;
- for (@NonNull Node headNode : getHeadNodes()) {
+ Set<@NonNull Node> bestToOneSubRegion = null;
+ Node bestNamingNode = null;
+ for (@NonNull Node node : getRealizedNodes()) {
+ Set<@NonNull Node> toOneSubRegion = computeToOneSubRegion(new HashSet<@NonNull Node>(), node);
+ if ((bestToOneSubRegion == null) || (toOneSubRegion.size() > bestToOneSubRegion.size())) {
+ bestToOneSubRegion = toOneSubRegion;
+ bestNamingNode = node;
+ }
+ else if ((bestNamingNode != null) && (toOneSubRegion.size() == bestToOneSubRegion.size())) {
+ if (ClassUtil.safeCompareTo(bestNamingNode.getCompleteClass().getName(), node.getCompleteClass().getName()) > 0) {
+ bestToOneSubRegion = toOneSubRegion;
+ bestNamingNode = node;
+ }
+ }
+ }
+ if (bestNamingNode != null) {
s = new SymbolNameBuilder();
s.appendString("m_");
- s.appendName(headNode.getCompleteClass().getName());
- List<String> edgeNames = new ArrayList<String>();
- for (@NonNull NavigationEdge edge : headNode.getNavigationEdges()) {
- String propertyName = edge.getProperty().getName();
- edgeNames.add(edge.getTarget().isNull() ? propertyName + "0" : propertyName);
- }
- Collections.sort(edgeNames);
- for (String edgeName : edgeNames) {
+ s.appendName(bestNamingNode.getCompleteClass().getName());
+ List<@NonNull String> headNames = new ArrayList<@NonNull String>();
+ for (@NonNull Node headNode : getHeadNodes()) {
+ String name = headNode.getCompleteClass().getName();
+ if (name != null) {
+ headNames.add(name);
+ }
+ }
+ for (@NonNull String headName : headNames) {
s.appendString("_");
- s.appendName(edgeName);
+ s.appendString(headName);
+ }
+ }
+ else {
+ for (@NonNull Node headNode : getHeadNodes()) {
+ s = new SymbolNameBuilder();
+ s.appendString("m_");
+ s.appendName(headNode.getCompleteClass().getName());
+ List<String> edgeNames = new ArrayList<String>();
+ for (@NonNull NavigationEdge edge : headNode.getNavigationEdges()) {
+ String propertyName = edge.getProperty().getName();
+ edgeNames.add(edge.getTarget().isNull() ? propertyName + "0" : propertyName);
+ }
+ Collections.sort(edgeNames);
+ for (String edgeName : edgeNames) {
+ s.appendString("_");
+ s.appendName(edgeName);
+ }
+ break;
}
- break;
}
if (s == null) {
s = new SymbolNameBuilder();
@@ -1018,6 +1051,19 @@ public abstract class AbstractRegion implements Region, ToDOT.ToDOTable
return s;
}
+ private @NonNull Set<@NonNull Node> computeToOneSubRegion(@NonNull Set<@NonNull Node> toOneSubRegion, @NonNull Node atNode) {
+ if (toOneSubRegion.add(atNode)) {
+ for (@NonNull NavigationEdge edge : atNode.getNavigationEdges()) {
+ assert edge.getSource() == atNode;
+ Property source2target = edge.getProperty();
+ if (!source2target.isIsMany() && !source2target.isIsImplicit()) {
+ computeToOneSubRegion(toOneSubRegion, edge.getTarget());
+ }
+ }
+ }
+ return toOneSubRegion;
+ }
+
/**
* Create a NodeConnection to the realized node for each attribute.
*

Back to the top