Class MergeFormattingSupport


  • public class MergeFormattingSupport
    extends Object
    Merge formatting support.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.eclipse.compare.internal.DocLineComparator createDocLineComparator​(org.eclipse.jface.text.IDocument document)
      Creates a new DocLineComparator for the given document with the "ignoreWhiteSpace" flag false.
      static com._1c.g5.gumtree.core.tree.INode generateGumTreeAST​(String moduleContent, org.eclipse.jface.text.IDocument moduleDocument)
      Generates GumTree AST for the given Bsl module content and document.
      static String merge​(String mainModuleContent, String otherModuleContent, MergeRule mergeRule)
      Runs 2-way merge for the given Bsl module text contents according to the special merge rule.
      static String merge​(String mainModuleContent, String otherModuleContent, String ancestorModuleContent, MergeRule mergeRule)
      Runs 3-way merge for the given Bsl module text contents according to the special merge rule.
      static String merge​(String mainModuleContent, String otherModuleContent, String ancestorModuleContent, MergeRule mergeRule, List<MergeResultDifference> mergeConflicts)
      Runs 3-way merge for the given Bsl module text contents according to the special merge rule and collects merge conflicts.
      static String mergeBslModuleWithParsingModuleStructure​(IComparisonSession session, BslModuleComparisonNode node, IBslModuleNodeContentProvider contentProvider, org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider)
      Merges the differences in the specified Bsl module node with parsing module structure.
      static com._1c.g5.gumtree.core.DiffsCreator runGumtreeDiffer​(org.eclipse.jface.text.IDocument mainModuleDocument, org.eclipse.jface.text.IDocument otherModuleDocument, org.eclipse.jface.text.IDocument ancestorModuleDocument, com._1c.g5.gumtree.core.tree.INode mainModuleTree, com._1c.g5.gumtree.core.tree.INode otherModuleTree, com._1c.g5.gumtree.core.tree.INode ancestorModuleTree, boolean runMovedBlockMatcher, boolean joinDiffBlocks)
      Runs GumTree 2-/3-way diff for the given Bsl modules.
    • Method Detail

      • merge

        public static String merge​(String mainModuleContent,
                                   String otherModuleContent,
                                   MergeRule mergeRule)
        Runs 2-way merge for the given Bsl module text contents according to the special merge rule. Main module content and other module content can not be null simultaneously.
        Parameters:
        mainModuleContent - the main text content, can be null
        otherModuleContent - the other text content, can be null
        mergeRule - the special merge rule, can not be null
        Returns:
        the result of merge, can be be null
      • merge

        public static String merge​(String mainModuleContent,
                                   String otherModuleContent,
                                   String ancestorModuleContent,
                                   MergeRule mergeRule)
        Runs 3-way merge for the given Bsl module text contents according to the special merge rule. Main module content and other module content can not be null simultaneously.
        Parameters:
        mainModuleContent - the main text content, can be null
        otherModuleContent - the other text content, can be null
        ancestorModuleContent - the ancestor text content, can be null
        mergeRule - the special merge rule, can not be null
        Returns:
        the result of merge, can be null
      • merge

        public static String merge​(String mainModuleContent,
                                   String otherModuleContent,
                                   String ancestorModuleContent,
                                   MergeRule mergeRule,
                                   List<MergeResultDifference> mergeConflicts)
        Runs 3-way merge for the given Bsl module text contents according to the special merge rule and collects merge conflicts. Main module content and other module content can not be null simultaneously.
        Parameters:
        mainModuleContent - the main text content, can be null
        otherModuleContent - the other text content, can be null
        ancestorModuleContent - the ancestor text content, can be null
        mergeRule - the special merge rule, can not be null
        mergeConflicts - the list to store merge conflicts, can not be null
        Returns:
        the result of merge, can be null
      • generateGumTreeAST

        public static com._1c.g5.gumtree.core.tree.INode generateGumTreeAST​(String moduleContent,
                                                                            org.eclipse.jface.text.IDocument moduleDocument)
                                                                     throws com._1c.g5.gumtree.core.tree.TreeGeneratorException
        Generates GumTree AST for the given Bsl module content and document.
        Parameters:
        moduleContent - the Bsl module content, can not be null
        moduleDocument - the Bsl module document, can not be null
        Returns:
        the newly generated AST, can not be null
        Throws:
        com._1c.g5.gumtree.core.tree.TreeGeneratorException
      • runGumtreeDiffer

        public static com._1c.g5.gumtree.core.DiffsCreator runGumtreeDiffer​(org.eclipse.jface.text.IDocument mainModuleDocument,
                                                                            org.eclipse.jface.text.IDocument otherModuleDocument,
                                                                            org.eclipse.jface.text.IDocument ancestorModuleDocument,
                                                                            com._1c.g5.gumtree.core.tree.INode mainModuleTree,
                                                                            com._1c.g5.gumtree.core.tree.INode otherModuleTree,
                                                                            com._1c.g5.gumtree.core.tree.INode ancestorModuleTree,
                                                                            boolean runMovedBlockMatcher,
                                                                            boolean joinDiffBlocks)
        Runs GumTree 2-/3-way diff for the given Bsl modules.
        Parameters:
        mainModuleDocument - the main module document, can not be null
        otherModuleDocument - the other module document, can not be null
        ancestorModuleDocument - the ancestor module document, may be null
        mainModuleTree - the main module GumTree AST, can not be null
        otherModuleTree - the other module GumTree AST, can not be null
        ancestorModuleTree - the ancestor module GumTree AST, can not be null
        runMovedBlockMatcher - defines whether the moved blocks matching is required
        joinDiffBlocks - defines whether the blocks joining is required
        Returns:
        DiffsCreator with found diffs, can not be null
      • createDocLineComparator

        public static org.eclipse.compare.internal.DocLineComparator createDocLineComparator​(org.eclipse.jface.text.IDocument document)
        Creates a new DocLineComparator for the given document with the "ignoreWhiteSpace" flag false.
        Parameters:
        document - the given IDocument, can not be null
        Returns:
        the DocLineComparator instance, can not be null
      • mergeBslModuleWithParsingModuleStructure

        public static String mergeBslModuleWithParsingModuleStructure​(IComparisonSession session,
                                                                      BslModuleComparisonNode node,
                                                                      IBslModuleNodeContentProvider contentProvider,
                                                                      org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider)
        Merges the differences in the specified Bsl module node with parsing module structure.
        Parameters:
        node - the Bsl module comparison node, cannot be null
        contentProvider - the Bsl module content provider for the specified side, cannot be null
        isThreeWay - tells whether the comparison/merge is three-way
        locationInFileProvider - the location in file provider, cannot be null
        Returns:
        the merged with parsing module structure Bsl module content, never null