@@ -130,7 +130,7 @@ public static Expression expressionFor(EList<Element> results, Element context)
130130 public static Expression expressionFor (Element result ) {
131131 if (result instanceof LiteralExpression ) {
132132 Object value = valueOf (result );
133- return value == null ? literalInfinity (): (Expression )elementFor (value );
133+ return value == null ? literalInfinity (): (Expression )elementFor (null , value );
134134 } else if (result instanceof Feature ) {
135135 FeatureReferenceExpression featureRef = SysMLFactory .eINSTANCE .createFeatureReferenceExpression ();
136136 TypeUtil .addResultParameterTo (featureRef );
@@ -142,29 +142,29 @@ public static Expression expressionFor(Element result) {
142142
143143 }
144144
145- public static EList <Element > results (Object object ) {
145+ public static EList <Element > results (Element context , Object object ) {
146146 EList <Element > results = new BasicEList <>();
147- if (object instanceof List ) {
148- (( List <?>) object ) .stream ().
149- map (EvaluationUtil :: elementFor ).
147+ if (object instanceof List <?> list ) {
148+ list .stream ().
149+ map (obj -> elementFor ( context , obj ) ).
150150 filter (e ->e != null ).
151151 forEachOrdered (results ::add );
152152 } else if (object != null ) {
153- Element element = elementFor (object );
154- if (object != null ) {
153+ Element element = elementFor (context , object );
154+ if (element != null ) {
155155 results .add (element );
156156 }
157157 }
158158 return results ;
159159 }
160160
161- public static Element elementFor (Object object ) {
161+ public static Element elementFor (Element context , Object object ) {
162162 return object instanceof Boolean ? literalBoolean ((Boolean )object ):
163163 object instanceof String ? literalString ((String )object ):
164164 object instanceof Integer ? literalInteger ((Integer )object ):
165165 object instanceof Double ? literalRational ((Double )object ):
166166 object instanceof Element ? ElementUtil .getMetaclassFeatureFor ((Element )object ):
167- null ;
167+ enumUsage ( context , object ) ;
168168 }
169169
170170 public static LiteralBoolean literalBoolean (boolean value ) {
@@ -195,6 +195,22 @@ public static LiteralInfinity literalInfinity() {
195195 return SysMLFactory .eINSTANCE .createLiteralInfinity ();
196196 }
197197
198+ public static Feature enumUsage (Element context , Object object ) {
199+ if (object != null ) {
200+ Class <?> class_ = object .getClass ();
201+ if (class_ != null ) {
202+ String name = class_ .getSimpleName () + "::" + object ;
203+ Type type = SysMLLibraryUtil .getLibraryType (context ,
204+ "KerML::Root::" + name , "KerML::Core::" + name , "KerML::Kernel::" + name ,
205+ "SysML::Systems::" + name );
206+ if (type instanceof Feature feature ) {
207+ return feature ;
208+ }
209+ }
210+ }
211+ return null ;
212+ }
213+
198214 public static EList <Element > booleanResult (boolean value ) {
199215 return singletonList (literalBoolean (value ));
200216 }
0 commit comments