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 authored and rubenporras committed Aug 26, 2024
1 parent 84b0674 commit e29c3d3
Show file tree
Hide file tree
Showing 64 changed files with 40 additions and 2,687 deletions.
2 changes: 0 additions & 2 deletions com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ Require-Bundle: com.avaloq.tools.ddk.check.core,
org.eclipse.ui.ide,
org.eclipse.core.runtime,
org.eclipse.xtend.lib,
org.eclipse.xtext.junit4,
org.eclipse.xtext.ui.testing,
org.eclipse.xtext.testing,
org.junit,
org.mockito,
com.avaloq.tools.ddk.check.runtime.core,
org.eclipse.ui.workbench;resolution:=optional,
org.eclipse.xtext.xbase,
org.eclipse.xtext.xbase.junit,
org.eclipse.xtext.xbase.lib,
org.apache.logging.log4j,
org.apache.commons.lang,
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Require-Bundle: org.eclipse.ui,
com.avaloq.tools.ddk.test.ui,
com.avaloq.tools.ddk.check.runtime.core,
org.junit,
com.google.guava,
org.eclipse.xtext.junit4
com.google.guava
Export-Package: com.avaloq.tools.ddk.check.runtime.test.core
Import-Package: org.mockito,
org.mockito.stubbing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Require-Bundle: com.avaloq.tools.ddk.check.runtime.core,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.xtext,
org.eclipse.xtext.junit4,
org.eclipse.xtext.testing,
org.eclipse.xtext.ui.testing,
org.junit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.avaloq.tools.ddk.check.validation;

