@@ -129,7 +129,7 @@ public static Expression expressionFor(EList<Element> results, Element context)
129129 public static Expression expressionFor (Element result ) {
130130 if (result instanceof LiteralExpression ) {
131131 Object value = valueOf (result );
132- return value == null ? literalInfinity (): (Expression )elementFor (value );
132+ return value == null ? literalInfinity (): (Expression )elementFor (null , value );
133133 } else if (result instanceof Feature ) {
134134 FeatureReferenceExpression featureRef = SysMLFactory .eINSTANCE .createFeatureReferenceExpression ();
135135 NamespaceUtil .addMemberTo (featureRef , result );
@@ -140,29 +140,29 @@ public static Expression expressionFor(Element result) {
140140
141141 }
142142
143- public static EList <Element > results (Object object ) {
143+ public static EList <Element > results (Element context , Object object ) {
144144 EList <Element > results = new BasicEList <>();
145- if (object instanceof List ) {
146- (( List <?>) object ) .stream ().
147- map (EvaluationUtil :: elementFor ).
145+ if (object instanceof List <?> list ) {
146+ list .stream ().
147+ map (obj -> elementFor ( context , obj ) ).
148148 filter (e ->e != null ).
149149 forEachOrdered (results ::add );
150150 } else if (object != null ) {
151- Element element = elementFor (object );
152- if (object != null ) {
151+ Element element = elementFor (context , object );
152+ if (element != null ) {
153153 results .add (element );
154154 }
155155 }
156156 return results ;
157157 }
158158
159- public static Element elementFor (Object object ) {
159+ public static Element elementFor (Element context , Object object ) {
160160 return object instanceof Boolean ? literalBoolean ((Boolean )object ):
161161 object instanceof String ? literalString ((String )object ):
162162 object instanceof Integer ? literalInteger ((Integer )object ):
163163 object instanceof Double ? literalRational ((Double )object ):
164164 object instanceof Element ? ElementUtil .getMetaclassFeatureFor ((Element )object ):
165- null ;
165+ enumUsage ( context , object ) ;
166166 }
167167
168168 public static LiteralBoolean literalBoolean (boolean value ) {
@@ -193,6 +193,22 @@ public static LiteralInfinity literalInfinity() {
193193 return SysMLFactory .eINSTANCE .createLiteralInfinity ();
194194 }
195195
196+ public static Feature enumUsage (Element context , Object object ) {
197+ if (object != null ) {
198+ Class <?> class_ = object .getClass ();
199+ if (class_ != null ) {
200+ String name = class_ .getSimpleName () + "::" + object ;
201+ Type type = SysMLLibraryUtil .getLibraryType (context ,
202+ "KerML::Root::" + name , "KerML::Core::" + name , "KerML::Kernel::" + name ,
203+ "SysML::Systems::" + name );
204+ if (type instanceof Feature feature ) {
205+ return feature ;
206+ }
207+ }
208+ }
209+ return null ;
210+ }
211+
196212 public static EList <Element > booleanResult (boolean value ) {
197213 return singletonList (literalBoolean (value ));
198214 }
0 commit comments