Search in sources :

Example 1 with ConfigurableSection

use of com.avaloq.tools.ddk.checkcfg.checkcfg.ConfigurableSection in project dsl-devkit by dsldevkit.

the class CheckConfigurationPropertiesGenerator method putInheritedProperties.

/**
 * Adds the inherited properties.
 *
 * @param properties
 *          the properties
 * @param language
 *          the language
 * @param check
 *          the check to configure
 * @param parentCatalog
 *          the parent catalog configuration
 * @param configuredProperties
 *          the properties already configured for this check
 */
private void putInheritedProperties(final Properties properties, final String language, final Check check, final ConfiguredCatalog parentCatalog, final EList<ConfiguredParameter> configuredProperties) {
    // this check needs to inherit any parameters defined in one of its parent levels (ConfigurableSections).
    // the values of the inferred parameters are taken from the innermost level.
    // @Format-Off
    Set<String> configuredPropertyNames = configuredProperties.stream().map(property -> property.getParameter()).filter(Objects::nonNull).map(formalParameter -> formalParameter.getName()).collect(Collectors.toSet());
    // @Format-On
    EObject parentSection = parentCatalog;
    while (parentSection != null) {
        if (parentSection instanceof ConfigurableSection) {
            EList<ConfiguredParameter> sectionProperties = ((ConfigurableSection) parentSection).getParameterConfigurations();
            for (ConfiguredParameter property : sectionProperties) {
                if (!configuredPropertyNames.contains(property.getParameter().getName())) {
                    configuredPropertyNames.add(property.getParameter().getName());
                    putProperty(properties, language, check, property, evaluateParameterValue(property.getNewValue()));
                }
            }
        }
        parentSection = parentSection.eContainer();
    }
}
Also used : CheckPropertiesGenerator(com.avaloq.tools.ddk.check.generator.CheckPropertiesGenerator) ConfigurableSection(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfigurableSection) Iterables(com.google.common.collect.Iterables) Inject(com.google.inject.Inject) Check(com.avaloq.tools.ddk.check.check.Check) NodeModelUtils(org.eclipse.xtext.nodemodel.util.NodeModelUtils) Logger(org.apache.log4j.Logger) XIssueExpression(com.avaloq.tools.ddk.check.check.XIssueExpression) Locale(java.util.Locale) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) ConfiguredCatalog(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCatalog) FormalParameter(com.avaloq.tools.ddk.check.check.FormalParameter) StreamSupport(java.util.stream.StreamSupport) XExpression(org.eclipse.xtext.xbase.XExpression) Properties(java.util.Properties) Function(com.google.common.base.Function) ConfiguredLanguageValidator(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredLanguageValidator) ConfiguredParameter(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) CheckPreferencesHelper(com.avaloq.tools.ddk.check.runtime.configuration.CheckPreferencesHelper) SeverityKind(com.avaloq.tools.ddk.checkcfg.checkcfg.SeverityKind) Collectors(java.util.stream.Collectors) IExpressionInterpreter(org.eclipse.xtext.xbase.interpreter.IExpressionInterpreter) EList(org.eclipse.emf.common.util.EList) LanguageSpecificCheckConfigurationStore(com.avaloq.tools.ddk.check.runtime.configuration.LanguageSpecificCheckConfigurationStore) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) XListLiteral(org.eclipse.xtext.xbase.XListLiteral) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck) CheckConfiguration(com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration) ECollections(org.eclipse.emf.common.util.ECollections) ConfigurableSection(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfigurableSection) ConfiguredParameter(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter) EObject(org.eclipse.emf.ecore.EObject) Objects(java.util.Objects)

Aggregations

Check (com.avaloq.tools.ddk.check.check.Check)1 FormalParameter (com.avaloq.tools.ddk.check.check.FormalParameter)1 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1 CheckPropertiesGenerator (com.avaloq.tools.ddk.check.generator.CheckPropertiesGenerator)1 CheckPreferencesHelper (com.avaloq.tools.ddk.check.runtime.configuration.CheckPreferencesHelper)1 LanguageSpecificCheckConfigurationStore (com.avaloq.tools.ddk.check.runtime.configuration.LanguageSpecificCheckConfigurationStore)1 CheckConfiguration (com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration)1 ConfigurableSection (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfigurableSection)1 ConfiguredCatalog (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCatalog)1 ConfiguredCheck (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)1 ConfiguredLanguageValidator (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredLanguageValidator)1 ConfiguredParameter (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter)1 SeverityKind (com.avaloq.tools.ddk.checkcfg.checkcfg.SeverityKind)1 Function (com.google.common.base.Function)1 Iterables (com.google.common.collect.Iterables)1 Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 Locale (java.util.Locale)1 Objects (java.util.Objects)1 Properties (java.util.Properties)1