diff options
author | 2023-09-13 19:04:39 +0200 | |
---|---|---|
committer | 2023-09-13 19:04:39 +0200 | |
commit | 5999eb4433dc5a758674d9c941d97bbaf48d030d (patch) | |
tree | 8c5d0d41adcf3f7f7d2fdc4a0480271c9b81cfe1 /subprojects/language-semantics/src/main/java/tools | |
parent | fix: multiplicity error for non-existing objects (diff) | |
download | refinery-5999eb4433dc5a758674d9c941d97bbaf48d030d.tar.gz refinery-5999eb4433dc5a758674d9c941d97bbaf48d030d.tar.zst refinery-5999eb4433dc5a758674d9c941d97bbaf48d030d.zip |
fix: hide new node names in generated models
Diffstat (limited to 'subprojects/language-semantics/src/main/java/tools')
-rw-r--r-- | subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/metadata/MetadataCreator.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/metadata/MetadataCreator.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/metadata/MetadataCreator.java index b6a2cdf0..cc262129 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/metadata/MetadataCreator.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/metadata/MetadataCreator.java | |||
@@ -46,27 +46,36 @@ public class MetadataCreator { | |||
46 | relationScope = scopeProvider.getScope(problem, ProblemPackage.Literals.ASSERTION__RELATION); | 46 | relationScope = scopeProvider.getScope(problem, ProblemPackage.Literals.ASSERTION__RELATION); |
47 | } | 47 | } |
48 | 48 | ||
49 | public static String unnamedNode(int nodeId) { | ||
50 | return "::" + nodeId; | ||
51 | } | ||
52 | |||
49 | public List<NodeMetadata> getNodesMetadata() { | 53 | public List<NodeMetadata> getNodesMetadata() { |
50 | return getNodesMetadata(initializer.getNodeCount()); | 54 | return getNodesMetadata(initializer.getNodeCount(), true); |
51 | } | 55 | } |
52 | 56 | ||
53 | public List<NodeMetadata> getNodesMetadata(int nodeCount) { | 57 | public List<NodeMetadata> getNodesMetadata(int nodeCount, boolean preserveNewNodes) { |
54 | var nodes = new NodeMetadata[Math.max(initializer.getNodeCount(), nodeCount)]; | 58 | var nodes = new NodeMetadata[Math.max(initializer.getNodeCount(), nodeCount)]; |
55 | for (var entry : initializer.getNodeTrace().keyValuesView()) { | 59 | for (var entry : initializer.getNodeTrace().keyValuesView()) { |
56 | var node = entry.getOne(); | 60 | var node = entry.getOne(); |
57 | var id = entry.getTwo(); | 61 | var id = entry.getTwo(); |
58 | nodes[id] = getNodeMetadata(node); | 62 | nodes[id] = getNodeMetadata(id, node, preserveNewNodes); |
59 | } | 63 | } |
60 | for (int i = 0; i < nodes.length; i++) { | 64 | for (int i = 0; i < nodes.length; i++) { |
61 | if (nodes[i] == null) { | 65 | if (nodes[i] == null) { |
62 | var nodeName = "::" + i; | 66 | var nodeName = unnamedNode(i); |
63 | nodes[i] = new NodeMetadata(nodeName, nodeName, NodeKind.IMPLICIT); | 67 | nodes[i] = new NodeMetadata(nodeName, nodeName, NodeKind.IMPLICIT); |
64 | } | 68 | } |
65 | } | 69 | } |
66 | return List.of(nodes); | 70 | return List.of(nodes); |
67 | } | 71 | } |
68 | 72 | ||
69 | private NodeMetadata getNodeMetadata(Node node) { | 73 | private NodeMetadata getNodeMetadata(int nodeId, Node node, boolean preserveNewNodes) { |
74 | var kind = getNodeKind(node); | ||
75 | if (!preserveNewNodes && kind == NodeKind.NEW) { | ||
76 | var nodeName = unnamedNode(nodeId); | ||
77 | return new NodeMetadata(nodeName, nodeName, NodeKind.IMPLICIT); | ||
78 | } | ||
70 | var qualifiedName = getQualifiedName(node); | 79 | var qualifiedName = getQualifiedName(node); |
71 | var simpleName = getSimpleName(node, qualifiedName, nodeScope); | 80 | var simpleName = getSimpleName(node, qualifiedName, nodeScope); |
72 | return new NodeMetadata(qualifiedNameConverter.toString(qualifiedName), | 81 | return new NodeMetadata(qualifiedNameConverter.toString(qualifiedName), |