Class AbstractEmfBasedComparisonParticipant

    • Constructor Detail

      • AbstractEmfBasedComparisonParticipant

        protected AbstractEmfBasedComparisonParticipant()
        Creates new participant instance with default comparison nodes factory.
      • AbstractEmfBasedComparisonParticipant

        protected AbstractEmfBasedComparisonParticipant​(ComparisonNodeFactory nodeFactory)
        Creates new participant instance with specific comparison nodes factory.
        Parameters:
        nodeFactory - the node factory to use, cannot be null
    • Method Detail

      • supportsMergingUsingExternalTool

        public boolean supportsMergingUsingExternalTool​(ComparisonNode node,
                                                        IComparisonSession session)
        Description copied from interface: IComparisonParticipant
        Tells whether the given node supports merging using external tool.
        Specified by:
        supportsMergingUsingExternalTool in interface IComparisonParticipant
        Parameters:
        node - the comparison node to check, cannot be null
        session - the comparison session, cannot be null
        Returns:
        true if the node supports merging using external tool, false otherwise
      • isExcludedFromComparison

        public boolean isExcludedFromComparison​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                                AbstractComparedEmfObjects<?> comparedContextObjects,
                                                IComparisonSession session)
        Description copied from interface: IComparisonParticipant
        Checks whether the feature must be excluded from the comparison.
        Specified by:
        isExcludedFromComparison in interface IComparisonParticipant
        Parameters:
        feature - the feature to check, cannot be null
        comparedContextObjects - the triple of compared objects, cannot be null
        session - the comparison session, cannot be null
        Returns:
        true if the feature must be excluded, false otherwise
      • getForcedDDRebuildScope

        public Map<String,​IBmObject> getForcedDDRebuildScope​(TopComparisonNode topNode,
                                                                   MergeContext context)
        Description copied from interface: IComparisonParticipant
        In case if the merge process changes the top object it should supply information about affected DDs.
        Specified by:
        getForcedDDRebuildScope in interface IComparisonParticipant
        Parameters:
        topNode - The top node of the comparison model representing the merged object, not null
        context - Current merge operation context, not null
        Returns:
        The map of the affected DD segments and corresponding objects, may be empty, never null
      • adoptMainSideFeature

        public org.eclipse.emf.ecore.EStructuralFeature adoptMainSideFeature​(org.eclipse.emf.ecore.EStructuralFeature mainSideFeature,
                                                                             IComparisonSession session)
        Description copied from interface: IComparisonParticipant
        Converts, if possible, the main side feature into a other supported by the other side object.
        Specified by:
        adoptMainSideFeature in interface IComparisonParticipant
        Parameters:
        mainSideFeature - the main side feature to convert, cannot be null
        session - the comparison session, cannot be null
        Returns:
        the converted feature applicable for other side object or null
      • saveCustomSettings

        public void saveCustomSettings​(ComparisonNode node,
                                       SerializableMergeSettings container,
                                       IComparisonSession session)
        Description copied from interface: IComparisonParticipant
        Saves custom settings for the specified node into the given merge settings container. Does nothing if the node doesn't have any custom settings.
        Specified by:
        saveCustomSettings in interface IComparisonParticipant
        Parameters:
        node - the comparison node to save custom settings for, cannot be null
        container - the container of serializable settings, cannot be null
        session - the comparison session, cannot be null
      • mergeUsingExternalTool

        public ExternalMergeToolResult mergeUsingExternalTool​(ComparisonNode node,
                                                              ComparisonContext comparisonContext,
                                                              org.eclipse.core.runtime.IProgressMonitor monitor)
        Description copied from interface: IComparisonParticipant
        Merges nodes using an external tool that are supported by this participant.
        Specified by:
        mergeUsingExternalTool in interface IComparisonParticipant
        Parameters:
        node - the comparison node, cannot be null
        comparisonContext - the comparison context, cannot be null
        monitor - the progress monitor, cannot be null
        Returns:
        the external merge tool result or null if no nodes were merged
      • createResourceForImportedObject

        protected void createResourceForImportedObject​(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory,
                                                       org.eclipse.emf.ecore.EObject originalObject,
                                                       org.eclipse.emf.ecore.EObject importedObject,
                                                       MergeContext context)
        Creates resource using given factory for given imported object.
        Parameters:
        resourceFactory - the factory, cannot be null
        originalObject - the original object, cannot be null
        importedObject - the imported object, cannot be null
        the - current merge context, cannot be null
      • getFeatureTypeDescription

        protected String getFeatureTypeDescription​(org.eclipse.emf.ecore.EStructuralFeature feature)
      • compareReference

        protected ComparisonFlags compareReference​(TopComparisonNode topParent,
                                                   LazyNodeProvider<? extends ComparisonNode> nodeProvider,
                                                   AbstractComparedEmfObjects<?> comparingObject,
                                                   ComparedFeatures<org.eclipse.emf.ecore.EReference> comparedReferences,
                                                   ComparisonContext comparisonContext)
        Compares a non-containment reference feature.
        Parameters:
        topParent - the top parent node, cannot be null
        nodeProvider - the provider of the node hosting the compared EObject, cannot be null
        comparingObject - the triple of parent objects containing the given feature, cannot be null
        comparedReferences - the triple of reference features to be compared, cannot be null
        comparisonContext - the current comparison context, cannot be null
        Returns:
        the resulting flags, never null
      • getSingleReferenceSymlink

        protected String getSingleReferenceSymlink​(org.eclipse.emf.ecore.EObject contextObject,
                                                   org.eclipse.emf.ecore.EReference reference,
                                                   IComparisonSession session,
                                                   ComparisonSide side)
        Returns a symbolic link for an object defined by a single reference from the given context object.
        Parameters:
        contextObject - the context object owning the feature, cannot be null
        reference - the single reference feature, cannot be null
        session - the comparison session, cannot be null
        side - the comparison side where the context object lies, cannot be null
        Returns:
        symbolic link or null if there is no target object indentified by a symbolic name in the specified context object
      • getMultiReferenceSymlinks

        protected List<String> getMultiReferenceSymlinks​(org.eclipse.emf.ecore.EObject contextObject,
                                                         org.eclipse.emf.ecore.EReference reference,
                                                         IComparisonSession session,
                                                         ComparisonSide side)
        Returns list of symbolic links for objects referenced by the specified multi-reference feature from the specified context object.
        Parameters:
        contextObject - the context object owning the feature, cannot be null
        reference - the multi-reference feature, cannot be null
        session - the comparison session, cannot be null
        side - the comparison side where the context object lies, cannot be null
        Returns:
        list of symbolic links, may be empty, never null
      • getMultiReferenceValueSymlink

        protected String getMultiReferenceValueSymlink​(org.eclipse.emf.ecore.EObject contextObject,
                                                       org.eclipse.emf.ecore.EReference reference,
                                                       org.eclipse.emf.ecore.EObject targetObject,
                                                       IComparisonSession session,
                                                       ComparisonSide side)
        Returns symbolic link of the specified target object lying into collection of referencing objects specified by the given multi-reference feature.
        Parameters:
        contextObject - the context object owning the multi-reference feature, cannot be null
        reference - the multi-reference feature, cannot be null
        targetObject - the object to get symbolic link for, cannot be null
        session - the comparison session, cannot be null
        side - the comparison side where the context object lies, cannot be null
        Returns:
        symbolic link or null in case the target object cannot be indentified by a symbolic name in the specified context object
      • compareEmfContainment

        protected ComparisonFlags compareEmfContainment​(TopComparisonNode topParent,
                                                        LazyNodeProvider<? extends ComparisonNode> nodeProvider,
                                                        AbstractComparedEmfObjects<?> comparingObject,
                                                        ComparedFeatures<org.eclipse.emf.ecore.EReference> comparedReferences,
                                                        AbstractEmfBasedComparisonParticipant.BmIdsWrapper childBmIds,
                                                        ComparisonContext comparisonContext)
        Compares containment feature.
        Parameters:
        topParent - the top parent comparison node, cannot be null
        nodeProvider - the lazy provider for the parent comparison node, cannot be null
        comparingObject - the triple of parent objects containing the specified feature, cannot be null
        comparedReferences - the containment features to be compared, cannot be null
        childBmIds - collector of indexes of child nodes to be compared later, cannot be null
        comparisonContext - the comparison context, cannot be null
        Returns:
        the resulting comparison flags, never null
      • isUnmatchableContainment

        protected boolean isUnmatchableContainment​(org.eclipse.emf.ecore.EReference reference)
        Checks whether the specified containment feature cannot be matched by an identity-based matcher.
        Parameters:
        reference - the containment feature to check
        Returns:
        true if the feature cannot be matched by an identity matcher
      • getFeaturesToCompareForOneSideObject

        protected List<org.eclipse.emf.ecore.EReference> getFeaturesToCompareForOneSideObject​(AbstractComparedEmfObjects<?> comparingObjects)
        Returns list of features to be always compared for one-side nodes.
        Parameters:
        comparingObjects - the triple of objects being compared, cannot be null
        Returns:
        the list of feature to be compared for one-side nodes, never null
      • getCustomMatcher

        protected IEmfObjectMatcher getCustomMatcher​(TopComparisonNode topNode,
                                                     org.eclipse.emf.ecore.EReference reference,
                                                     ComparisonContext comparisonContext)
        Returns a custom matcher for the specified reference.
        Parameters:
        topNode - the top node
        reference - the reference to get a custom matcher for
        comparisonContext - the current comparison context, cannot be null
        Returns:
        a custom matcher or null if no custom matcher can be found
      • assertEClassesMatch

        protected static void assertEClassesMatch​(org.eclipse.emf.ecore.EObject object1,
                                                  org.eclipse.emf.ecore.EObject object2)
        Asserts whether the two specified EObjects have identical EClasses.
        Parameters:
        object1 - the first EObject
        object2 - the second EObject
      • areDifferentEClassObjectsMergeable

        protected boolean areDifferentEClassObjectsMergeable​(org.eclipse.emf.ecore.EObject main,
                                                             org.eclipse.emf.ecore.EObject other,
                                                             ComparisonContext comparisonContext)
      • importEmfObject

        protected org.eclipse.emf.ecore.EObject importEmfObject​(MergeContext context,
                                                                ComparisonNode mergingNode,
                                                                org.eclipse.emf.ecore.EObject otherObject)
      • translateReferencesInImportedObject

        protected void translateReferencesInImportedObject​(org.eclipse.emf.ecore.EObject eObject,
                                                           MergeContext mergeContext)
      • wrapOtherReference

        protected org.eclipse.emf.ecore.EObject wrapOtherReference​(MergeContext context,
                                                                   org.eclipse.emf.ecore.EObject otherObject,
                                                                   org.eclipse.emf.ecore.EReference eReference,
                                                                   org.eclipse.emf.ecore.EObject otherValue)
      • adaptOtherReference

        protected org.eclipse.emf.ecore.EObject adaptOtherReference​(MergeContext context,
                                                                    org.eclipse.emf.ecore.EObject otherObject,
                                                                    org.eclipse.emf.ecore.EReference eReference,
                                                                    org.eclipse.emf.ecore.EObject otherValue,
                                                                    org.eclipse.emf.ecore.EObject mainObject)
      • createImportedEObject

        protected abstract org.eclipse.emf.ecore.EObject createImportedEObject​(org.eclipse.emf.ecore.EObject otherObject,
                                                                               IMergeSession mergeSession)
      • isFeatureWithCustomMerge

        protected abstract boolean isFeatureWithCustomMerge​(org.eclipse.emf.ecore.EStructuralFeature feature)
      • getExternalPropertySymlink

        protected abstract String getExternalPropertySymlink​(TopComparisonNode node,
                                                             org.eclipse.emf.ecore.EReference externalProperty,
                                                             ComparisonSide side,
                                                             org.eclipse.emf.ecore.EObject eObject)
        Returns the symbolic link (FQN) of the specified external property.
        Parameters:
        node - the node with the external property
        externalProperty - the EReference to the external property
        side - the comparison side
        eObject - the EObject referencing the external property
        Returns:
        the symbolic link
      • getExternalPropertyQualifyingType

        protected abstract String getExternalPropertyQualifyingType​(org.eclipse.emf.ecore.EObject eObject,
                                                                    org.eclipse.emf.ecore.EReference externalProperty)
        Returns the EClass of the specified external property of the specified EObject.
        Parameters:
        eObject -
        externalProperty -
        Returns:
      • hasConflictChangesInCollection

        protected boolean hasConflictChangesInCollection​(ComparedFeatures<org.eclipse.emf.ecore.EReference> comparedReferences,
                                                         Collection<? extends MatchedEmfObjects> matchedElements)
        Tells whether the collection being compared should be treated as containing conflicts.
        Parameters:
        comparedReferences - the triple of many-features being compared, cannot be null
        Returns:
        true if the collection should be treated as containing conflicts, false otherwise
      • comparePictureResource

        protected ComparisonFlags comparePictureResource​(AbstractComparedEmfObjects<?> comparingObject,
                                                         ComparisonContext comparisonContext)
        Compares picture resource for compared PictureDef's.
        Parameters:
        comparingObject - the triple of PictureDef's to be compared, can not be null
        comparisonContext - the current comparison context, can not be null
        Returns:
        the resulting flags, never null
      • importPictureResourceFile

        protected void importPictureResourceFile​(PictureDef picture,
                                                 MergeContext context)
        Creates a IPostponedFileOperation to import the other side picture resource.
        Parameters:
        picture - the other side picture to create an add operation for, can not be null
        context - the merge context, can not be null
      • updatePictureResourceFile

        protected void updatePictureResourceFile​(PictureDef mainPicture,
                                                 PictureDef otherPicture,
                                                 IMergeSession session)
        Updates the main picture resource file with the other picture resource. If the other resource doesn't exist the main resource file will be deleted.
        Parameters:
        mainPicture - the main side picture, can not be null
        otherPicture - the other side picture, can not be null
        session - the merge session, can not be null
      • deletePictureResourceFile

        protected void deletePictureResourceFile​(PictureDef mainPicture,
                                                 IMergeSession session)
        Deletes the main picture resource file.
        Parameters:
        mainPicture - the main side picture, can not be null
        session - the merge session, can not be null
      • getPictureResourcePath

        protected Path getPictureResourcePath​(PictureDef picture,
                                              IComparisonDataSource dataSource)
        Returns the picture resource path for the given data source. By default returns null.
        Parameters:
        picture - the picture to get resource path for, cannot be null
        dataSource - the comparison data source, cannot be null
        Returns:
        the picture resource path, may be null
      • adoptEClassToImport

        protected org.eclipse.emf.ecore.EClass adoptEClassToImport​(org.eclipse.emf.ecore.EClass otherEClass,
                                                                   IComparisonSession session)
        Converts, if possible, the other side EClass into a main supported by the main side to import object.
        Parameters:
        otherEClass - the other side EClass to convert, cannot be null
        session - the comparison session, cannot be null
        Returns:
        the converted EClass, never null
      • getOtherSideFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getOtherSideFeature​(org.eclipse.emf.ecore.EStructuralFeature mainSideFeature,
                                                                               IComparisonSession session)
        Converts, if possible, the main side feature into a other supported by the other side object. Returns the given main side feature if no convert was found.
        Parameters:
        mainSideFeature - the main side feature to convert, cannot be null
        session - the comparison session, cannot be null
        Returns:
        the converted feature applicable for other side object or given main side feature if no convert was found, never null
      • needCreateOneSideNode

        protected static boolean needCreateOneSideNode​(AbstractComparedEmfObjects<?> comparedObjects,
                                                       ComparisonFlags nodeFlags,
                                                       boolean threeWay)
        Checks whether we need to create one-side node for the compared objects.
        Parameters:
        comparedObjects - the compared objects to check, must have object only on MAIN or on OTHER side, cannot be null
        nodeFlags - the node flags calculated for it, cannot be null
        threeWay - is three-way merge
        Returns:
        true if need to create the node in the model, false otherwise
      • getQualifiedName

        protected static org.eclipse.xtext.naming.QualifiedName getQualifiedName​(String symlink)
        Splits the given symlink into segments and returns them as a QualifiedName.
        Parameters:
        symlink - the given symlink, can not be null
        Returns:
        a qualified name, never null
      • removeObjectFromListOnMerge

        protected void removeObjectFromListOnMerge​(MergeContext context,
                                                   org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> mainList,
                                                   org.eclipse.emf.ecore.EObject mainObject)
        Removes the given object from the given list on the MAIN side during the merge phase. Override in descendants if need customized behavior on deletion.
        Parameters:
        context - the merge context, cannot be null
        mainList - the list to remove the object from, cannot be null
        mainObject - the object to be removed, cannot be null
      • removeObjectFromContainerOnMerge

        protected void removeObjectFromContainerOnMerge​(MergeContext context,
                                                        org.eclipse.emf.ecore.EObject mainContainer,
                                                        org.eclipse.emf.ecore.EReference mainReference,
                                                        org.eclipse.emf.ecore.EObject mainObject)
        Removes the given object from the container on the MAIN side during the merge phase. Override in descendants if need customized behavior on deletion.
        Parameters:
        context - the merge context, cannot be null
        mainContainer - the container to remove from, cannot be null
        mainReference - the reference to remove object by, cannot be null
        mainObject - the object to be removed, cannot be null
      • setObjectToContainerOnMerge

        protected void setObjectToContainerOnMerge​(MergeContext context,
                                                   ComparisonNode mergingNode,
                                                   org.eclipse.emf.ecore.EObject mainContainer,
                                                   org.eclipse.emf.ecore.EReference mainReference,
                                                   org.eclipse.emf.ecore.EObject eObject)
        Sets the object to the given container on the MAIN side.
        Parameters:
        context - the merge context, cannot be null
        mergingNode - the comparison node related to the merging feature, cannot be null
        mainContainer - the container to add into, cannot be null
        mainReference - the reference to add object by, cannot be null
        eObject - the object to be added, cannot be null
      • isBmIdMayChangeOnMerge

        protected boolean isBmIdMayChangeOnMerge​(IBmObject bmObject)
        Tells whether bmId of an object may change during the merge phase. Override in descendants for specific types.
        Parameters:
        bmObject - the object to be checked, cannot be null
        Returns:
        true if bmId may change, false otherwise
      • getNodeFactory

        protected ComparisonNodeFactory getNodeFactory()
        Gets factory to create new comparison nodes.
        Returns:
        the comparison node factory instance, never null