use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class ConfiguredCatalogImpl method setCatalog.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCatalog(CheckCatalog newCatalog) {
CheckCatalog oldCatalog = catalog;
catalog = newCatalog;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CheckcfgPackage.CONFIGURED_CATALOG__CATALOG, oldCatalog, catalog));
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckCompiler method _toJavaExpression.
@Override
protected // CHECKSTYLE:OFF
void _toJavaExpression(final XAbstractFeatureCall expr, final ITreeAppendable b) {
// CHECKSTYLE:ON
FormalParameter parameter = getFormalParameter(expr);
if (parameter != null) {
// No Java entities are generated for this. Replace by a call to the getter function.
b.append(generatorNaming.catalogInstanceName(parameter)).append(".").append(generatorNaming.formalParameterGetterName(parameter));
b.append("(").append(getContextImplicitVariableName(expr)).append(")");
} else {
Member member = getMember(expr);
if (member != null) {
// Something isn't quite right in the Jvm model yet... or in the xbase compiler. Don't know what it is, but even if in an inner
// class, it generates "this.foo" instead of either just "foo" or "OuterClass.this.foo". Force it to produce the latter.
CheckCatalog catalog = EcoreUtil2.getContainerOfType(member, CheckCatalog.class);
String catalogName = generatorNaming.validatorClassName(catalog);
b.append(catalogName + ".this.").append(member.getName());
return;
}
super._toJavaExpression(expr, b);
}
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckCfgTemplateProposalProvider method addCatalogConfigurations.
/**
* Adds the populated check configuration.
*
* @param templateContext
* the template context
* @param context
* the context
* @param acceptor
* the acceptor
*/
@SuppressWarnings("all")
private void addCatalogConfigurations(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) {
// $NON-NLS-1$
final String templateName = "Add all registered catalogs";
// $NON-NLS-1$
final String templateDescription = "configures all missing catalogs";
final String contextTypeId = templateContext.getContextType().getId();
if (context.getRootModel() instanceof CheckConfiguration) {
final CheckConfiguration conf = (CheckConfiguration) context.getRootModel();
List<IEObjectDescription> allElements = Lists.newArrayList(scopeProvider.getScope(conf, CheckcfgPackage.Literals.CONFIGURED_CATALOG__CATALOG).getAllElements());
StringBuilder builder = new StringBuilder();
for (IEObjectDescription description : allElements) {
if (description.getEObjectOrProxy() instanceof CheckCatalog) {
CheckCatalog catalog = (CheckCatalog) description.getEObjectOrProxy();
if (catalog.eIsProxy()) {
catalog = (CheckCatalog) EcoreUtil.resolve(catalog, conf);
}
if (isCatalogConfigured(conf, catalog)) {
continue;
} else if (allElements.indexOf(description) > 0) {
builder.append(Strings.newLine());
}
final String catalogName = qualifiedNameValueConverter.toString(description.getQualifiedName().toString());
// $NON-NLS-1$ //$NON-NLS-2$
builder.append("catalog ").append(catalogName).append(" {}").append(Strings.newLine());
}
}
if (builder.length() > 0) {
// $NON-NLS-1$
builder.append("${cursor}");
Template t = new Template(templateName, templateDescription, contextTypeId, builder.toString(), true);
TemplateProposal tp = createProposal(t, templateContext, context, images.forConfiguredCatalog(), getRelevance(t));
acceptor.accept(tp);
}
}
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckCfgJavaValidator method checkConfiguredCatalogUnique.
/**
* Checks that within a Check Configuration all Catalog Configurations are unique, meaning that a referenced
* Check Catalog can only be configured in one place.
*
* @param configuration
* the configuration
*/
@Check
public void checkConfiguredCatalogUnique(final CheckConfiguration configuration) {
if (configuration.getLegacyCatalogConfigurations().size() < 2) {
return;
}
Predicate<ConfiguredCatalog> predicate = new Predicate<ConfiguredCatalog>() {
@Override
public boolean apply(final ConfiguredCatalog configuredCatalog) {
final CheckCatalog catalog = configuredCatalog.getCatalog();
return catalog != null && !catalog.eIsProxy();
}
};
Function<ConfiguredCatalog, String> function = new Function<ConfiguredCatalog, String>() {
@Override
public String apply(final ConfiguredCatalog from) {
return from.getCatalog().getName();
}
};
for (final ConfiguredCatalog c : getDuplicates(predicate, function, configuration.getLegacyCatalogConfigurations())) {
error(Messages.CheckCfgJavaValidator_DUPLICATE_CATALOG_CONFIGURATION, c, CheckcfgPackage.Literals.CONFIGURED_CATALOG__CATALOG, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_CATALOG_CONFIGURATION);
}
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckCfgScopeProvider method getScope.
@Override
public IScope getScope(final EObject context, final EReference reference) {
if (reference == CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK) {
// Note that context object can be either a configured check (if 'optional' keyword has been provided
// so that a new instance is created and the configured catalog does not contain any configured checks
// yet) or a configured catalog (in all other cases)
final ConfiguredCatalog configuredCatalog = EcoreUtil2.getContainerOfType(context, ConfiguredCatalog.class);
if (configuredCatalog == null || configuredCatalog.getCatalog() == null) {
return IScope.NULLSCOPE;
}
CheckCatalog catalog = configuredCatalog.getCatalog();
return Scopes.scopeFor(catalog.getAllChecks(), checkQualifiedNameProvider, IScope.NULLSCOPE);
} else if (reference == CheckcfgPackage.Literals.CONFIGURED_PARAMETER__PARAMETER) {
// a new list of FormalParameters to scope to
EList<FormalParameter> parameters = ECollections.newBasicEList();
final ConfiguredCheck configuredCheck = EcoreUtil2.getContainerOfType(context, ConfiguredCheck.class);
if (configuredCheck != null) {
// add FormalParameter definitions from linked check
parameters.addAll(configuredCheck.getCheck().getFormalParameters());
}
// add inferred FormalParameters (properties)
final CheckConfiguration checkConfiguration = EcoreUtil2.getContainerOfType(context, CheckConfiguration.class);
parameters.addAll(checkConfiguration.getProperties());
return Scopes.scopeFor(parameters, checkQualifiedNameProvider, IScope.NULLSCOPE);
}
return super.getScope(context, reference);
}
Aggregations