Interface INamesAreUniqueValidationHelper.Context

  • All Known Implementing Classes:
    DefaultUniqueNameContext, LocalUniqueNameContext, UniqueInResourceContext
    Enclosing interface:
    INamesAreUniqueValidationHelper

    @Beta
    public static interface INamesAreUniqueValidationHelper.Context

    Provides context information to the validation that allows to introspect the scope in which the validation for unique names is supposed to happen.

    The term clusterType is used to denote a (super-)type of the current object under validation. When checking the name for uniqueness, all objects that are instances of the given cluster type are considered. This can be used to define different namespaces. For example, a language that has the concepts of Fields, Procedures and Functions may provide 2 different cluster types.

    1. All fields must have a unique name.
    2. The executable procedure and functions use the same namespace and may not have duplicate names.
    This would allow a field to use the same name as a procedure or function but raise an issue if a procedure has the same name as a function.

    Since:
    2.22
    • Method Detail

      • getValidationScope

        ISelectable getValidationScope​(IEObjectDescription description,
                                       org.eclipse.emf.ecore.EClass clusterType)

        Returns an ISelectable that can be queried for elements with a given name to find duplicates.

        Depending on the type of objects that have to have unique names, different selectables may be returned. Some objects must be unique per project, others must be globally unique or only unique per file. This API allows to fine tune the scope of the validation.

        Parameters:
        description - the description of the validated object.
        clusterType - the root type of the validated type hierarchy.
        Returns:
        the validation scope.
      • cancelIndicator

        org.eclipse.xtext.util.CancelIndicator cancelIndicator()
        The cancel-indicator that shall be used.
      • isCaseSensitive

        default boolean isCaseSensitive​(org.eclipse.emf.ecore.EObject object,
                                        org.eclipse.emf.ecore.EClass clusterType)
        Answers whether the names in the given cluster must be treated in a case sensistive or insensitive manner.
        See Also:
        ICaseInsensitivityHelper
      • isUnique

        default boolean isUnique()
        Context implementations that do know from their construction if they will or won't contain any duplicates, can override isUnique() to provide a more efficient means to validate all candidates at once.