Package com.puppetlabs.xtext.dommodel

Examples of com.puppetlabs.xtext.dommodel.RegionMatch


    }
  }

  @Override
  protected void formatWhitespace(StyleSet styleSet, IDomNode node, ITextFlow output, ILayoutContext context) {
    RegionMatch match = intersect(node, context);
    boolean wsp = context.isWhitespacePreservation();
    boolean implied = node.getStyleClassifiers().contains(NodeClassifier.IMPLIED);

    // TODO: the combination of whitespacePreservation, implied-space AND regional formatting is not
    // tested - it implies a priori knowledge of the textual representation of a serialized model without
    // any source text nodes; and will probably in practice never be requested. (A serialization pass would
    // needed to get the text to figure out where nodes are...)
    //
    if(match.isInside()) {
      if(match.isContained() && (!wsp || implied)) {
        // format if contained and formatting is wanted, or the space is implied
        Spacing spacing = styleSet.getStyleValue(SpacingStyle.class, node, defaultSpacing);
        LineBreaks lineBreaks = styleSet.getStyleValue(LineBreakStyle.class, node, defaultLineBreaks);
        String text = styleSet.getStyleValue(TokenTextStyle.class, node);
        applySpacingAndLinebreaks(context, node, text, spacing, lineBreaks, output);
      }
      else {
        output.appendText(match.apply().getFirst());
      }
    }
  }
View Full Code Here


   * @param node
   * @param context
   * @return true if the node should be formatted and text produced
   */
  protected RegionMatch intersect(IDomNode node, ILayoutContext context) {
    return new RegionMatch(node, context.getRegionToFormat());
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.xtext.dommodel.RegionMatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.