use of org.eclipse.xtext.example.homeautomation.ruleEngine.Declaration in project xtext-eclipse by eclipse.
the class RuleEngineValidator method checkUniqueDeclarations.
@Check
public void checkUniqueDeclarations(Model model) {
Set<String> deviceNames = new HashSet<>();
Set<String> ruleDescriptions = new HashSet<>();
for (Declaration decl : model.getDeclarations()) {
if (decl instanceof Device) {
String name = ((Device) decl).getName();
if (!deviceNames.add(name)) {
error("Device names must be unique.", decl, RuleEnginePackage.Literals.DEVICE__NAME);
}
} else {
String methodName = RuleEngineJvmModelInferrer.getRuleMethodName((Rule) decl);
if (!ruleDescriptions.add(methodName)) {
error("Rule descriptions must be unique.", decl, RuleEnginePackage.Literals.RULE__DESCRIPTION);
}
}
}
}
use of org.eclipse.xtext.example.homeautomation.ruleEngine.Declaration in project xtext-eclipse by eclipse.
the class RuleEngineFormatter method _format.
protected void _format(final Model model, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.setNewLines(0, 0, 1);
it.noSpace();
};
document.<Model>prepend(model, _function);
EList<Declaration> _declarations = model.getDeclarations();
for (final Declaration declaration : _declarations) {
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.setNewLines(1, 1, 2);
};
document.<Declaration>append(document.<Declaration>format(declaration), _function_1);
}
}
Aggregations