Class ConstraintSplitWriter

    • Constructor Detail

      • ConstraintSplitWriter

        public ConstraintSplitWriter​(ConstraintSplitWriter.IConstraintFilter filter)
        Creates a split writer for the given writer and splits at constraint.
        Parameters:
        filter - the constraint filter identifying the split point
    • Method Detail

      • pre

        private boolean pre​(IModelElement context,
                            ConstraintSyntaxTree constraint)
        To be called before a potential split point (checking the filter).
        Parameters:
        context - the enclosing model element
        constraint - the constraint to check
        Returns:
        true if a split shall happen, false else
      • post

        private void post​(boolean split)
        To be called after a potential split point (checking the filter).
        Parameters:
        split - the output of the corresponding pre call
      • getBeforeText

        public java.lang.String getBeforeText()
        Returns the textual model representation before the constraint.
        Returns:
        the textual model representation before the constraint
      • getConstraintText

        public java.lang.String getConstraintText()
        Returns the textual model representation of the constraint.
        Returns:
        the textual model representation of the constraint
      • getAfterText

        public java.lang.String getAfterText()
        Returns the textual model representation after the constraint.
        Returns:
        the textual model representation after the constraint
      • getSplit

        public java.lang.String[] getSplit​(boolean trimConstraint,
                                           boolean trimParenthesis)
        Returns the split as needed for embedding xText editors.
        Parameters:
        trimConstraint - trim the constraint from leading/trailing whitespaces
        trimParenthesis - trims the constraint from a leading/trailing parenthesis moving them to prefix/suffix
        Returns:
        an array consisting of the values of getBeforeText(), getConstraintText() and getAfterText()
      • doTrim

        private static boolean doTrim​(char ch)
        Returns whether ch shall be trimmed.
        Parameters:
        ch - the character to check
        Returns:
        true if ch shall be trimmed, false else