use of com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration in project dsl-devkit by dsldevkit.
the class FormatConfigurationImpl method setExtendedFormatConfiguration.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setExtendedFormatConfiguration(FormatConfiguration newExtendedFormatConfiguration) {
FormatConfiguration oldExtendedFormatConfiguration = extendedFormatConfiguration;
extendedFormatConfiguration = newExtendedFormatConfiguration;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FormatPackage.FORMAT_CONFIGURATION__EXTENDED_FORMAT_CONFIGURATION, oldExtendedFormatConfiguration, extendedFormatConfiguration));
}
use of com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration in project dsl-devkit by dsldevkit.
the class FormatValidationTest method extendedGrammarCompatible.
/**
* Verify that ExtendedGrammarCompatible validation issues error when grammars of the Format models are incompatible.
*/
@Test
public void extendedGrammarCompatible() {
try {
getXtextTestUtil().getModel("MyDsl.xtext", "grammar com.avaloq.tools.ddk.xtext.format.validation.MyDsl\nimport \"http://www.eclipse.org/emf/2002/Ecore\" as ecore\nRule: 'rule';");
} catch (IOException e) {
fail("Could not create MyDsl model: " + e.getMessage());
}
FormatConfiguration myDslModel = createModel("MyDsl", PARENT_MODEL_NAME, new String[] {});
assertDiagnostic(myDslModel, FormatJavaValidator.EXTENDED_GRAMMAR_INCOMPATIBLE_CODE);
}
use of com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration in project dsl-devkit by dsldevkit.
the class FormatValidationTest method extendedGrammarCompatibleOK.
/**
* Verify that ExtendedGrammarCompatible validation issues no error.
*/
@Test
public void extendedGrammarCompatibleOK() {
createModel(PARENT_MODEL_NAME, null, new String[] {});
FormatConfiguration extendModel = createModel(EXTENDING_MODEL_NAME, PARENT_MODEL_NAME, new String[] {});
assertNoDiagnostic(extendModel, FormatJavaValidator.EXTENDED_GRAMMAR_INCOMPATIBLE_CODE);
}
use of com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration in project dsl-devkit by dsldevkit.
the class FormatJavaValidator method checkOverrideMissing.
/**
* Checks that rules declare overrides when there is a corresponding inherited rule.
*
* @param model
* the model
*/
@Check
public void checkOverrideMissing(final FormatConfiguration model) {
FormatConfiguration extendedModel = model.getExtendedFormatConfiguration();
if (extendedModel == null || extendedModel.eIsProxy()) {
return;
}
Iterable<Rule> nonOverrideRules = Iterables.filter(model.getRules(), Predicates.not(IS_OVERRIDE));
Iterable<Rule> overriddenRules = collectRules(extendedModel);
Map<AbstractRule, GrammarRule> localAbstractRuleMap = Maps.newHashMap();
for (GrammarRule rule : Iterables.filter(nonOverrideRules, GrammarRule.class)) {
localAbstractRuleMap.put(TARGET_RULE.apply(rule), rule);
}
// Check GrammarRules
for (GrammarRule overriddenRule : Iterables.filter(overriddenRules, GrammarRule.class)) {
if (localAbstractRuleMap.containsKey(TARGET_RULE.apply(overriddenRule))) {
GrammarRule localRule = localAbstractRuleMap.get(TARGET_RULE.apply(overriddenRule));
error(OVERRIDE_MISSING_MESSAGE, localRule, FormatPackage.Literals.GRAMMAR_RULE__TARGET_RULE, OVERRIDE_MISSING_CODE);
}
}
// Check WildcardRule
if (!Iterables.isEmpty(Iterables.filter(nonOverrideRules, WildcardRule.class)) && !Iterables.isEmpty(Iterables.filter(overriddenRules, WildcardRule.class))) {
error(OVERRIDE_MISSING_MESSAGE, Iterables.filter(nonOverrideRules, WildcardRule.class).iterator().next(), null, OVERRIDE_MISSING_CODE);
}
}
use of com.avaloq.tools.ddk.xtext.format.format.FormatConfiguration in project dsl-devkit by dsldevkit.
the class FormatJavaValidator method collectRules.
/**
* Collect all rules contained by the given model (including any of its extended configurations).
*
* @param model
* the model
* @return all rules
*/
private Iterable<Rule> collectRules(final FormatConfiguration model) {
Iterable<Rule> result = model.getRules();
FormatConfiguration extendedModel = model.getExtendedFormatConfiguration();
if (extendedModel != null && !extendedModel.eIsProxy()) {
result = Iterables.concat(result, collectRules(extendedModel));
}
return result;
}
Aggregations