Search in sources :

Example 1 with ConfiguredCheck

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

the class SemanticHighlightingCalculator method provideHighlightingFor.

// NOTE: will never be called, is currently disabled (see UI module)
/**
 * {@inheritDoc}
 */
public void provideHighlightingFor(final XtextResource resource, final IHighlightedPositionAcceptor acceptor) {
    if (resource == null) {
        return;
    }
    Iterator<EObject> iter = EcoreUtil.getAllContents(resource, true);
    while (iter.hasNext()) {
        EObject current = iter.next();
        if (current instanceof ConfiguredCheck && ((ConfiguredCheck) current).getSeverity().equals(SeverityKind.IGNORE)) {
            INode node = getFirstParseTreeNode(current, CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK);
            highlightNode(node, SemanticHighlightingConfiguration.DISABLED_VALUE_ID, acceptor);
        }
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) EObject(org.eclipse.emf.ecore.EObject) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)

Example 2 with ConfiguredCheck

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

the class CheckCfgJavaValidator method checkConfigurationEqualsDefault.

/**
 * Checks whether a configured check's configuration equals the default. Emits an info if this is the case.
 *
 * @param configuredCheck
 *          the configured check
 */
@Check
public void checkConfigurationEqualsDefault(final ConfiguredCheck configuredCheck) {
    final com.avaloq.tools.ddk.check.check.Check check = configuredCheck.getCheck();
    if (!isParameterConfigured(configuredCheck) || check == null || check.eIsProxy()) {
        // only interesting if check configured and resolvable
        return;
    }
    Iterable<FormalParameter> formalParameters = check.getFormalParameters();
    for (final ConfiguredParameter configParam : configuredCheck.getParameterConfigurations()) {
        try {
            FormalParameter param = Iterables.find(formalParameters, new Predicate<FormalParameter>() {

                @Override
                public boolean apply(final FormalParameter input) {
                    return input == configParam.getParameter();
                }
            });
            if (parameterValuesEqual(configParam.getNewValue(), param.getRight())) {
                info(NLS.bind(Messages.CheckCfgJavaValidator_CONFIGURED_PARAM_EQUALS_DEFAULT, param.getName()), configParam, CheckcfgPackage.Literals.CONFIGURED_PARAMETER__NEW_VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.CONFIGURED_PARAM_EQUALS_DEFAULT);
            }
        } catch (NoSuchElementException e) {
            LOGGER.debug("Could not find referenced formal parameter");
        }
    }
}
Also used : FormalParameter(com.avaloq.tools.ddk.check.check.FormalParameter) ConfiguredParameter(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter) NoSuchElementException(java.util.NoSuchElementException) Check(org.eclipse.xtext.validation.Check) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)

Example 3 with ConfiguredCheck

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

the class CheckCfgJavaValidator method checkConfiguredCheckUnique.

/**
 * Checks that Check Configurations are unique. A Configured Catalog may only contain one configuration for each referenced Check.
 *
 * @param configuration
 *          the configuration
 */
@Check
public void checkConfiguredCheckUnique(final ConfiguredCatalog configuration) {
    if (configuration.getCheckConfigurations().size() < 2) {
        return;
    }
    Predicate<ConfiguredCheck> predicate = new Predicate<ConfiguredCheck>() {

        @Override
        public boolean apply(final ConfiguredCheck configuredCheck) {
            return configuredCheck.getCheck() != null && !configuredCheck.getCheck().eIsProxy();
        }
    };
    Function<ConfiguredCheck, String> function = new Function<ConfiguredCheck, String>() {

        @Override
        public String apply(final ConfiguredCheck from) {
            return from.getCheck().getName();
        }
    };
    for (final ConfiguredCheck c : getDuplicates(predicate, function, configuration.getCheckConfigurations())) {
        error(Messages.CheckCfgJavaValidator_DUPLICATE_CHECK_CONFIGURATION, c, CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_CHECK_CONFIGURATION);
    }
}
Also used : Function(com.google.common.base.Function) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck) Predicate(com.google.common.base.Predicate) Check(org.eclipse.xtext.validation.Check) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)

Example 4 with ConfiguredCheck

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

the class CheckCfgJavaValidator method checkConfiguredParameterUnique.

