Class 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
      • Fields inherited from interface org.eclipse.emf.ecore.EValidator

        MARKER, RELATED_URIS_ATTRIBUTE, URI_ATTRIBUTE
      • Fields inherited from interface org.eclipse.xtext.validation.ValidationMessageAcceptor

        INSIGNIFICANT_INDEX
    • Field Detail

      • SHORTENABLE_REFERENCE

        public static final java.lang.String SHORTENABLE_REFERENCE
        See Also:
        Constant Field Values
    • Constructor Detail

      • DSLJavaValidator

        public DSLJavaValidator()
    • 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 given DateValue 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 given TimeValue is actually correct.
        Parameters:
        aValue -
      • checkIfDateAndTimesAreValid

        public void checkIfDateAndTimesAreValid​(DateAndTimeValue aValue)
        Checks whether a given DateAndTimeValue 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 check
        someParameters - 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: