Package de.gebit.integrity.validation
Class DSLJavaValidator
- java.lang.Object
-
- org.eclipse.xtext.validation.AbstractInjectableValidator
-
- org.eclipse.xtext.validation.AbstractDeclarativeValidator
-
- de.gebit.integrity.validation.AbstractDSLJavaValidator
-
- de.gebit.integrity.validation.DSLJavaValidator
-
- All Implemented Interfaces:
org.eclipse.emf.ecore.EValidator
,org.eclipse.xtext.validation.ValidationMessageAcceptor
public class DSLJavaValidator extends AbstractDSLJavaValidator
These validators perform some more extensive validation on parts of the syntax tree.- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.xtext.validation.AbstractDeclarativeValidator
org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper, org.eclipse.xtext.validation.AbstractDeclarativeValidator.State, org.eclipse.xtext.validation.AbstractDeclarativeValidator.StateAccess
-
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.EValidator
org.eclipse.emf.ecore.EValidator.Descriptor, org.eclipse.emf.ecore.EValidator.PatternMatcher, org.eclipse.emf.ecore.EValidator.Registry, org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider, org.eclipse.emf.ecore.EValidator.ValidationDelegate
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SHORTENABLE_REFERENCE
static java.lang.String
UNUSED_IMPORT
-
Fields inherited from class org.eclipse.xtext.validation.AbstractInjectableValidator
CURRENT_LANGUAGE_NAME, ISSUE_SEVERITIES
-
-
Constructor Summary
Constructors Constructor Description DSLJavaValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkParameter(Call aCall)
Polymorphic Dispatch of#checkParameter(Call)
.protected void
_checkParameter(SuiteStatementWithResult aCall)
Polymorphic Dispatch Default Case of#checkParameter(Call)
.protected void
_checkParameter(TableTest aTableTest)
Polymorphic Dispatch of#checkParameter(Call)
.protected void
_checkParameter(Test aTest)
Polymorphic Dispatch of#checkParameter(Call)
.protected void
checkForMissingParameter(java.util.Set<java.lang.String> someMandatoryParameters, java.util.Set<java.lang.String> someSpecifiedParameter)
Checks if some parameter is missing and reports this.protected java.util.Set<java.lang.String>
checkForNonNullableParameter(MethodReference aMethod, java.util.List<Parameter> someParameters)
Checks if the given method has a parameter that is non-nullable, but for which a null value is statically provided.void
checkForPrivateConstantInSuite(ConstantDefinition anEntity)
Checks for redundant private modifier.void
checkForPrivateVariableInSuite(VariableDefinition anEntity)
Checks for redundant private modifier.void
checkForShortenableReferences(PackageDefinition aDefinition)
void
checkForUnusedImports(Model aModel)
void
checkIfCallDefinitionsAreValid(CallDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).void
checkIfConstantDefinitionsAreValid(ConstantDefinition anEntity)
Checks whether a constant definition contains dots, which would be illegal (issue #171).void
checkIfConstantParameterizationIsPossible(ConstantDefinition aConstant)
Checks whether a parameterized constant is defined in a package scope.void
checkIfDateAndTimesAreValid(DateAndTimeValue aValue)
Checks whether a givenDateAndTimeValue
is actually correct.void
checkIfDatesAreValid(DateValue aValue)
Checks whether a givenDateValue
is actually correct (finds errors like days which don't exist in the given month).void
checkIfForkDefinitionsAreValid(ForkDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).void
checkIfOperationDefinitionsAreValid(OperationDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).void
checkIfRegexIsValid(RegexValue aValue)
Checks whether a given regex is valid.void
checkIfSuiteDefinitionsAreValid(SuiteDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).void
checkIfTestDefinitionsAreValid(TestDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).void
checkIfTimesAreValid(TimeValue aValue)
Checks whether a givenTimeValue
is actually correct.void
checkIfVariableDefinitionsAreValid(VariableDefinition anEntity)
Checks whether a variable definition contains dots, which would be illegal (issue #10).void
checkIfVariantDefinitionsAreValid(VariantDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).protected void
checkParameter(Parameter aParameter)
Checks for duplicate parameters.void
checkParameter(SuiteStatementWithResult aCall)
Checks for missing parameters.void
checkSuiteParameter(SuiteParameter aParameter)
Checks for redundant suite parameters.void
checkSuiteReturn(SuiteReturn aReturn)
Checks for redundant suite results.void
checkSuiteStatement(Suite aSuiteStatement)
Checks for redundant suite inline statements.protected java.util.Set<java.lang.String>
collectMandatoryParameterNames(java.util.Collection<FixtureParameterAssessment> aCollection)
Collects all mandatory parameter names and returns them.protected java.util.Set<java.lang.String>
collectNonNullableParameterNames(java.util.Collection<FixtureParameterAssessment> aCollection)
Collects all non-nullable parameter names and returns them.void
enableEditTimeValidations()
protected void
ensureParameterIsNotNullValue(org.eclipse.emf.ecore.EObject aParameterObject, org.eclipse.emf.ecore.EObject aParameterValue)
If the provided parameter is linked to a static null value, an error is generated.protected java.util.Set<java.lang.String>
getMandatoryParameterNamesOf(MethodReference aMethod)
Extracts all mandatory parameter names from the given method reference.protected void
performDotCheck(java.lang.String aName, java.lang.String anEntity)
A generic dot-checking method for entity names.protected void
performDotCheck(java.lang.String aName, java.lang.String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)
A generic dot-checking method for entity names.protected void
performSuiteParameterShadowingCheck(java.lang.String aName, org.eclipse.emf.ecore.EObject aContainer, java.lang.String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)
Checks for variable entities that overshadow suite input or return parameters.void
setReferenceLengthTarget(int aTarget)
void
setWarnUnusedImports(boolean aValue)
java.util.List<FixtureParameterAssessment>
wrap(java.lang.Iterable<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,org.eclipse.xtext.common.types.JvmAnnotationReference>> someParameters)
Wraps the parameter/annotation tuples in assessment objects for easier access and caches the processing results.-
Methods inherited from class de.gebit.integrity.validation.AbstractDSLJavaValidator
getEPackages
-
Methods inherited from class org.eclipse.xtext.validation.AbstractDeclarativeValidator
acceptError, acceptError, acceptInfo, acceptInfo, acceptWarning, acceptWarning, addIssue, addIssue, addIssue, addIssue, addIssue, addIssueToState, checkDone, checkIsFromCurrentlyCheckedResource, createDiagnostic, createDiagnostic, createMethodWrapper, error, error, error, error, error, error, error, error, getCancelIndicator, getChain, getCheckMode, getContext, getCurrentMethod, getCurrentObject, getIssueSeverities, getMessageAcceptor, guard, handleExceptionDuringValidation, info, info, info, info, info, info, info, info, internalValidate, isIgnored, newInstance, setInjector, setMessageAcceptor, toDiagnosticSeverity, warning, warning, warning, warning, warning, warning, warning, warning
-
-
-
-
Field Detail
-
SHORTENABLE_REFERENCE
public static final java.lang.String SHORTENABLE_REFERENCE
- See Also:
- Constant Field Values
-
UNUSED_IMPORT
public static final java.lang.String UNUSED_IMPORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
setReferenceLengthTarget
public void setReferenceLengthTarget(int aTarget)
-
enableEditTimeValidations
public void enableEditTimeValidations()
-
setWarnUnusedImports
public void setWarnUnusedImports(boolean aValue)
-
checkForShortenableReferences
public void checkForShortenableReferences(PackageDefinition aDefinition)
-
checkForUnusedImports
public void checkForUnusedImports(Model aModel)
-
checkIfDatesAreValid
public void checkIfDatesAreValid(DateValue aValue)
Checks whether a givenDateValue
is actually correct (finds errors like days which don't exist in the given month).- Parameters:
aValue
-
-
checkIfTimesAreValid
public void checkIfTimesAreValid(TimeValue aValue)
Checks whether a givenTimeValue
is actually correct.- Parameters:
aValue
-
-
checkIfDateAndTimesAreValid
public void checkIfDateAndTimesAreValid(DateAndTimeValue aValue)
Checks whether a givenDateAndTimeValue
is actually correct.- Parameters:
aValue
-
-
checkIfRegexIsValid
public void checkIfRegexIsValid(RegexValue aValue)
Checks whether a given regex is valid.- Parameters:
aValue
-
-
checkIfVariableDefinitionsAreValid
public void checkIfVariableDefinitionsAreValid(VariableDefinition anEntity)
Checks whether a variable definition contains dots, which would be illegal (issue #10).- Parameters:
anEntity
-
-
checkIfConstantDefinitionsAreValid
public void checkIfConstantDefinitionsAreValid(ConstantDefinition anEntity)
Checks whether a constant definition contains dots, which would be illegal (issue #171).- Parameters:
anEntity
-
-
checkIfForkDefinitionsAreValid
public void checkIfForkDefinitionsAreValid(ForkDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
checkIfVariantDefinitionsAreValid
public void checkIfVariantDefinitionsAreValid(VariantDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
checkIfSuiteDefinitionsAreValid
public void checkIfSuiteDefinitionsAreValid(SuiteDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
checkIfOperationDefinitionsAreValid
public void checkIfOperationDefinitionsAreValid(OperationDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
checkIfCallDefinitionsAreValid
public void checkIfCallDefinitionsAreValid(CallDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
checkIfTestDefinitionsAreValid
public void checkIfTestDefinitionsAreValid(TestDefinition anEntity)
Checks whether a definition contains dots, which would be illegal (issue #174).- Parameters:
anEntity
-
-
performDotCheck
protected void performDotCheck(java.lang.String aName, java.lang.String anEntity)
A generic dot-checking method for entity names. Generates a nice error message.- Parameters:
aName
-anEntity
-
-
performDotCheck
protected void performDotCheck(java.lang.String aName, java.lang.String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)
A generic dot-checking method for entity names. Generates a nice error message.- Parameters:
aName
-anEntityType
-
-
performSuiteParameterShadowingCheck
protected void performSuiteParameterShadowingCheck(java.lang.String aName, org.eclipse.emf.ecore.EObject aContainer, java.lang.String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)
Checks for variable entities that overshadow suite input or return parameters.- Parameters:
aName
-aContainer
-anEntityType
-aStructuralFeature
-
-
checkIfConstantParameterizationIsPossible
public void checkIfConstantParameterizationIsPossible(ConstantDefinition aConstant)
Checks whether a parameterized constant is defined in a package scope. It is not supported currently within suites.- Parameters:
aConstant
-
-
checkForPrivateVariableInSuite
public void checkForPrivateVariableInSuite(VariableDefinition anEntity)
Checks for redundant private modifier.- Parameters:
anEntity
-
-
checkForPrivateConstantInSuite
public void checkForPrivateConstantInSuite(ConstantDefinition anEntity)
Checks for redundant private modifier.- Parameters:
anEntity
-
-
checkSuiteStatement
public void checkSuiteStatement(Suite aSuiteStatement)
Checks for redundant suite inline statements.- Parameters:
aSuiteStatement
-
-
checkSuiteParameter
public void checkSuiteParameter(SuiteParameter aParameter)
Checks for redundant suite parameters.- Parameters:
aParameter
-
-
checkSuiteReturn
public void checkSuiteReturn(SuiteReturn aReturn)
Checks for redundant suite results.- Parameters:
aReturn
-
-
checkParameter
public void checkParameter(SuiteStatementWithResult aCall)
Checks for missing parameters.- Parameters:
aCall
- Call to be verified.
-
_checkParameter
protected void _checkParameter(Call aCall)
Polymorphic Dispatch of#checkParameter(Call)
.
-
_checkParameter
protected void _checkParameter(Test aTest)
Polymorphic Dispatch of#checkParameter(Call)
.
-
_checkParameter
protected void _checkParameter(TableTest aTableTest)
Polymorphic Dispatch of#checkParameter(Call)
.
-
_checkParameter
protected void _checkParameter(SuiteStatementWithResult aCall)
Polymorphic Dispatch Default Case of#checkParameter(Call)
.
-
checkParameter
protected void checkParameter(Parameter aParameter)
Checks for duplicate parameters.- Parameters:
aParameter
- the parameter to be checked
-
getMandatoryParameterNamesOf
protected java.util.Set<java.lang.String> getMandatoryParameterNamesOf(MethodReference aMethod)
Extracts all mandatory parameter names from the given method reference.- Parameters:
aMethod
- Method where to get the parameter names from.- Returns:
- All mandatory parameter names.
-
checkForMissingParameter
protected void checkForMissingParameter(java.util.Set<java.lang.String> someMandatoryParameters, java.util.Set<java.lang.String> someSpecifiedParameter)
Checks if some parameter is missing and reports this.- Parameters:
someMandatoryParameters
- Mandatory parameter names.someSpecifiedParameter
- Specified parameter names.
-
checkForNonNullableParameter
protected java.util.Set<java.lang.String> checkForNonNullableParameter(MethodReference aMethod, java.util.List<Parameter> someParameters)
Checks if the given method has a parameter that is non-nullable, but for which a null value is statically provided.- Parameters:
aMethod
- the method to checksomeParameters
- the parameters to check- Returns:
- the set of non-nullable parameters if any non-nullable parameters are present in the fixture method (regardless of whether violations were found), null otherwise
-
ensureParameterIsNotNullValue
protected void ensureParameterIsNotNullValue(org.eclipse.emf.ecore.EObject aParameterObject, org.eclipse.emf.ecore.EObject aParameterValue)
If the provided parameter is linked to a static null value, an error is generated.- Parameters:
aParameter
-
-
wrap
public java.util.List<FixtureParameterAssessment> wrap(java.lang.Iterable<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,org.eclipse.xtext.common.types.JvmAnnotationReference>> someParameters)
Wraps the parameter/annotation tuples in assessment objects for easier access and caches the processing results.- Parameters:
someParameters
- Parameters to wrap- Returns:
- Assessment classes for easier access.
-
collectMandatoryParameterNames
protected java.util.Set<java.lang.String> collectMandatoryParameterNames(java.util.Collection<FixtureParameterAssessment> aCollection)
Collects all mandatory parameter names and returns them.- Parameters:
aCollection
- Some parameter to get the mandatory names from.- Returns:
-
collectNonNullableParameterNames
protected java.util.Set<java.lang.String> collectNonNullableParameterNames(java.util.Collection<FixtureParameterAssessment> aCollection)
Collects all non-nullable parameter names and returns them.- Parameters:
aCollection
- Some parameter to get the mandatory names from.- Returns:
-
-