|
22 | 22 | package org.omg.sysml.delegate.invocation; |
23 | 23 |
|
24 | 24 | import java.lang.reflect.InvocationTargetException; |
25 | | -import java.util.HashMap; |
26 | | -import java.util.HashSet; |
27 | | -import java.util.Map; |
28 | | -import java.util.Set; |
29 | 25 |
|
30 | 26 | import org.eclipse.emf.common.util.EList; |
31 | 27 | import org.eclipse.emf.ecore.EOperation; |
32 | 28 | import org.eclipse.emf.ecore.InternalEObject; |
33 | 29 | import org.eclipse.emf.ecore.util.BasicInvocationDelegate; |
34 | 30 | import org.omg.sysml.lang.sysml.Feature; |
35 | | -import org.omg.sysml.lang.sysml.impl.FeatureImpl; |
| 31 | +import org.omg.sysml.util.FeatureUtil; |
36 | 32 |
|
37 | 33 | public class Feature_effectiveShortName_InvocationDelegate extends BasicInvocationDelegate { |
38 | 34 |
|
39 | 35 | public Feature_effectiveShortName_InvocationDelegate(EOperation operation) { |
40 | 36 | super(operation); |
41 | 37 | } |
42 | 38 |
|
43 | | - private final Map<Feature, String> nameCache = new HashMap<>(); |
44 | | - |
45 | 39 | @Override |
46 | 40 | public Object dynamicInvoke(InternalEObject target, EList<?> arguments) throws InvocationTargetException { |
47 | 41 | Feature self = (Feature) target; |
48 | | - |
49 | | - return computeEffectiveShortName(self, new HashSet<>()); |
50 | | - } |
51 | | - |
52 | | - private boolean isNameSet(Feature self) { |
53 | | - return self.getDeclaredName() != null || self.getDeclaredShortName() != null; |
| 42 | + return FeatureUtil.computeEffectiveShortName(self); |
54 | 43 | } |
55 | | - |
56 | | - public String computeEffectiveShortName(Feature self, Set<Feature> visited) { |
57 | | - if (isNameSet(self)) { |
58 | | - return self.getDeclaredShortName(); |
59 | | - } |
60 | | - |
61 | | - String effectiveShortName = nameCache.get(self); |
62 | | - |
63 | | - if (effectiveShortName != null) { |
64 | | - return effectiveShortName; |
65 | | - } |
66 | | - |
67 | | - visited.add(self); |
68 | | - FeatureImpl namingFeature = (FeatureImpl) self.namingFeature(); |
69 | | - |
70 | | - if (namingFeature != null && !visited.contains(namingFeature)) { |
71 | | - effectiveShortName = computeEffectiveShortName(namingFeature, visited); |
72 | | - nameCache.put(self, effectiveShortName); |
73 | | - } |
74 | | - |
75 | | - return effectiveShortName; |
76 | | - } |
77 | | - |
78 | 44 | } |
0 commit comments