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 StringSHORTENABLE_REFERENCEstatic StringUNUSED_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 voidcheckForMissingParameter(Set<String> someMandatoryParameters, Set<String> someSpecifiedParameter)Checks if some parameter is missing and reports this.protected Set<String>checkForNonNullableParameter(MethodReference aMethod, List<Parameter> someParameters)Checks if the given method has a parameter that is non-nullable, but for which a null value is statically provided.voidcheckForPrivateConstantInSuite(ConstantDefinition anEntity)Checks for redundant private modifier.voidcheckForPrivateVariableInSuite(VariableDefinition anEntity)Checks for redundant private modifier.voidcheckForShortenableReferences(PackageDefinition aDefinition)voidcheckForUnusedImports(Model aModel)voidcheckIfCallDefinitionsAreValid(CallDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).voidcheckIfConstantDefinitionsAreValid(ConstantDefinition anEntity)Checks whether a constant definition contains dots, which would be illegal (issue #171).voidcheckIfConstantParameterizationIsPossible(ConstantDefinition aConstant)Checks whether a parameterized constant is defined in a package scope.voidcheckIfDateAndTimesAreValid(DateAndTimeValue aValue)Checks whether a givenDateAndTimeValueis actually correct.voidcheckIfDatesAreValid(DateValue aValue)Checks whether a givenDateValueis actually correct (finds errors like days which don't exist in the given month).voidcheckIfForkDefinitionsAreValid(ForkDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).voidcheckIfOperationDefinitionsAreValid(OperationDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).voidcheckIfRegexIsValid(RegexValue aValue)Checks whether a given regex is valid.voidcheckIfSuiteDefinitionsAreValid(SuiteDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).voidcheckIfTestDefinitionsAreValid(TestDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).voidcheckIfTimesAreValid(TimeValue aValue)Checks whether a givenTimeValueis actually correct.voidcheckIfVariableDefinitionsAreValid(VariableDefinition anEntity)Checks whether a variable definition contains dots, which would be illegal (issue #10).voidcheckIfVariantDefinitionsAreValid(VariantDefinition anEntity)Checks whether a definition contains dots, which would be illegal (issue #174).protected voidcheckParameter(Parameter aParameter)Checks for duplicate parameters.voidcheckParameter(SuiteStatementWithResult aCall)Checks for missing parameters.voidcheckSuiteParameter(SuiteParameter aParameter)Checks for redundant suite parameters.voidcheckSuiteReturn(SuiteReturn aReturn)Checks for redundant suite results.voidcheckSuiteStatement(Suite aSuiteStatement)Checks for redundant suite inline statements.protected Set<String>collectMandatoryParameterNames(Collection<FixtureParameterAssessment> aCollection)Collects all mandatory parameter names and returns them.protected Set<String>collectNonNullableParameterNames(Collection<FixtureParameterAssessment> aCollection)Collects all non-nullable parameter names and returns them.voidenableEditTimeValidations()protected voidensureParameterIsNotNullValue(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 Set<String>getMandatoryParameterNamesOf(MethodReference aMethod)Extracts all mandatory parameter names from the given method reference.protected voidperformDotCheck(String aName, String anEntity)A generic dot-checking method for entity names.protected voidperformDotCheck(String aName, String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)A generic dot-checking method for entity names.protected voidperformSuiteParameterShadowingCheck(String aName, org.eclipse.emf.ecore.EObject aContainer, String anEntityType, org.eclipse.emf.ecore.EStructuralFeature aStructuralFeature)Checks for variable entities that overshadow suite input or return parameters.voidsetReferenceLengthTarget(int aTarget)voidsetWarnUnusedImports(boolean aValue)List<FixtureParameterAssessment>wrap(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 String SHORTENABLE_REFERENCE
- See Also:
- Constant Field Values
-
UNUSED_IMPORT
public static final 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 givenDateValueis 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 givenTimeValueis actually correct.- Parameters:
aValue-
-
checkIfDateAndTimesAreValid
public void checkIfDateAndTimesAreValid(DateAndTimeValue aValue)
Checks whether a givenDateAndTimeValueis 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(String aName, String anEntity)
A generic dot-checking method for entity names. Generates a nice error message.- Parameters:
aName-anEntity-
-
performDotCheck
protected void performDotCheck(String aName, 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(String aName, org.eclipse.emf.ecore.EObject aContainer, 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 Set<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(Set<String> someMandatoryParameters, Set<String> someSpecifiedParameter)
Checks if some parameter is missing and reports this.- Parameters:
someMandatoryParameters- Mandatory parameter names.someSpecifiedParameter- Specified parameter names.
-
checkForNonNullableParameter
protected Set<String> checkForNonNullableParameter(MethodReference aMethod, 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 List<FixtureParameterAssessment> wrap(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 Set<String> collectMandatoryParameterNames(Collection<FixtureParameterAssessment> aCollection)
Collects all mandatory parameter names and returns them.- Parameters:
aCollection- Some parameter to get the mandatory names from.- Returns:
-
collectNonNullableParameterNames
protected Set<String> collectNonNullableParameterNames(Collection<FixtureParameterAssessment> aCollection)
Collects all non-nullable parameter names and returns them.- Parameters:
aCollection- Some parameter to get the mandatory names from.- Returns:
-
-