import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl;
import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl;
import com.avaloq.tools.ddk.check.testLanguage.Greeting;
import com.avaloq.tools.ddk.xtext.tracing.ResourceValidationRuleSummaryEvent;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import org.eclipse.emf.ecore.EObject;
Expand All @@ -15,7 +14,7 @@
* Validator for ExecutionEnvironment.
*/
@SuppressWarnings("all")
public class ExecutionEnvironmentCheckImpl extends AbstractDispatchingCheckImpl {
public class ExecutionEnvironmentCheckImpl extends DispatchingCheckImpl {
@Inject
private ExecutionEnvironmentCheckCatalog executionEnvironmentCatalog;

Expand All @@ -28,19 +27,19 @@ public final ImmutableMap<String, String> getIssueCodeToLabelMap() {
}

@Override
public void validate(final CheckMode checkMode, final EObject object, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector, final ResourceValidationRuleSummaryEvent.Collector eventCollector) {
public void validate(final CheckMode checkMode, final EObject object, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
if (checkMode.shouldCheck(CheckType.NORMAL)) {
diagnosticCollector.setCurrentCheckType(CheckType.NORMAL);
if (object instanceof final com.avaloq.tools.ddk.check.testLanguage.Greeting castObject) {
validate("greetingNameLengthGreeting", "ExecutionEnvironment.greetingNameLengthGreeting", object,
() -> greetingNameLengthGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector);
() -> greetingNameLengthGreeting(castObject, diagnosticCollector), diagnosticCollector);
}
}
}

private class GreetingNameLengthClass {

public void runGreeting(final Greeting g, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void runGreeting(final Greeting g, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
int _length = g.getName().length();
boolean _greaterThan = (_length > 5);
if (_greaterThan) {
Expand Down Expand Up @@ -78,7 +77,7 @@ public void runGreeting(final Greeting g, final AbstractDispatchingCheckImpl.Dia
* greetingNameLengthGreeting.
*/
@Check(CheckType.NORMAL)
public void greetingNameLengthGreeting(final Greeting context, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void greetingNameLengthGreeting(final Greeting context, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
greetingNameLengthImpl.runGreeting(context, diagnosticCollector);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.avaloq.tools.ddk.check.validation;

import com.avaloq.tools.ddk.check.lib.IResourceCache;
import com.avaloq.tools.ddk.check.runtime.issue.AbstractDispatchingCheckImpl;
import com.avaloq.tools.ddk.check.runtime.issue.DispatchingCheckImpl;
import com.avaloq.tools.ddk.check.testLanguage.Greeting;
import com.avaloq.tools.ddk.xtext.tracing.ResourceValidationRuleSummaryEvent;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
Expand All @@ -21,7 +20,7 @@
* Validator for LibraryChecks.
*/
@SuppressWarnings("all")
public class LibraryChecksCheckImpl extends AbstractDispatchingCheckImpl {
public class LibraryChecksCheckImpl extends DispatchingCheckImpl {
@Inject
private LibraryChecksCheckCatalog libraryChecksCatalog;

Expand All @@ -37,18 +36,18 @@ public final ImmutableMap<String, String> getIssueCodeToLabelMap() {
}

@Override
public void validate(final CheckMode checkMode, final EObject object, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector, final ResourceValidationRuleSummaryEvent.Collector eventCollector) {
public void validate(final CheckMode checkMode, final EObject object, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
if (checkMode.shouldCheck(CheckType.FAST)) {
diagnosticCollector.setCurrentCheckType(CheckType.FAST);
if (object instanceof final com.avaloq.tools.ddk.check.testLanguage.Greeting castObject) {
validate("checkCatalogIsActiveGreeting", "LibraryChecks.checkCatalogIsActiveGreeting", object,
() -> checkCatalogIsActiveGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector);
() -> checkCatalogIsActiveGreeting(castObject, diagnosticCollector), diagnosticCollector);
validate("cacheInjectionFailedGreeting", "LibraryChecks.cacheInjectionFailedGreeting", object,
() -> cacheInjectionFailedGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector);
() -> cacheInjectionFailedGreeting(castObject, diagnosticCollector), diagnosticCollector);
validate("cacheDoesntWorkGreeting", "LibraryChecks.cacheDoesntWorkGreeting", object,
() -> cacheDoesntWorkGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector);
() -> cacheDoesntWorkGreeting(castObject, diagnosticCollector), diagnosticCollector);
validate("formalParametersGreeting", "LibraryChecks.formalParametersGreeting", object,
() -> formalParametersGreeting(castObject, diagnosticCollector), diagnosticCollector, eventCollector);
() -> formalParametersGreeting(castObject, diagnosticCollector), diagnosticCollector);
}
}
}
Expand All @@ -57,7 +56,7 @@ public void validate(final CheckMode checkMode, final EObject object, final Abst
* checkCatalogIsActiveGreeting.
*/
@Check(CheckType.FAST)
public void checkCatalogIsActiveGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {// Issue diagnostic
public void checkCatalogIsActiveGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {// Issue diagnostic
libraryChecksCatalog.accept(diagnosticCollector, //
it, // context EObject
null, // EStructuralFeature
Expand All @@ -72,7 +71,7 @@ public void checkCatalogIsActiveGreeting(final Greeting it, final AbstractDispat
* cacheInjectionFailedGreeting.
*/
@Check(CheckType.FAST)
public void cacheInjectionFailedGreeting(final Greeting g, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void cacheInjectionFailedGreeting(final Greeting g, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
if ((LibraryChecksCheckImpl.this.cache == null)) {// Issue diagnostic
libraryChecksCatalog.accept(diagnosticCollector, //
g, // context EObject
Expand All @@ -89,7 +88,7 @@ public void cacheInjectionFailedGreeting(final Greeting g, final AbstractDispatc
* cacheDoesntWorkGreeting.
*/
@Check(CheckType.FAST)
public void cacheDoesntWorkGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void cacheDoesntWorkGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
String _qualifiedCatalogName = this.getQualifiedCatalogName();
final String key = (_qualifiedCatalogName + ".testValue");
try {
Expand Down Expand Up @@ -132,7 +131,7 @@ private class FormalParametersClass {



public void runGreeting(final Greeting it, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void runGreeting(final Greeting it, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
final String p1 = libraryChecksCatalog.getFormalParameters_Param1(it);
final boolean p2 = false;
final List<String> expectedNames = ImmutableList.<String>of("foo", "bar", "ba\u0001\nz");
Expand Down Expand Up @@ -255,7 +254,7 @@ public void runGreeting(final Greeting it, final AbstractDispatchingCheckImpl.Di
* formalParametersGreeting.
*/
@Check(CheckType.FAST)
public void formalParametersGreeting(final Greeting context, final AbstractDispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
public void formalParametersGreeting(final Greeting context, final DispatchingCheckImpl.DiagnosticCollector diagnosticCollector) {
formalParametersImpl.runGreeting(context, diagnosticCollector);
}
}
1 change: 0 additions & 1 deletion com.avaloq.tools.ddk.check.ui.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Require-Bundle: org.junit,
org.eclipse.xtext.common.types.ui,
org.eclipse.jdt.core,
org.eclipse.ui.ide,
org.eclipse.xtext.junit4,
org.eclipse.xtext.xbase.lib,
org.eclipse.core.runtime,
org.slf4j.ext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Require-Bundle: com.avaloq.tools.ddk.test.core,
org.eclipse.ui.ide,
org.eclipse.core.runtime,
org.eclipse.xtend.lib,
org.eclipse.xtext.junit4,
org.eclipse.xtext.ui.testing,
org.junit,
org.eclipse.xtext.xbase.lib,
Expand Down
7 changes: 0 additions & 7 deletions com.avaloq.tools.ddk.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,4 @@
version="0.0.0"
unpack="false"/>

<plugin
id="com.avaloq.tools.ddk.xtextspy"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ Bundle-ActivationPolicy: lazy
Require-Bundle: com.avaloq.tools.ddk.sample.helloworld,
com.avaloq.tools.ddk.sample.helloworld.ui,
org.junit,
org.eclipse.xtext.junit4,
org.eclipse.xtext.ui.testing,
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing,
org.eclipse.xtext.xbase.lib,
org.eclipse.core.runtime,
org.eclipse.ui.workbench;resolution:=optional,
org.eclipse.xtext.xbase.junit,
com.avaloq.tools.ddk.check.runtime.core,
com.avaloq.tools.ddk.check.runtime.ui,
com.avaloq.tools.ddk.check.core.test,
Expand Down
7 changes: 0 additions & 7 deletions com.avaloq.tools.ddk.source.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,4 @@
version="0.0.0"
unpack="false"/>

<plugin
id="com.avaloq.tools.ddk.xtextspy.source"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Bundle-ActivationPolicy: lazy
Export-Package: com.avaloq.tools.ddk.xtext.format.ui;x-internal=true
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.workbench;resolution:=optional,
org.eclipse.xtext.junit4,
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.junit,
org.eclipse.xtext.xbase.testing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Require-Bundle: com.avaloq.tools.ddk.test.core,
org.eclipse.xtend,
org.eclipse.xtend.typesystem.emf,
org.eclipse.xtext,
org.eclipse.xtext.junit4,
org.junit,
org.mockito,
com.avaloq.tools.ddk.xtext.ui,
Expand Down
1 change: 0 additions & 1 deletion com.avaloq.tools.ddk.xtext.test.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Require-Bundle: com.avaloq.tools.ddk.xtext,
org.eclipse.pde.core,
org.eclipse.ui.ide,
org.eclipse.xtend.lib,
org.eclipse.xtext.junit4;visibility:=reexport,
org.eclipse.xtext.testing;visibility:=reexport,
org.eclipse.xtext.ui.testing;visibility:=reexport,
org.eclipse.xtext.ui,
Expand Down
Loading

0 comments on commit e29c3d3

Please sign in to comment.