use of com.avaloq.tools.ddk.check.check.FormalParameter in project dsl-devkit by dsldevkit.
the class CheckConfigurationImplCustom method getProperties.
/**
* {@inheritDoc}
*/
@Override
public EList<FormalParameter> getProperties() {
EList<FormalParameter> properties = new EObjectContainmentEList<FormalParameter>(FormalParameter.class, this, CheckcfgPackage.CHECK_CONFIGURATION__PROPERTIES);
PropertiesInferenceHelper helper = PropertiesInferenceHelper.getHelper();
return helper.getProperties(this, properties);
}
use of com.avaloq.tools.ddk.check.check.FormalParameter in project dsl-devkit by dsldevkit.
the class CheckCfgTemplateProposalProvider method addConfiguredCheckTemplates.
/**
* Adds template proposals for all checks which may be referenced in current catalog configuration. Only proposals for checks
* which have not yet been configured are provided.
*
* @param templateContext
* the template context
* @param context
* the context
* @param acceptor
* the acceptor
*/
private void addConfiguredCheckTemplates(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) {
// NOPMD
ConfiguredCatalog configuredCatalog = EcoreUtil2.getContainerOfType(context.getCurrentModel(), ConfiguredCatalog.class);
Iterable<String> alreadyConfiguredCheckNames = Iterables.filter(Iterables.transform(configuredCatalog.getCheckConfigurations(), new Function<ConfiguredCheck, String>() {
@Override
public String apply(final ConfiguredCheck from) {
if (from.getCheck() != null) {
return from.getCheck().getName();
}
return null;
}
}), Predicates.notNull());
final CheckCatalog catalog = configuredCatalog.getCatalog();
for (final Check check : catalog.getAllChecks()) {
// create a template on the fly
final String checkName = check.getName();
if (!Iterables.contains(alreadyConfiguredCheckNames, checkName)) {
// check if referenced check has configurable parameters
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final StringJoiner paramsJoiner = new StringJoiner(", ", " (", ")");
// $NON-NLS-1$
paramsJoiner.setEmptyValue("");
for (final FormalParameter param : check.getFormalParameters()) {
final String paramName = param.getName();
final Object defaultValue = interpreter.evaluate(param.getRight()).getResult();
final String valuePlaceholder = helper.createLiteralValuePattern(paramName, defaultValue);
// $NON-NLS-1$
paramsJoiner.add(paramName + " = " + valuePlaceholder);
}
// $NON-NLS-1$ //$NON-NLS-2$
final String severity = (catalog.isFinal() || check.isFinal()) ? "default " : "${default:Enum('SeverityKind')} ";
// $NON-NLS-1$ //$NON-NLS-2$
final String description = "Configures the check \"" + check.getLabel() + "\"";
// $NON-NLS-1$
final String contextTypeId = "com.avaloq.tools.ddk.checkcfg.CheckCfg.ConfiguredCheck." + checkName;
// $NON-NLS-1$
final String pattern = severity + qualifiedNameValueConverter.toString(checkName) + paramsJoiner + "${cursor}";
Template t = new Template(checkName, description, contextTypeId, pattern, true);
TemplateProposal tp = createProposal(t, templateContext, context, images.forConfiguredCheck(check.getDefaultSeverity()), getRelevance(t));
acceptor.accept(tp);
}
}
}
use of com.avaloq.tools.ddk.check.check.FormalParameter in project dsl-devkit by dsldevkit.
the class CheckCfgProposalProvider method completeConfiguredParameter_NewValue.
@Override
public // CHECKSTYLE:OFF
void completeConfiguredParameter_NewValue(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
// CHECKSTYLE:ON
// TODO filter depending on type of linked parameter
FormalParameter parameter = ((ConfiguredParameter) model).getParameter();
ICheckCfgPropertySpecification propertySpecification = null;
String[] validValues = null;
if (parameter != null) {
propertySpecification = CheckCfgUtil.getPropertySpecification(parameter.getName());
if (propertySpecification != null) {
validValues = propertySpecification.getExpectedValues();
}
}
if (validValues != null && validValues.length > 0) {
String info = propertySpecification.getInfo();
for (String validValue : validValues) {
ICompletionProposal proposal = createCompletionProposal(String.format("\"%s\"", validValue), new StyledString(validValue), getImage(model), 0, context.getPrefix(), context);
if (proposal instanceof ConfigurableCompletionProposal) {
((ConfigurableCompletionProposal) proposal).setAdditionalProposalInfo(info);
}
acceptor.accept(proposal);
}
return;
}
super.completeConfiguredParameter_NewValue(model, assignment, context, acceptor);
}
Aggregations