Search in sources :

Example 6 with Annotation

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

the class ExpressionsJavaValidator method checkAnnotationTarget.

@Check(CheckType.FAST)
public void checkAnnotationTarget(final AnnotatableElement element) {
    EList<Annotation> annotations = element.getAnnotations();
    for (Annotation annotation : annotations) {
        EList<EObject> targets = annotation.getType().getTargets();
        if (targets.isEmpty())
            continue;
        boolean found = Iterables.any(targets, new Predicate<EObject>() {

            @Override
            public boolean apply(EObject input) {
                return ((EClass) input).isInstance(element);
            }
        });
        if (!found) {
            error(String.format(ERROR_WRONG_ANNOTATION_TARGET_MSG, annotation.getType().getName(), element.eClass()), null, element.getAnnotations().indexOf(annotation), ERROR_WRONG_ANNOTATION_TARGET_CODE);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Annotation(org.yakindu.base.types.Annotation) Check(org.eclipse.xtext.validation.Check)

Aggregations

Annotation (org.yakindu.base.types.Annotation)6 Statechart (org.yakindu.sct.model.sgraph.Statechart)3 Check (org.eclipse.xtext.validation.Check)2 ArgumentedAnnotation (org.yakindu.sct.model.stext.stext.ArgumentedAnnotation)2 EObject (org.eclipse.emf.ecore.EObject)1 EventDrivenStatemachineHeader (org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineHeader)1 EventDrivenStatemachineSource (org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineSource)1 EventDrivenEventCode (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenEventCode)1 EventDrivenStatemachineHeader (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineHeader)1 EventDrivenStatemachineImplementation (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineImplementation)1 EventDrivenStatemachine (org.yakindu.sct.generator.java.eventdriven.EventDrivenStatemachine)1 Scope (org.yakindu.sct.model.sgraph.Scope)1