use of com.avaloq.tools.ddk.check.check.FormalParameter in project dsl-devkit by dsldevkit.
the class CheckCompiler method getFormalParameter.
/**
* Gets the FormalParameter this feature call references, if any.
*
* @param element
* to check
* @return The source model element (FormalParameter) for this feature call target, or null.
*/
public FormalParameter getFormalParameter(final JvmIdentifiableElement element) {
Iterator<EObject> modelElements = associations.getSourceElements(element).iterator();
FormalParameter parameter = null;
while (parameter == null && modelElements.hasNext()) {
EObject obj = modelElements.next();
if (obj instanceof FormalParameter) {
parameter = (FormalParameter) obj;
}
}
return parameter;
}
use of com.avaloq.tools.ddk.check.check.FormalParameter in project dsl-devkit by dsldevkit.
the class CheckCompiler method _toJavaExpression.
@Override
protected // CHECKSTYLE:OFF
void _toJavaExpression(final XAbstractFeatureCall expr, final ITreeAppendable b) {
// CHECKSTYLE:ON
FormalParameter parameter = getFormalParameter(expr);
if (parameter != null) {
// No Java entities are generated for this. Replace by a call to the getter function.
b.append(generatorNaming.catalogInstanceName(parameter)).append(".").append(generatorNaming.formalParameterGetterName(parameter));
b.append("(").append(getContextImplicitVariableName(expr)).append(")");
} else {
Member member = getMember(expr);
if (member != null) {
// Something isn't quite right in the Jvm model yet... or in the xbase compiler. Don't know what it is, but even if in an inner
// class, it generates "this.foo" instead of either just "foo" or "OuterClass.this.foo". Force it to produce the latter.
CheckCatalog catalog = EcoreUtil2.getContainerOfType(member, CheckCatalog.class);
String catalogName = generatorNaming.validatorClassName(catalog);
b.append(catalogName + ".this.").append(member.getName());
return;
}
super._toJavaExpression(expr, b);
}
}
use of com.avaloq.tools.ddk.check.check.FormalParameter 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.check.check.FormalParameter 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.FormalParameter in project dsl-devkit by dsldevkit.
the class ConfiguredParameterImpl method setParameter.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParameter(FormalParameter newParameter) {
FormalParameter oldParameter = parameter;
parameter = newParameter;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CheckcfgPackage.CONFIGURED_PARAMETER__PARAMETER, oldParameter, parameter));
}
Aggregations