11/*******************************************************************************
22 * SysML 2 Pilot Implementation
3- * Copyright (c) 2021-2023 Model Driven Solutions, Inc.
3+ * Copyright (c) 2021-2024 Model Driven Solutions, Inc.
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU Lesser General Public License as published by
2121
2222package org .omg .sysml .adapter ;
2323
24- import org .eclipse .emf .common .util .EList ;
25- import org .omg .sysml .lang .sysml .Expression ;
26- import org .omg .sysml .lang .sysml .Feature ;
2724import org .omg .sysml .lang .sysml .OperatorExpression ;
2825import org .omg .sysml .lang .sysml .SysMLPackage ;
29- import org .omg .sysml .lang .sysml .Type ;
30- import org .omg .sysml .util .ElementUtil ;
3126import org .omg .sysml .util .ExpressionUtil ;
32- import org .omg .sysml .util .TypeUtil ;
3327
3428public class OperatorExpressionAdapter extends InvocationExpressionAdapter {
3529
36- public static final String INDEXING_OPERATOR = "#" ;
37- public static final String ARRAY_TYPE = "Collections::Array" ;
38-
3930 public OperatorExpressionAdapter (OperatorExpression element ) {
4031 super (element );
4132 }
@@ -45,30 +36,6 @@ public OperatorExpression getTarget() {
4536 return (OperatorExpression )super .getTarget ();
4637 }
4738
48- public void addIndexingResultSubsetting () {
49- OperatorExpression target = getTarget ();
50- if (INDEXING_OPERATOR .equals (target .getOperator ())) {
51- EList <Expression > arguments = target .getArgument ();
52- if (!arguments .isEmpty ()) {
53- Expression seqArgument = arguments .get (0 );
54- ElementUtil .transform (seqArgument );
55- Feature seqResult = seqArgument .getResult ();
56- if (!hasArrayType (seqResult )) {
57- Feature resultFeature = target .getResult ();
58- if (resultFeature != null && seqResult != null ) {
59- TypeUtil .addImplicitGeneralTypeTo (resultFeature , SysMLPackage .eINSTANCE .getSubsetting (), seqResult );
60- }
61- }
62- }
63- }
64- }
65-
66- protected boolean hasArrayType (Feature feature ) {
67- Type arrayType = getLibraryType (ARRAY_TYPE );
68- return arrayType != null &&
69- feature .getType ().stream ().anyMatch (t ->TypeUtil .conforms (t , arrayType ));
70- }
71-
7239 @ Override
7340 public void computeImplicitGeneralTypes () {
7441 OperatorExpression target = getTarget ();
@@ -77,7 +44,6 @@ public void computeImplicitGeneralTypes() {
7744 addDefaultGeneralType (SysMLPackage .eINSTANCE .getFeatureTyping (), ExpressionUtil .getOperatorQualifiedNames (operator ));
7845 }
7946 super .computeImplicitGeneralTypes ();
80- addIndexingResultSubsetting ();
8147 }
8248
8349}
0 commit comments