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);
}
}
}
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");
}
}
}
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);
}
}
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);
}
}
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());
}
}
}
Aggregations