/**
 * Checks that a Configured Check has unique Configured Parameters.
 *
 * @param configuredCheck
 *          the configured check
 */
@Check
public void checkConfiguredParameterUnique(final ConfiguredCheck configuredCheck) {
    if (configuredCheck.getParameterConfigurations().size() < 2) {
        return;
    }
    Predicate<ConfiguredParameter> predicate = new Predicate<ConfiguredParameter>() {

        @Override
        public boolean apply(final ConfiguredParameter configuredParameter) {
            return configuredParameter.getParameter() != null && !configuredParameter.getParameter().eIsProxy();
        }
    };
    Function<ConfiguredParameter, String> function = new Function<ConfiguredParameter, String>() {

        @Override
        public String apply(final ConfiguredParameter from) {
            return from.getParameter().getName();
        }
    };
    for (final ConfiguredParameter p : getDuplicates(predicate, function, configuredCheck.getParameterConfigurations())) {
        error(Messages.CheckCfgJavaValidator_DUPLICATE_PARAMETER_CONFIGURATION, p, CheckcfgPackage.Literals.CONFIGURED_PARAMETER__PARAMETER, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.DUPLICATE_PARAMETER_CONFIGURATION);
    }
}
Also used : Function(com.google.common.base.Function) ConfiguredParameter(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter) Predicate(com.google.common.base.Predicate) Check(org.eclipse.xtext.validation.Check) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)

Example 5 with ConfiguredCheck

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

the class CheckConfigurationPropertiesGenerator method generatePropertiesForCatalogsInConfigurableSection.

/**
 * Generate properties for languages or legacy catalogs.
 *
 * @param section
 *          the section
 * @param properties
 *          the properties
 */
private void generatePropertiesForCatalogsInConfigurableSection(final ConfigurableSection section, final Properties properties) {
    String language = null;
    EList<ConfiguredCatalog> configuredCatalogs = ECollections.emptyEList();
    if (section instanceof CheckConfiguration) {
        configuredCatalogs = ((CheckConfiguration) section).getLegacyCatalogConfigurations();
    } else if (section instanceof ConfiguredLanguageValidator) {
        language = ((ConfiguredLanguageValidator) section).getLanguage();
        configuredCatalogs = ((ConfiguredLanguageValidator) section).getCatalogConfigurations();
    }
    for (ConfiguredCatalog catalog : configuredCatalogs) {
        Set<Check> configuredChecks = Sets.newHashSet();
        for (ConfiguredCheck configuredCheck : catalog.getCheckConfigurations()) {
            generatePropertiesForConfiguredCheck(properties, language, configuredCheck);
            configuredChecks.add(configuredCheck.getCheck());
        }
        for (Check unconfiguredCheck : Sets.difference(Sets.newHashSet(catalog.getCatalog().getAllChecks()), configuredChecks)) {
            putInheritedProperties(properties, language, unconfiguredCheck, catalog, ECollections.emptyEList());
        }
    }
}
Also used : CheckConfiguration(com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration) ConfiguredCatalog(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCatalog) ConfiguredLanguageValidator(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredLanguageValidator) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck) Check(com.avaloq.tools.ddk.check.check.Check) ConfiguredCheck(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)

Aggregations

ConfiguredCheck (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCheck)8 Check (org.eclipse.xtext.validation.Check)4 ConfiguredCatalog (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredCatalog)3 Function (com.google.common.base.Function)3 Check (com.avaloq.tools.ddk.check.check.Check)2 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)2 FormalParameter (com.avaloq.tools.ddk.check.check.FormalParameter)2 CheckConfiguration (com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration)2 ConfiguredParameter (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter)2 Predicate (com.google.common.base.Predicate)2 SeverityRange (com.avaloq.tools.ddk.check.check.SeverityRange)1 ConfiguredLanguageValidator (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredLanguageValidator)1 NoSuchElementException (java.util.NoSuchElementException)1 StringJoiner (java.util.StringJoiner)1 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 Template (org.eclipse.jface.text.templates.Template)1 TemplateProposal (org.eclipse.jface.text.templates.TemplateProposal)1 INode (org.eclipse.xtext.nodemodel.INode)1