Skip to content

Commit

Permalink
Adding parameter validation to static operation calls #11
Browse files Browse the repository at this point in the history
  • Loading branch information
ujhelyiz committed Sep 11, 2015
1 parent 77625ae commit 338c2ce
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.incquerylabs.uml.ralf.ReducedAlfSystem;
import com.incquerylabs.uml.ralf.reducedAlfLanguage.Expression;
import com.incquerylabs.uml.ralf.reducedAlfLanguage.FeatureInvocationExpression;
import com.incquerylabs.uml.ralf.reducedAlfLanguage.StaticFeatureInvocationExpression;
import com.incquerylabs.uml.ralf.reducedAlfLanguage.Tuple;
import com.incquerylabs.uml.ralf.resource.ReducedAlfLanguageResource;

Expand Down Expand Up @@ -71,16 +72,24 @@ public List<EObject> getLinkedObjects(EObject context, EReference ref, INode nod
if (linkedObjects.size() == 1 && linkedObjects.get(0) instanceof Operation) {
Operation op = (Operation) linkedObjects.get(0);
IUMLContextProvider umlContext = ((ReducedAlfLanguageResource)context.eResource()).getUmlContextProvider();
Expression ctx = null;
Set<Operation> candidates = null;
Type contextType = null;
Tuple parameters = null;
if (context instanceof FeatureInvocationExpression) {
FeatureInvocationExpression featureInvocationExpression = (FeatureInvocationExpression) context;
ctx = featureInvocationExpression.getContext();
Expression ctx = featureInvocationExpression.getContext();
parameters = featureInvocationExpression.getParameters();
contextType = typeSystem.type(ctx).getValue().getUmlType();
} else if (context instanceof StaticFeatureInvocationExpression) {
StaticFeatureInvocationExpression staticFeatureInvocationExpression = (StaticFeatureInvocationExpression) context;
parameters = staticFeatureInvocationExpression.getParameters();
contextType = op.getClass_();
} else {
//throw new UnsupportedOperationException("Invalid context of Operation call: " + context.eClass().getName());
return linkedObjects;
}
Type contextType = typeSystem.type(ctx).getValue().getUmlType();
Set<Operation> candidates = umlContext.getOperationCandidatesOfClass((Classifier) contextType, op.getName());
if (candidates.size() > 1) {
candidates = umlContext.getOperationCandidatesOfClass((Classifier) contextType, op.getName());
if (candidates != null && candidates.size() > 1) {
linkedObjects = calculateBestCandidates(candidates, parameters);
}
}
Expand Down

0 comments on commit 338c2ce

Please sign in to comment.