use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition in project dsl-devkit by dsldevkit.
the class ScopeJavaValidator method checkScopeRuleOverriding.
/**
* Checks that the local scope rules do not override any inherited scope rules (not supported).
*
* @param context
* scoping section to check
*/
@Check
public void checkScopeRuleOverriding(final ScopeModel context) {
final Set<ScopeDefinition> inheritedDefinitions = getAllInheritedScopeDefinitions(context);
if (inheritedDefinitions.isEmpty()) {
return;
}
final Map<String, ScopeRule> profileMap = Maps.newHashMap();
for (ScopeDefinition def : inheritedDefinitions) {
for (ScopeRule rule : def.getRules()) {
final String profile = ScopeUtil.getSignature(rule);
profileMap.put(profile, rule);
}
}
for (ScopeDefinition def : context.getScopes()) {
for (ScopeRule rule : def.getRules()) {
final String profile = ScopeUtil.getSignature(rule);
final ScopeRule other = profileMap.get(profile);
if (other != null) {
errorOnDuplicate(rule, other, Messages.overriddenInheritedScopeRule, ScopePackage.Literals.SCOPE_RULE__CONTEXT);
}
}
}
}
use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition in project dsl-devkit by dsldevkit.
the class ScopeJavaValidator method checkGuardDefaultExists.
/**
* Checks that a guarded scope rule is matched by a unguarded default scope rule.
*
* @param context
* scope rule to check
*/
@Check
public void checkGuardDefaultExists(final ScopeRule context) {
if (context.getContext() == null || context.getContext().getGuard() == null) {
return;
}
ScopeDefinition def = EObjectUtil.eContainer(context, ScopeDefinition.class);
ScopeContext ctx = context.getContext();
boolean defaultFound = false;
for (ScopeRule r : def.getRules()) {
ScopeContext c = r.getContext();
if (c != null && c.getGuard() == null && c.getContextType() == ctx.getContextType()) {
defaultFound = true;
break;
}
}
if (!defaultFound) {
warning("No matching default scope rule defined", ScopePackage.Literals.SCOPE_RULE__CONTEXT);
}
}
use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition in project dsl-devkit by dsldevkit.
the class ScopeJavaValidator method checkNameFunctionExists.
/**
* Verifies that a matching default name function exists for scope expressions without explicit name functions.
*
* @param expr
* scope expression to check
*/
@Check
public void checkNameFunctionExists(final SimpleScopeExpression expr) {
if (expr.getNaming() != null && !expr.getNaming().getNames().isEmpty()) {
return;
}
ScopeDefinition def = EObjectUtil.eContainer(expr, ScopeDefinition.class);
ScopeModel model = EObjectUtil.eContainer(expr, ScopeModel.class);
if (def != null && model != null) {
EClass scopeType = getType(def);
NamingSection namingSection = model.getNaming();
if (namingSection != null) {
for (NamingDefinition naming : namingSection.getNamings()) {
if (naming.getType() != null && isLeftMostSuperType(naming.getType(), scopeType)) {
return;
}
}
}
error(NLS.bind(Messages.missingNameFunction, scopeType.getName()), ScopePackage.Literals.SIMPLE_SCOPE_EXPRESSION__EXPR);
}
}
Aggregations