Lines 12-39
Link Here
|
12 |
*/ |
12 |
*/ |
13 |
package org.eclipse.uml2.uml.internal.operations; |
13 |
package org.eclipse.uml2.uml.internal.operations; |
14 |
|
14 |
|
|
|
15 |
import java.util.ArrayList; |
16 |
import java.util.Collections; |
17 |
import java.util.Iterator; |
18 |
import java.util.List; |
19 |
import java.util.ListIterator; |
15 |
import java.util.Map; |
20 |
import java.util.Map; |
16 |
|
21 |
|
17 |
import org.eclipse.emf.common.util.BasicDiagnostic; |
22 |
import org.eclipse.emf.common.util.BasicDiagnostic; |
18 |
import org.eclipse.emf.common.util.Diagnostic; |
23 |
import org.eclipse.emf.common.util.Diagnostic; |
19 |
import org.eclipse.emf.common.util.DiagnosticChain; |
24 |
import org.eclipse.emf.common.util.DiagnosticChain; |
20 |
|
|
|
21 |
import org.eclipse.uml2.uml.Message; |
22 |
|
23 |
import org.eclipse.uml2.uml.CallEvent; |
25 |
import org.eclipse.uml2.uml.CallEvent; |
24 |
import org.eclipse.uml2.uml.Event; |
26 |
import org.eclipse.uml2.uml.Event; |
|
|
27 |
import org.eclipse.uml2.uml.Message; |
25 |
import org.eclipse.uml2.uml.MessageEnd; |
28 |
import org.eclipse.uml2.uml.MessageEnd; |
26 |
import org.eclipse.uml2.uml.MessageEvent; |
29 |
import org.eclipse.uml2.uml.MessageEvent; |
27 |
import org.eclipse.uml2.uml.MessageKind; |
30 |
import org.eclipse.uml2.uml.MessageKind; |
28 |
import org.eclipse.uml2.uml.MessageOccurrenceSpecification; |
31 |
import org.eclipse.uml2.uml.MessageOccurrenceSpecification; |
|
|
32 |
import org.eclipse.uml2.uml.MessageSort; |
29 |
import org.eclipse.uml2.uml.NamedElement; |
33 |
import org.eclipse.uml2.uml.NamedElement; |
|
|
34 |
import org.eclipse.uml2.uml.Operation; |
35 |
import org.eclipse.uml2.uml.Parameter; |
36 |
import org.eclipse.uml2.uml.ParameterDirectionKind; |
30 |
import org.eclipse.uml2.uml.ReceiveOperationEvent; |
37 |
import org.eclipse.uml2.uml.ReceiveOperationEvent; |
31 |
import org.eclipse.uml2.uml.ReceiveSignalEvent; |
38 |
import org.eclipse.uml2.uml.ReceiveSignalEvent; |
32 |
import org.eclipse.uml2.uml.SendOperationEvent; |
39 |
import org.eclipse.uml2.uml.SendOperationEvent; |
33 |
import org.eclipse.uml2.uml.SendSignalEvent; |
40 |
import org.eclipse.uml2.uml.SendSignalEvent; |
|
|
41 |
import org.eclipse.uml2.uml.Signal; |
34 |
import org.eclipse.uml2.uml.SignalEvent; |
42 |
import org.eclipse.uml2.uml.SignalEvent; |
|
|
43 |
import org.eclipse.uml2.uml.Type; |
44 |
import org.eclipse.uml2.uml.TypedElement; |
35 |
import org.eclipse.uml2.uml.UMLPackage; |
45 |
import org.eclipse.uml2.uml.UMLPackage; |
36 |
|
46 |
import org.eclipse.uml2.uml.UMLPlugin; |
37 |
import org.eclipse.uml2.uml.util.UMLSwitch; |
47 |
import org.eclipse.uml2.uml.util.UMLSwitch; |
38 |
import org.eclipse.uml2.uml.util.UMLValidator; |
48 |
import org.eclipse.uml2.uml.util.UMLValidator; |
39 |
|
49 |
|
Lines 142-172
Link Here
|
142 |
* In the case when the Message signature is an Operation, the arguments of the Message must correspond to the parameters of the Operation. A Parameter corresponds to an Argument if the Argument is of the same Class or a specialization of that of the Parameter. |
152 |
* In the case when the Message signature is an Operation, the arguments of the Message must correspond to the parameters of the Operation. A Parameter corresponds to an Argument if the Argument is of the same Class or a specialization of that of the Parameter. |
143 |
* true |
153 |
* true |
144 |
* <!-- end-model-doc --> |
154 |
* <!-- end-model-doc --> |
145 |
* @generated |
155 |
* @generated NOT |
146 |
*/ |
156 |
*/ |
147 |
public static boolean validateSignatureIsOperation(Message message, |
157 |
public static boolean validateSignatureIsOperation(Message message, |
148 |
DiagnosticChain diagnostics, Map context) { |
158 |
DiagnosticChain diagnostics, Map context) { |
149 |
// TODO: implement this method |
159 |
boolean result = true; |
150 |
// -> specify the condition that violates the invariant |
160 |
NamedElement signature = message.getSignature(); |
151 |
// -> verify the details of the diagnostic, including severity and message |
161 |
if (signature instanceof Operation) { |
152 |
// Ensure that you remove @generated or mark it @generated NOT |
162 |
if (!message.getArguments().isEmpty()) { |
153 |
if (false) { |
163 |
List args = message.getArguments(); |
|
|
164 |
List params = Collections.EMPTY_LIST; |
165 |
if (message != null |
166 |
&& message.getMessageSort() == MessageSort.REPLY_LITERAL) { |
167 |
params = new ArrayList(((Operation) signature) |
168 |
.getOwnedParameters()); |
169 |
for (ListIterator it = params.listIterator(); it.hasNext();) { |
170 |
Parameter param = (Parameter) it.next(); |
171 |
if (param.getDirection() == ParameterDirectionKind.IN_LITERAL) { |
172 |
it.remove(); |
173 |
} |
174 |
} |
175 |
} else { |
176 |
params = ((Operation) signature).getOwnedParameters(); |
177 |
} |
178 |
if (args.size() != params.size()) { |
179 |
result = false; |
180 |
} |
181 |
for (Iterator arg = args.iterator(), typed = params.iterator(); arg |
182 |
.hasNext() && result;) { |
183 |
TypedElement nextArg = (TypedElement) arg.next(); |
184 |
TypedElement nextTyped = (TypedElement) typed.next(); |
185 |
Type nextArgType = nextArg.getType(); |
186 |
Type nextTypedType = nextTyped.getType(); |
187 |
if (nextArgType != null && nextTypedType != null) { |
188 |
if (!nextArgType.conformsTo(nextTypedType)) { |
189 |
result = false; |
190 |
} |
191 |
} |
192 |
} |
193 |
} |
194 |
} |
195 |
if (!result) { |
154 |
if (diagnostics != null) { |
196 |
if (diagnostics != null) { |
155 |
diagnostics |
197 |
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, |
156 |
.add(new BasicDiagnostic( |
198 |
UMLValidator.DIAGNOSTIC_SOURCE, |
157 |
Diagnostic.ERROR, |
199 |
UMLValidator.MESSAGE__SIGNATURE_IS_OPERATION, |
158 |
UMLValidator.DIAGNOSTIC_SOURCE, |
200 |
UMLPlugin.INSTANCE.getString( |
159 |
UMLValidator.MESSAGE__SIGNATURE_IS_OPERATION, |
201 |
"_UI_Message_SignatureIsOperation_diagnostic", //$NON-NLS-1$ |
160 |
org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE |
202 |
getMessageSubstitutions(context, message)), |
161 |
.getString( |
203 |
new Object[]{message})); |
162 |
"_UI_GenericInvariant_diagnostic", new Object[]{"validateSignatureIsOperation", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(message, context)}), //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
163 |
new Object[]{message})); |
164 |
} |
204 |
} |
165 |
return false; |
|
|
166 |
} |
205 |
} |
167 |
return true; |
206 |
return result; |
168 |
} |
207 |
} |
169 |
|
208 |
|
|
|
209 |
|
210 |
|
211 |
|
212 |
|
170 |
/** |
213 |
/** |
171 |
* <!-- begin-user-doc --> |
214 |
* <!-- begin-user-doc --> |
172 |
* <!-- end-user-doc --> |
215 |
* <!-- end-user-doc --> |
Lines 174-202
Link Here
|
174 |
* In the case when the Message signature is a Signal, the arguments of the Message must correspond to the attributes of the Signal. A Message Argument corresponds to a Signal Attribute if the Arguement is of the same Class or a specialization of that of the Attribute. |
217 |
* In the case when the Message signature is a Signal, the arguments of the Message must correspond to the attributes of the Signal. A Message Argument corresponds to a Signal Attribute if the Arguement is of the same Class or a specialization of that of the Attribute. |
175 |
* true |
218 |
* true |
176 |
* <!-- end-model-doc --> |
219 |
* <!-- end-model-doc --> |
177 |
* @generated |
220 |
* @generated NOT |
178 |
*/ |
221 |
*/ |
179 |
public static boolean validateSignatureIsSignal(Message message, |
222 |
public static boolean validateSignatureIsSignal(Message message, |
180 |
DiagnosticChain diagnostics, Map context) { |
223 |
DiagnosticChain diagnostics, Map context) { |
181 |
// TODO: implement this method |
224 |
|
182 |
// -> specify the condition that violates the invariant |
225 |
boolean result = true; |
183 |
// -> verify the details of the diagnostic, including severity and message |
226 |
NamedElement signature = message.getSignature(); |
184 |
// Ensure that you remove @generated or mark it @generated NOT |
227 |
if (signature instanceof Signal) { |
185 |
if (false) { |
228 |
if (!message.getArguments().isEmpty()) { |
|
|
229 |
List messageArguments = message.getArguments(); |
230 |
List signalAttributes = ((Signal) signature).getAttributes(); |
231 |
if (messageArguments.size() != signalAttributes.size()) { |
232 |
result = false; |
233 |
} |
234 |
for (Iterator arg = messageArguments.iterator(), typed = signalAttributes |
235 |
.iterator(); arg.hasNext() && result;) { |
236 |
TypedElement nextArg = (TypedElement) arg.next(); |
237 |
TypedElement nextTyped = (TypedElement) typed.next(); |
238 |
Type nextArgType = nextArg.getType(); |
239 |
Type nextTypedType = nextTyped.getType(); |
240 |
if (nextArgType != null && nextTypedType != null) { |
241 |
if (!nextArgType.conformsTo(nextTypedType)) { |
242 |
result = false; |
243 |
} |
244 |
} |
245 |
} |
246 |
} |
247 |
} |
248 |
if (!result) { |
186 |
if (diagnostics != null) { |
249 |
if (diagnostics != null) { |
187 |
diagnostics |
250 |
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, |
188 |
.add(new BasicDiagnostic( |
251 |
UMLValidator.DIAGNOSTIC_SOURCE, |
189 |
Diagnostic.ERROR, |
252 |
UMLValidator.MESSAGE__SIGNATURE_IS_SIGNAL, |
190 |
UMLValidator.DIAGNOSTIC_SOURCE, |
253 |
UMLPlugin.INSTANCE.getString( |
191 |
UMLValidator.MESSAGE__SIGNATURE_IS_SIGNAL, |
254 |
"_UI_Message_SignatureIsSignal_diagnostic", //$NON-NLS-1$ |
192 |
org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE |
255 |
getMessageSubstitutions(context, message)), |
193 |
.getString( |
256 |
new Object[]{message})); |
194 |
"_UI_GenericInvariant_diagnostic", new Object[]{"validateSignatureIsSignal", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(message, context)}), //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
195 |
new Object[]{message})); |
196 |
} |
257 |
} |
197 |
return false; |
|
|
198 |
} |
258 |
} |
199 |
return true; |
259 |
return result; |
200 |
} |
260 |
} |
201 |
|
261 |
|
202 |
/** |
262 |
/** |