use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext in project dsl-devkit by dsldevkit.
the class ScopeLabelProvider method text.
/**
* Return label text for an ScopeRule.
*
* @param rule
* The ScopeRule.
* @return The label text.
*/
@SuppressWarnings("nls")
public String text(final ScopeRule rule) {
StringBuffer res = new StringBuffer();
final ScopeContext context = rule.getContext();
if (context.isGlobal()) {
res.append("* ");
} else {
res.append(context.getContextType().getName());
res.append(' ');
}
if (context.getGuard() != null) {
String guard = serializer.serialize(context.getGuard());
// NOPMD
guard = guard.length() > MAX_GUARD_LABEL_LENGTH ? guard.substring(0, MAX_GUARD_LABEL_LENGTH) + "..." : guard;
res.append('[').append(guard).append("] ");
}
return res.toString();
}
use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext 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.ScopeContext in project dsl-devkit by dsldevkit.
the class ScopeRuleImpl method basicSetContext.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContext(ScopeContext newContext, NotificationChain msgs) {
ScopeContext oldContext = context;
context = newContext;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ScopePackage.SCOPE_RULE__CONTEXT, oldContext, newContext);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations