Package org.eclipse.xtext.validation
Class NamesAreUniqueValidationHelper
- java.lang.Object
-
- org.eclipse.xtext.validation.NamesAreUniqueValidationHelper
-
- All Implemented Interfaces:
INamesAreUniqueValidationHelper
public class NamesAreUniqueValidationHelper extends java.lang.Object implements INamesAreUniqueValidationHelper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.xtext.validation.INamesAreUniqueValidationHelper
INamesAreUniqueValidationHelper.Context, INamesAreUniqueValidationHelper.ContextProvider
-
-
Constructor Summary
Constructors Constructor Description NamesAreUniqueValidationHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
checkDescriptionForDuplicatedName(IEObjectDescription description, java.util.Map<org.eclipse.emf.ecore.EClass,java.util.Map<QualifiedName,IEObjectDescription>> clusterTypeToName, ValidationMessageAcceptor acceptor)
void
checkUniqueNames(java.lang.Iterable<IEObjectDescription> descriptions, org.eclipse.xtext.util.CancelIndicator cancelIndicator, ValidationMessageAcceptor acceptor)
Deprecated.Since Xtext 2.22 implementations should adhere to the context provided viacheckUniqueNames(org.eclipse.xtext.validation.INamesAreUniqueValidationHelper.Context, ValidationMessageAcceptor)
.void
checkUniqueNames(java.lang.Iterable<IEObjectDescription> descriptions, ValidationMessageAcceptor acceptor)
Deprecated.Since Xtext 2.22 implementations should adhere to the context provided viacheckUniqueNames(org.eclipse.xtext.validation.INamesAreUniqueValidationHelper.Context, ValidationMessageAcceptor)
.void
checkUniqueNames(INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
Create errors for objects that have the same name according to the given context.protected void
createDuplicateNameError(IEObjectDescription description, org.eclipse.emf.ecore.EClass clusterType, ValidationMessageAcceptor acceptor)
protected void
doCheckUniqueIn(IEObjectDescription description, INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
protected void
doCheckUniqueNames(INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
protected org.eclipse.emf.ecore.EClass
getAssociatedClusterType(org.eclipse.emf.ecore.EClass eClass)
Return the type that describes the set of instances that should have unique names.protected org.eclipse.emf.ecore.EClass
getClusterType(IEObjectDescription description)
protected com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass>
getClusterTypes()
Initialize the set of clustering types.protected org.eclipse.emf.ecore.EObject
getContainerForErrorMessage(org.eclipse.emf.ecore.EObject object)
java.lang.String
getDuplicateNameErrorMessage(IEObjectDescription description, org.eclipse.emf.ecore.EClass clusterType, org.eclipse.emf.ecore.EStructuralFeature feature)
Build the error message for duplicated names.protected java.lang.String
getErrorCode()
Returnsnull
.protected org.eclipse.emf.ecore.EStructuralFeature
getNameFeature(org.eclipse.emf.ecore.EObject object)
protected java.lang.String
getTypeLabel(org.eclipse.emf.ecore.EClass eClass)
protected boolean
isContainerInformationHelpful(IEObjectDescription description, java.lang.String shortName)
protected boolean
isContainerInformationHelpful(IEObjectDescription description, org.eclipse.emf.ecore.EObject container, java.lang.String containerTypeLabel, org.eclipse.emf.ecore.EStructuralFeature containerNameFeature)
protected boolean
isDuplicate(IEObjectDescription description, IEObjectDescription candidate)
Called with two descriptions that have the same name.
-
-
-
Method Detail
-
getClusterTypes
protected com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass> getClusterTypes()
Initialize the set of clustering types. A type is considered to be clustering if any instance of that type has to have a unique name when it is transformed to an
IEObjectDescription
. Instances that do not belong to the same cluster may have the same exported name.A clustering type will often be some kind of root type in a type hierarchy.
-
checkUniqueNames
@Deprecated public void checkUniqueNames(java.lang.Iterable<IEObjectDescription> descriptions, ValidationMessageAcceptor acceptor)
Deprecated.Since Xtext 2.22 implementations should adhere to the context provided viacheckUniqueNames(org.eclipse.xtext.validation.INamesAreUniqueValidationHelper.Context, ValidationMessageAcceptor)
.Description copied from interface:INamesAreUniqueValidationHelper
Create errors for objects that have the same name. Objects that do not belong to the same cluster will not get any errors.- Specified by:
checkUniqueNames
in interfaceINamesAreUniqueValidationHelper
- See Also:
INamesAreUniqueValidationHelper.checkUniqueNames(Iterable, CancelIndicator, ValidationMessageAcceptor)
-
checkUniqueNames
@Deprecated public void checkUniqueNames(java.lang.Iterable<IEObjectDescription> descriptions, org.eclipse.xtext.util.CancelIndicator cancelIndicator, ValidationMessageAcceptor acceptor)
Deprecated.Since Xtext 2.22 implementations should adhere to the context provided viacheckUniqueNames(org.eclipse.xtext.validation.INamesAreUniqueValidationHelper.Context, ValidationMessageAcceptor)
.Create errors for objects that have the same name. Objects that do not belong to the same cluster will not get any errors. The cancel indicator may be used to abort the validation.
The cancel indicator will be queried everytime a description has been processed. It should provide a fast answer about its canceled state.- Specified by:
checkUniqueNames
in interfaceINamesAreUniqueValidationHelper
-
checkUniqueNames
public void checkUniqueNames(INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
Description copied from interface:INamesAreUniqueValidationHelper
Create errors for objects that have the same name according to the given context.- Specified by:
checkUniqueNames
in interfaceINamesAreUniqueValidationHelper
- Since:
- 2.22
-
doCheckUniqueNames
protected void doCheckUniqueNames(INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
- Since:
- 2.22
-
doCheckUniqueIn
protected void doCheckUniqueIn(IEObjectDescription description, INamesAreUniqueValidationHelper.Context context, ValidationMessageAcceptor acceptor)
- Since:
- 2.22
-
isDuplicate
protected boolean isDuplicate(IEObjectDescription description, IEObjectDescription candidate)
Called with two descriptions that have the same name. May be specialized to consider further information from the user data.- Since:
- 2.22
-
checkDescriptionForDuplicatedName
@Deprecated protected void checkDescriptionForDuplicatedName(IEObjectDescription description, java.util.Map<org.eclipse.emf.ecore.EClass,java.util.Map<QualifiedName,IEObjectDescription>> clusterTypeToName, ValidationMessageAcceptor acceptor)
-
createDuplicateNameError
protected void createDuplicateNameError(IEObjectDescription description, org.eclipse.emf.ecore.EClass clusterType, ValidationMessageAcceptor acceptor)
-
getErrorCode
protected java.lang.String getErrorCode()
Returnsnull
. Clients may override if they desire to attach an error code to the created errors.
-
getDuplicateNameErrorMessage
public java.lang.String getDuplicateNameErrorMessage(IEObjectDescription description, org.eclipse.emf.ecore.EClass clusterType, org.eclipse.emf.ecore.EStructuralFeature feature)
Build the error message for duplicated names. The default implementation will provide error messages of this form:- Duplicate Entity 'Sample'
- Duplicate Property 'Sample' in Entity 'EntityName'
-
isContainerInformationHelpful
protected boolean isContainerInformationHelpful(IEObjectDescription description, org.eclipse.emf.ecore.EObject container, java.lang.String containerTypeLabel, org.eclipse.emf.ecore.EStructuralFeature containerNameFeature)
-
isContainerInformationHelpful
protected boolean isContainerInformationHelpful(IEObjectDescription description, java.lang.String shortName)
-
getContainerForErrorMessage
protected org.eclipse.emf.ecore.EObject getContainerForErrorMessage(org.eclipse.emf.ecore.EObject object)
-
getTypeLabel
protected java.lang.String getTypeLabel(org.eclipse.emf.ecore.EClass eClass)
-
getNameFeature
protected org.eclipse.emf.ecore.EStructuralFeature getNameFeature(org.eclipse.emf.ecore.EObject object)
-
getClusterType
protected org.eclipse.emf.ecore.EClass getClusterType(IEObjectDescription description)
- Returns:
- the cluster type or
null
if the given description does not participate in the unique name validation. - Since:
- 2.22
- See Also:
getAssociatedClusterType(EClass)
-
getAssociatedClusterType
protected org.eclipse.emf.ecore.EClass getAssociatedClusterType(org.eclipse.emf.ecore.EClass eClass)
Return the type that describes the set of instances that should have unique names. The default information will return the topmost type or the first super type that is contained in the set of cluster types (getClusterTypes()
). Only the first super type will be taken into account when walking the hierarchy. Returnnull
if objects of the given type are not subject to validation.
-
-