Added ValidationServices.call().
Change-Id: Idfead3e9762465cb9f6936336f2e674f834922bc
diff --git a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/parser/AstValidator.java b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/parser/AstValidator.java
index 25f5c94..dd76673 100644
--- a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/parser/AstValidator.java
+++ b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/parser/AstValidator.java
@@ -294,25 +294,10 @@
final List<Set<IType>> argTypes = inferArgTypes(call);
- final String serviceName = call.getServiceName();
- final ServicesValidationResult servicesValidationResult;
- switch (call.getType()) {
- case CALLSERVICE:
- servicesValidationResult = services.callType(call, validationResult, serviceName, argTypes);
- break;
- case CALLORAPPLY:
- servicesValidationResult = services.callOrApplyTypes(call, validationResult, serviceName,
- argTypes);
- break;
- case COLLECTIONCALL:
- servicesValidationResult = services.collectionServiceCallTypes(call, validationResult,
- serviceName, argTypes);
- break;
- default:
- throw new UnsupportedOperationException(SHOULD_NEVER_HAPPEN);
- }
-
+ final ServicesValidationResult servicesValidationResult = services.call(call, validationResult,
+ argTypes);
possibleTypes = servicesValidationResult.getResultingTypes();
+
return checkWarningsAndErrors(call, possibleTypes);
}
diff --git a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ServicesValidationResult.java b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ServicesValidationResult.java
index 9f2aaf4..920700a 100644
--- a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ServicesValidationResult.java
+++ b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ServicesValidationResult.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2017 Obeo.
+ * Copyright (c) 2015, 2021 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -227,4 +227,8 @@
return result;
}
+ public Set<IService<?>> getResolvedServices() {
+ return typesPerService.keySet();
+ }
+
}
diff --git a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ValidationServices.java b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ValidationServices.java
index 984c0a1..cc7e837 100644
--- a/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ValidationServices.java
+++ b/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/ValidationServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2021 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -59,6 +59,11 @@
private static final String VARIABLE_HAS_NO_TYPES = "The %s variable has no types";
/**
+ * Should never happen message.
+ */
+ private static final String SHOULD_NEVER_HAPPEN = "should never happen";
+
+ /**
* Constructor.
*
* @param queryEnv
@@ -112,6 +117,38 @@
}
/**
+ * Gets the {@link ServicesValidationResult} for the given {@link Call} and {@link IType} of parameters.
+ *
+ * @param call
+ * the {@link Call}
+ * @param validationResult
+ * the {@link IValidationResult}
+ * @param argTypes
+ * the {@link IType} of parameters
+ * @return the {@link ServicesValidationResult} for the given {@link Call} and {@link IType} of parameters
+ */
+ public ServicesValidationResult call(Call call, IValidationResult validationResult,
+ final List<Set<IType>> argTypes) {
+ final ServicesValidationResult servicesValidationResult;
+ final String serviceName = call.getServiceName();
+ switch (call.getType()) {
+ case CALLSERVICE:
+ servicesValidationResult = callType(call, validationResult, serviceName, argTypes);
+ break;
+ case CALLORAPPLY:
+ servicesValidationResult = callOrApplyTypes(call, validationResult, serviceName, argTypes);
+ break;
+ case COLLECTIONCALL:
+ servicesValidationResult = collectionServiceCallTypes(call, validationResult, serviceName,
+ argTypes);
+ break;
+ default:
+ throw new UnsupportedOperationException(SHOULD_NEVER_HAPPEN);
+ }
+ return servicesValidationResult;
+ }
+
+ /**
* Gets the {@link ServicesValidationResult} for the given {@link IService#getName() service name} and
* {@link IType} of parameters.
*
@@ -508,9 +545,9 @@
/**
* Gets the {@link Set} of {@link EClass} form the given {@link IType}.
+ *
* @param type
* the {@link IType}
- *
* @return the {@link Set} of {@link EClass} form the given {@link IType}
*/
public Set<EClass> getEClasses(IType type) {