use of com.avaloq.tools.ddk.check.check.Check in project dsl-devkit by dsldevkit.
the class CheckQuickfixProvider method addIdToCheck.
/**
* Add explicit ID to a check, autogenerated from its label.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.MISSING_ID_ON_CHECK)
public void addIdToCheck(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_ADD_ID_LABEL, NLS.bind(Messages.CheckQuickfixProvider_ADD_ID_DESCN, CHECK), NO_IMAGE, (final EObject element, final IModificationContext context) -> {
final Check check = EcoreUtil2.getContainerOfType(element, Check.class);
if (check != null) {
final String label = check.getLabel();
final String id = CheckUtil.toIdentifier(label);
check.setId(id);
}
});
}
use of com.avaloq.tools.ddk.check.check.Check in project dsl-devkit by dsldevkit.
the class CheckCompiler method _toJavaStatement.
/**
* {@inheritDoc}
*/
// CHECKSTYLE:OFF
protected void _toJavaStatement(final XIssueExpression expr, final ITreeAppendable b, final boolean isReferenced) {
// NOPMD NPath complexity
// CHECKSTYLE:ON
XExpression markerObject = expr.getMarkerObject();
Check check = generatorExtensions.issuedCheck(expr);
for (XExpression param : expr.getMessageParameters()) {
internalToJavaStatement(param, b, true);
b.newLine();
}
if (markerObject != null) {
internalToJavaStatement(markerObject, b, true);
b.newLine();
}
XExpression markerIndex = expr.getMarkerIndex();
if (markerIndex != null) {
internalToJavaStatement(markerIndex, b, true);
b.newLine();
}
JvmType eObjectType = findKnownTopLevelType(EObject.class, expr);
for (XExpression data : expr.getIssueData()) {
internalToJavaStatement(data, b, true);
b.newLine();
}
// acceptor
b.append("// Issue diagnostic").newLine();
b.append(generatorNaming.catalogInstanceName(expr)).append(".accept(").append("getMessageAcceptor()");
// context object
b.append(", //").increaseIndentation().newLine();
if (markerObject != null) {
internalToConvertedExpression(markerObject, b, getLightweightType(eObjectType));
} else {
b.append(getContextImplicitVariableName(expr));
}
b.append(", // context EObject").newLine();
// feature
EStructuralFeature markerFeature = expr.getMarkerFeature();
if (markerFeature != null) {
b.append(findEPackageInterfaceType(markerFeature, expr));
b.append(".eINSTANCE.get").append(markerFeature.getEContainingClass().getName()).append("_").append(Strings.toFirstUpper(markerFeature.getName())).append("()");
} else {
b.append("null");
}
b.append(", // EStructuralFeature").newLine();
// message
b.append(generatorNaming.catalogInstanceName(check)).append(".get").append(Strings.toFirstUpper(check.getName())).append("Message(");
if (!expr.getMessageParameters().isEmpty()) {
boolean first = true;
for (XExpression param : expr.getMessageParameters()) {
if (!first) {
b.append(", ");
}
internalToJavaExpression(param, b);
first = false;
}
}
b.append(")");
b.append(", // Message").newLine();
// severity kind
b.append(generatorNaming.catalogInstanceName(check)).append(".get").append(Strings.toFirstUpper(generatorExtensions.issuedCheck(expr).getName()));
b.append("SeverityKind(");
if (markerObject != null) {
internalToConvertedExpression(markerObject, b, getLightweightType(eObjectType));
} else {
b.append(getContextImplicitVariableName(expr));
}
// .append(variable)
b.append(")");
b.append(", // Severity ").newLine();
// marker index
if (markerIndex != null) {
internalToJavaExpression(markerIndex, b);
} else {
b.append(findKnownTopLevelType(ValidationMessageAcceptor.class, expr)).append(".INSIGNIFICANT_INDEX");
}
b.append(", // Marker index").newLine();
// issue codes
final String qualifiedIssueCodeName = generatorExtensions.qualifiedIssueCodeName(expr);
b.append(qualifiedIssueCodeName == null ? "null" : qualifiedIssueCodeName);
// issue data
for (XExpression data : expr.getIssueData()) {
b.append(", ");
internalToJavaExpression(data, b);
}
b.append(" // Issue code & data").decreaseIndentation().newLine();
b.append(");");
}
use of com.avaloq.tools.ddk.check.check.Check 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();
}
}
use of com.avaloq.tools.ddk.check.check.Check 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());
}
}
}
use of com.avaloq.tools.ddk.check.check.Check in project dsl-devkit by dsldevkit.
the class ConfiguredCheckImpl method setCheck.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCheck(Check newCheck) {
Check oldCheck = check;
check = newCheck;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CheckcfgPackage.CONFIGURED_CHECK__CHECK, oldCheck, check));
}
Aggregations