Search in sources :

Example 6 with Operation

use of org.yakindu.base.types.Operation in project statecharts by Yakindu.

the class AbstractTypeSystem method getOperationExtensions.

@Override
public List<Operation> getOperationExtensions(Type type) {
    List<Operation> result = new ArrayList<>();
    result.addAll(extensionOperationRegistry.get(type));
    List<Type> superTypes = getSuperTypes(type);
    for (Type superType : superTypes) {
        result.addAll(extensionOperationRegistry.get(superType));
    }
    return result;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type) ArrayList(java.util.ArrayList) Operation(org.yakindu.base.types.Operation)

Example 7 with Operation

use of org.yakindu.base.types.Operation in project statecharts by Yakindu.

the class ExpressionsJavaValidator method checkOperationArguments_FeatureCall.

@Check(CheckType.FAST)
public void checkOperationArguments_FeatureCall(final FeatureCall call) {
    if (call.getFeature() instanceof Operation) {
        Operation operation = (Operation) call.getFeature();
        assertOperationArguments(operation, call.getExpressions());
    }
}
Also used : Operation(org.yakindu.base.types.Operation) Check(org.eclipse.xtext.validation.Check)

Example 8 with Operation

use of org.yakindu.base.types.Operation in project statecharts by Yakindu.

the class ExpressionsJavaValidator method checkOperationArguments_TypedElementReferenceExpression.

@Check(CheckType.FAST)
public void checkOperationArguments_TypedElementReferenceExpression(final ElementReferenceExpression call) {
    if (call.getReference() instanceof Operation) {
        Operation operation = (Operation) call.getReference();
        assertOperationArguments(operation, call.getExpressions());
    }
}
Also used : Operation(org.yakindu.base.types.Operation) Check(org.eclipse.xtext.validation.Check)

Example 9 with Operation

use of org.yakindu.base.types.Operation in project statecharts by Yakindu.

the class OperationOverloadingResolver method linkOperation.

public Optional<Operation> linkOperation(List<IEObjectDescription> candidates, ArgumentExpression call) {
    if (candidates.size() == 1 && candidates.get(0).getEClass().isSuperTypeOf(TypesPackage.Literals.OPERATION)) {
        return Optional.of((Operation) candidates.get(0).getEObjectOrProxy());
    }
    List<Operation> operations = candidates.stream().map(it -> (Operation) it.getEObjectOrProxy()).collect(Collectors.toList());
    Collections.sort(operations, new PolymorphicComparator());
    for (Operation operation : operations) {
        if (isCallable(operation, call)) {
            return Optional.of(operation);
        }
    }
    return Optional.empty();
}
Also used : ArgumentSorter(org.yakindu.base.expressions.expressions.util.ArgumentSorter) ITypeSystem(org.yakindu.base.types.typesystem.ITypeSystem) ArgumentExpression(org.yakindu.base.expressions.expressions.ArgumentExpression) Inject(com.google.inject.Inject) Collectors(java.util.stream.Collectors) EList(org.eclipse.emf.common.util.EList) Parameter(org.yakindu.base.types.Parameter) List(java.util.List) ITypeSystemInferrer(org.yakindu.base.types.inferrer.ITypeSystemInferrer) TypesPackage(org.yakindu.base.types.TypesPackage) Operation(org.yakindu.base.types.Operation) Optional(java.util.Optional) Comparator(java.util.Comparator) Collections(java.util.Collections) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Type(org.yakindu.base.types.Type) Expression(org.yakindu.base.expressions.expressions.Expression) Operation(org.yakindu.base.types.Operation)

Aggregations

Operation (org.yakindu.base.types.Operation)9 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)4 Parameter (org.yakindu.base.types.Parameter)3 Type (org.yakindu.base.types.Type)3 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 EList (org.eclipse.emf.common.util.EList)2 EObject (org.eclipse.emf.ecore.EObject)2 Check (org.eclipse.xtext.validation.Check)2 ArgumentExpression (org.yakindu.base.expressions.expressions.ArgumentExpression)2 Expression (org.yakindu.base.expressions.expressions.Expression)2 ArgumentSorter (org.yakindu.base.expressions.expressions.util.ArgumentSorter)2 TypesPackage (org.yakindu.base.types.TypesPackage)2 ITypeSystemInferrer (org.yakindu.base.types.inferrer.ITypeSystemInferrer)2 ITypeSystem (org.yakindu.base.types.typesystem.ITypeSystem)2