Skip to content

Commit

Permalink
feat: modify Check generator to not reference event Collector
Browse files Browse the repository at this point in the history
Have it leave out ResourceValidationRuleSummaryEvent.Collector from the
generated 'validate' method signature so that the checkedTypeRef call to
create a JvmTypeReference to the particular inner class cannot fail.

That is something that apparently could in some situations happen.
  • Loading branch information
hasu committed Aug 19, 2024
1 parent 84b0674 commit 495431e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CheckGeneratorNaming {

/* Gets the name of the default validator class. */
def String defaultValidatorClassName() {
"AbstractDispatchingCheckImpl"
"DispatchingCheckImpl"
}

/* Gets the fully qualified name of the default validator class. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import com.avaloq.tools.ddk.check.generator.CheckGeneratorNaming
import com.avaloq.tools.ddk.check.generator.CheckPropertiesGenerator
import com.avaloq.tools.ddk.check.resource.CheckLocationInFileProvider
import com.avaloq.tools.ddk.check.runtime.configuration.ICheckConfigurationStoreService
import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl
import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl.DiagnosticCollector
import com.avaloq.tools.ddk.check.runtime.issue.AbstractIssue
import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl
import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl.DiagnosticCollector
import com.avaloq.tools.ddk.check.runtime.issue.SeverityKind
import com.avaloq.tools.ddk.check.validation.IssueCodes
import com.avaloq.tools.ddk.xtext.tracing.ResourceValidationRuleSummaryEvent
import com.google.common.collect.ImmutableMap
import com.google.common.collect.Lists
import com.google.inject.Inject
Expand Down Expand Up @@ -144,7 +143,7 @@ class CheckJvmModelInferrer extends AbstractModelInferrer {
]);

acceptor.accept(catalog.toClass(catalog.qualifiedValidatorClassName), [
val parentType = checkedTypeRef(catalog, typeof(AbstractDispatchingCheckImpl));
val parentType = checkedTypeRef(catalog, typeof(DispatchingCheckImpl));
if (parentType !== null) {
superTypes += parentType;
}
Expand Down Expand Up @@ -196,7 +195,6 @@ class CheckJvmModelInferrer extends AbstractModelInferrer {
parameters += catalog.toParameter("checkMode", checkedTypeRef(catalog, CheckMode));
parameters += catalog.toParameter("object", objectBaseJavaTypeRef);
parameters += catalog.toParameter("diagnosticCollector", checkedTypeRef(catalog, DiagnosticCollector));
parameters += catalog.toParameter("eventCollector", checkedTypeRef(catalog, ResourceValidationRuleSummaryEvent.Collector));
annotations += createAnnotation(checkedTypeRef(catalog, typeof(Override)), []);
body = [out | emitDispatcherMethodBody(out, catalog, objectBaseJavaTypeRef)];
]);
Expand Down Expand Up @@ -295,7 +293,7 @@ class CheckJvmModelInferrer extends AbstractModelInferrer {
out.newLine;
out.append('''
validate(«jMethodName», «qMethodName», object,
() -> «methodName»(«varName», diagnosticCollector), diagnosticCollector, eventCollector);''');
() -> «methodName»(«varName», diagnosticCollector), diagnosticCollector);''');
}

private def String toJavaLiteral(String... strings) {
Expand Down

0 comments on commit 495431e

Please sign in to comment.