Search in sources :

Example 1 with Interface

use of com.avaloq.tools.ddk.xtext.export.export.Interface in project dsl-devkit by dsldevkit.

the class ExportJavaValidator method checkInterfaceFieldUniqueness.

/**
 * Checks that the interface don't have overlapping features, as a feature export is inherited by the export of subtypes.
 *
 * @param context
 *          model to check
 */
@Check
public void checkInterfaceFieldUniqueness(final ExportModel context) {
    UniquenessJavaValidationHelper<InterfaceField> helper1 = new UniquenessJavaValidationHelper<InterfaceField>(new AbstractNameFunction() {

        @Override
        public QualifiedName apply(final EObject from) {
            String name = ((InterfaceField) from).getField().getName();
            return QualifiedName.create(name != null ? name : "");
        }
    }, getMessageAcceptor());
    UniquenessJavaValidationHelper<InterfaceNavigation> helper2 = new UniquenessJavaValidationHelper<InterfaceNavigation>(new AbstractNameFunction() {

        @Override
        public QualifiedName apply(final EObject from) {
            String name = ((InterfaceNavigation) from).getRef().getName();
            return QualifiedName.create(name != null ? name : "");
        }
    }, getMessageAcceptor());
    for (Interface fingertype : context.getInterfaces()) {
        helper1.errorOnDuplicates(Iterables.filter(fingertype.getItems(), InterfaceField.class), ExportPackage.Literals.INTERFACE_FIELD__FIELD);
        helper2.errorOnDuplicates(Iterables.filter(fingertype.getItems(), InterfaceNavigation.class), ExportPackage.Literals.INTERFACE_NAVIGATION__REF);
    }
}
Also used : AbstractNameFunction(com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction) InterfaceNavigation(com.avaloq.tools.ddk.xtext.export.export.InterfaceNavigation) EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) InterfaceField(com.avaloq.tools.ddk.xtext.export.export.InterfaceField) UniquenessJavaValidationHelper(com.avaloq.tools.ddk.xtext.validation.UniquenessJavaValidationHelper) Interface(com.avaloq.tools.ddk.xtext.export.export.Interface) Check(org.eclipse.xtext.validation.Check)

Example 2 with Interface

use of com.avaloq.tools.ddk.xtext.export.export.Interface in project dsl-devkit by dsldevkit.

the class ExportJavaValidator method checkFingerprintInterfaceDefined.

/**
 * Checks that the interface referenced by a fingerprint is defined.
 *
 * @param context
 *          export to check
 */
@Check
public void checkFingerprintInterfaceDefined(final Export context) {
    if (context.isFingerprint() || context.isResourceFingerprint()) {
        ExportModel model = EObjectUtil.eContainer(context, ExportModel.class);
        Interface match = null;
        for (Interface iface : model.getInterfaces()) {
            if (iface.getType().isSuperTypeOf(context.getType())) {
                match = iface;
                break;
            }
        }
        if (match == null) {
            error("No matching interface specification declared", context.isFingerprint() ? ExportPackage.Literals.EXPORT__FINGERPRINT : ExportPackage.Literals.EXPORT__RESOURCE_FINGERPRINT);
        }
    }
}
Also used : ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) Interface(com.avaloq.tools.ddk.xtext.export.export.Interface) Check(org.eclipse.xtext.validation.Check)

Aggregations

Interface (com.avaloq.tools.ddk.xtext.export.export.Interface)2 Check (org.eclipse.xtext.validation.Check)2 ExportModel (com.avaloq.tools.ddk.xtext.export.export.ExportModel)1 InterfaceField (com.avaloq.tools.ddk.xtext.export.export.InterfaceField)1 InterfaceNavigation (com.avaloq.tools.ddk.xtext.export.export.InterfaceNavigation)1 AbstractNameFunction (com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction)1 UniquenessJavaValidationHelper (com.avaloq.tools.ddk.xtext.validation.UniquenessJavaValidationHelper)1 EObject (org.eclipse.emf.ecore.EObject)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1