Interface ICheckDefinition


  • public interface ICheckDefinition
    Defines the check's operational metada. The developer can/should provide the following information via this interface:
    • Define EClass'es of BSL language model that are being validated by this check (if any) in case of language module change/import/clean rebuild
    • Add model context collectors (see the OnModelFeatureChangeContextCollector or OnModelObjectAssociationContextCollector for details) which is called on model object association or feature change events
    • Add language context collectors (see the OnLanguageResourceChangesContextCollector for details) which is called on language module creation or change events
    • Define parameters of the check, which will be available for editing via the check management page in the EDT
    • Change the complexity of the check to help the ACC to improve the effectiveness of checks
    • Set the check default complexity and enablement
    • Set the descriptive information for check

    Please note that the check uses the following scheme to define the descriptive information for the check:
    • The title of the check should be defined via the check itself, using the CheckDescription#CheckDescription(String, String, String, IssueType, boolean, IssueSeverity, String, java.util.Map) constructor. The standard Eclipse localized strings could be used to define the multi-language titles
    • The check developer may specify the default description of the check via the check itself using the CheckDescription#CheckDescription(String, String, String, IssueType, boolean, IssueSeverity, String, java.util.Map) constructor. Same approach to localization as with title
    • The check developer may specify localizations (preferred method) as a set of external html files stored in the following structure:
      • The root resource folder is a 'check.descriptions' (the name of the folder, not the structure) residing in the root 'src' folder of the check supplying bundle. Please note that the folder should be in the bundle that defines the extension that registers the target check
      • The root resource folder may contains a set of locale-specific subfolders. Names should match the Locale.getLanguage() convention to be eligible by the EDT
      • The localized description should be placed in the file with the name matching the following pattern <checkId>.html, where <checkId> is an unique identifier of the target check
      • The localized description which is placed in the locale-specific subfolder will be used for the corresponding locale. In order to define the default localization the developer should place the localization file in the 'check.descriptions' folder
      • Different localization have the following priority (from highest to lowest): locale-specific file > default file > in-check description
    • Method Detail

      • addCheckedLanguageObjects

        void addCheckedLanguageObjects​(Set<org.eclipse.emf.ecore.EClass> targetTypes)
        Adds a set of target language object types that will be searched within the module and supplied as contexts in subsequen calls of ICheck.check(Object, ICheckResultAcceptor, ICheckParameters, org.eclipse.core.runtime.IProgressMonitor) In order for the check to support language object validation, at least one checked object type should be supplied (usually it's a MODULE itself)
        Parameters:
        targetTypes - The set of target object types. May not be null
      • addModelAssociationContextCollector

        void addModelAssociationContextCollector​(OnModelObjectAssociationContextCollector collector,
                                                 org.eclipse.emf.ecore.EClass targetEClass)
        Adds a collector of check contexts that are used to schedule the check in case of a new object with a given EClass is being added to the configuration.
        Multiple calls of this method for the same EClass are allowed, all collectors are being collected
        Parameters:
        collector - The collector to add. May not be null
        targetEClass - The EClass of an added object to track. May not be null
      • addModelFeatureChangeContextCollector

        void addModelFeatureChangeContextCollector​(OnModelFeatureChangeContextCollector collector,
                                                   org.eclipse.emf.ecore.EClass targetEClass)
        Adds a collector of check contexts that are used to schedule the check in case of a feature changes of the EClass objects.
        Multiple calls of this method for the same EClass are allowed, all collectors are being collected
        Parameters:
        collector - The collector to add. May not be null
        targetEClass - The EClass of an object which changed features we are going to track. May not be null
      • addCheckedModelObjects

        void addCheckedModelObjects​(org.eclipse.emf.ecore.EClass topObjectEClass,
                                    boolean includeTop,
                                    Set<org.eclipse.emf.ecore.EClass> containedObjectEClasses)
        Defines a rebuild scope collector for the given type of the top object. All scope collectors associated with non-top model objects will be ignored during the work of the checking infrastructure. The developer should register at least one rebuild scope collector in order for the check to be able to participate in the model check process.
        Parameters:
        topObjectEClass - The EClass of the top object, may not be null
        includeTop - The flag that defines the participation of the top object itself in the check
        containedObjectEClasses - The set of EClass'es of contained objects that are checked during the check process. May be not null
      • setComplexity

        void setComplexity​(CheckComplexity complexity)
        Sets the complexity of the check. The check could be either normal (so not time/resource consuming) or complex. All normal checks are performed first followed by complex ones. In case if not set, the system automatically marks this check as normal
        Parameters:
        complexity - The complexity to set. May not be null
      • setDefaultSeverity

        void setDefaultSeverity​(IssueSeverity severity)
        Sets the default severity of issues produced by this check. The issue has a default severity of IssueSeverity.MINOR in case if not set during the check configuration
        Parameters:
        severity - The severity to set. May not be null
      • setDescription

        void setDescription​(String description)
        Sets the dispayable description of the check. May be left unitialized, in this case the system will check the corresponding resource with external description of the check. Please see the ICheckDefinition#setDescriptionStoreBundleIdentifier(String) for details
        Parameters:
        description - The description to set. May not be null
      • setEnabled

        void setEnabled​(boolean enabled)
        Sets the default enablement status for the check. In case if the check is expensive/situational, the developer could state that it should be enabled manually by the client to be able to perform. By default all checks are enabled
        Parameters:
        enabled - True if the check is enabled by default, false otherwise
      • setIssueType

        void setIssueType​(IssueType issueType)
        Sets the type of issues this check is able to generate. May be left unitialized, in this case the issue type will be set to IssueType.WARNING
        Parameters:
        issueType - The type of the issue. May not be null
      • setLanguageResourceChangeContextCollector

        void setLanguageResourceChangeContextCollector​(OnLanguageResourceChangesContextCollector collector)
        Adds a context collector that reacts on languge/resource changes. The developer could use these collectors to schedule checks that depends on the language module/resource state.
        Parameters:
        collector - The collector to add, may not be null
      • setTitle

        void setTitle​(String title)
        Sets the dispayable title of the check. May be left unitialized, in this case the title of the check will be taken from the check identifier
        Parameters:
        title - The title to set. May not be null
      • addDelegatedTypes

        void addDelegatedTypes​(Class<?>... delegatedTypes)
        Adds types of objects provided by the delegating checks (see the ICheckResultAcceptor.delegateChecks(Iterable)) that are being handled by this check
        Parameters:
        delegatedTypes - The set object types that are delegated. May not be empty
      • setDelegateApplianceFilter

        void setDelegateApplianceFilter​(IDelegateApplicabilityFilter filter)
        Sets an optional filter for any contexts for checks that delegated checking to subsidiary checks. See the IDelegateApplicabilityFilter for details
        Parameters:
        filter - The filter to set. May not be null