}
}
@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());
}
}
}