Search in sources :

Example 1 with DeclarationForType

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

the class ExportJavaValidator method checkInterfaceAndExportUniqueness.

/**
 * Checks that the interfaces and exports in an export section all are declared for a unique type.
 *
 * @param context
 *          model to check
 */
@Check
public void checkInterfaceAndExportUniqueness(final ExportModel context) {
    UniquenessJavaValidationHelper<DeclarationForType> helper = new UniquenessJavaValidationHelper<DeclarationForType>(new AbstractNameFunction() {

        @Override
        public QualifiedName apply(final EObject from) {
            return QualifiedName.create(((DeclarationForType) from).getType().getEPackage().getName(), ((DeclarationForType) from).getType().getName());
        }
    }, getMessageAcceptor()) {

        @Override
        public String getMessage(final DeclarationForType declaration) {
            return "declaration duplicate found: " + declaration.getType().getEPackage().getName() + "::" + declaration.getType().getName();
        }
    };
    helper.errorOnDuplicates(Iterables.filter(context.getInterfaces(), DeclarationForType.class), ExportPackage.Literals.DECLARATION_FOR_TYPE__TYPE);
    helper.errorOnDuplicates(Iterables.filter(context.getExports(), DeclarationForType.class), ExportPackage.Literals.DECLARATION_FOR_TYPE__TYPE);
}
Also used : AbstractNameFunction(com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction) DeclarationForType(com.avaloq.tools.ddk.xtext.export.export.DeclarationForType) EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) UniquenessJavaValidationHelper(com.avaloq.tools.ddk.xtext.validation.UniquenessJavaValidationHelper) Check(org.eclipse.xtext.validation.Check)

Aggregations

DeclarationForType (com.avaloq.tools.ddk.xtext.export.export.DeclarationForType)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 Check (org.eclipse.xtext.validation.Check)1