use of com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction 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);
}
}
use of com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction 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);
}
use of com.avaloq.tools.ddk.xtext.scoping.AbstractNameFunction in project dsl-devkit by dsldevkit.
the class ValidScopeProvider method createEClassScope.
/**
* Creates the Eclass scope provider (all EClasses from the parent classifiers, referenced by their fully qualified (::) names.
*
* @param parent
* the parent
* @param classifiers
* the classifiers
* @return the i scope
*/
private IScope createEClassScope(final IScope parent, final Iterable<EClassifier> classifiers) {
final Iterable<EClass> classes = Iterables.filter(classifiers, EClass.class);
Iterable<IEObjectDescription> elements = EObjectDescriptions.all(classes, EcorePackage.Literals.ENAMED_ELEMENT__NAME);
elements = Iterables.concat(elements, EObjectDescriptions.all(classes, new AbstractNameFunction() {
public QualifiedName apply(final EObject from) {
final EClass param = (EClass) from;
return QualifiedName.create(param.getEPackage().getNsPrefix(), param.getName());
}
}));
return new SimpleScope(parent, elements);
}
Aggregations