2929import java .util .Optional ;
3030import java .util .Set ;
3131import java .util .function .Consumer ;
32- import java .util .function .Supplier ;
3332import java .util .stream .Collectors ;
3433import java .util .stream .Stream ;
3534
5857import org .omg .sysml .lang .sysml .Step ;
5958import org .omg .sysml .lang .sysml .Subsetting ;
6059import org .omg .sysml .lang .sysml .SysMLFactory ;
61- import org .omg .sysml .lang .sysml .SysMLPackage ;
6260import org .omg .sysml .lang .sysml .Type ;
6361import org .omg .sysml .lang .sysml .TypeFeaturing ;
6462
@@ -120,12 +118,6 @@ public static boolean checkIsOrdered(Feature feature, Set<Feature> visited) {
120118
121119 // Typing
122120
123- public static EList <Type > cacheTypesOf (Feature feature , Supplier <EList <Type >> supplier ) {
124- FeatureAdapter adapter = getFeatureAdapter (feature );
125- EList <Type > types = adapter .getTypes ();
126- return types == null ? adapter .setTypes (supplier .get ()): types ;
127- }
128-
129121 public static <T > T getFirstTypeOf (Feature feature , Class <T > kind ) {
130122 return FeatureUtil .getAllTypesOf (feature ).stream ().
131123 filter (kind ::isInstance ).
@@ -144,39 +136,11 @@ public static <T> EList<T> getAllTypesOf(Feature feature, Class<T> kind, int fea
144136 }
145137
146138 public static EList <Type > getAllTypesOf (Feature feature ) {
147- return FeatureUtil .cacheTypesOf (feature , ()->{
148- EList <Type > types = new NonNotifyingEObjectEList <Type >(Type .class , (InternalEObject )feature , SysMLPackage .FEATURE__TYPE );
149- getTypesOf (feature , types , new HashSet <Feature >());
150- removeRedundantTypes (types );
151- return types ;
152- });
139+ return getFeatureAdapter (feature ).getAllTypes ();
153140 }
154141
155- private static void getTypesOf (Feature feature , List <Type > types , Set <Feature > visitedFeatures ) {
156- visitedFeatures .add (feature );
157- getFeatureTypesOf (feature , types , visitedFeatures );
158- for (Feature typingFeature : feature .typingFeatures ()) {
159- if (!visitedFeatures .contains (typingFeature )) {
160- getTypesOf (typingFeature , types , visitedFeatures );
161- }
162- }
163- }
164-
165- private static void getFeatureTypesOf (Feature feature , List <Type > types , Set <Feature > visitedFeatures ) {
166- feature .getOwnedTyping ().stream ().
167- map (typing ->typing .getType ()).
168- filter (type ->type != null ).
169- forEachOrdered (types ::add );
170- types .addAll (TypeUtil .getImplicitGeneralTypesFor (feature , SysMLPackage .eINSTANCE .getFeatureTyping ()));
171- }
172-
173- protected static void removeRedundantTypes (List <Type > types ) {
174- for (int i = types .size () - 1 ; i >= 0 ; i --) {
175- Type type = types .get (i );
176- if (types .stream ().anyMatch (otherType ->otherType != type && TypeUtil .specializes (otherType , type ))) {
177- types .remove (i );
178- }
179- }
142+ public static void getTypesOf (Feature feature , List <Type > types , Set <Feature > visitedFeatures ) {
143+ getFeatureAdapter (feature ).getTypes (types , visitedFeatures );
180144 }
181145
182146 public static FeatureTyping addFeatureTypingTo (Feature feature ) {
0 commit comments