Package com.puppetlabs.xtext.dommodel.formatter.css

Examples of com.puppetlabs.xtext.dommodel.formatter.css.StyleSet$ImmutableStyleSet


  private static void appendEffectiveStyle(Appendable result, IDomNode node, String prefix) throws IOException {
    if(tracer == null) {
      result.append(" effective: [-off-]");
      return;
    }
    StyleSet effective = tracer.getEffectiveStyle(node);
    if(effective == null) {
      result.append(" effective: [null]");
      return;
    }
    if(prefix.length() != 0) {
      result.append("\n");
      result.append(prefix);
    }

    result.append(" effective: [");
    EffectiveStyleAppender styleAppender = new EffectiveStyleAppender(result);
    ArrayListMultimap<String, IStyle<?>> ruleToStyle = ArrayListMultimap.create();
    if(effective instanceof StyleSetWithTracking) {
      StyleSetWithTracking trackingSet = (StyleSetWithTracking) effective;
      for(IStyle<?> style : effective.getStyles()) {
        String n = trackingSet.getStyleSource(style).getRuleName();
        if(n == null || n.length() < 1)
          throw new RuntimeException("Rule without name");
        ruleToStyle.put(n, style);
      }
    }
    else {
      for(IStyle<?> style : effective.getStyles()) {
        ruleToStyle.put("(unknown source)", style);
      }
    }
    boolean firstSource = true;
    for(String source : ruleToStyle.keySet()) {
View Full Code Here


    return null;
  }

  protected IDomNode sequenceComposite(IDomNode node, ITextFlow output, ILayoutContext context,
      Predicate<IDomNode> include, Predicate<IDomNode> until) {
    final StyleSet styleSet = context.getCSS().collectStyles(node);
    tracer.recordEffectiveStyle(node, styleSet);

    final ILayoutManager layout = styleSet.getStyleValue(LayoutManagerStyle.class, node, defaultLayout);

    layout.beforeComposite(styleSet, node, output, context);
    // if layout of composite by layout manager returns true, children are already processed
    IDomNode last = null;
    if(!layout.format(styleSet, node, output, context))
View Full Code Here

    layout.afterComposite(styleSet, node, output, context);
    return last;
  }

  protected void sequenceLeaf(IDomNode node, ITextFlow output, ILayoutContext context) {
    final StyleSet styleSet = context.getCSS().collectStyles(node);
    tracer.recordEffectiveStyle(node, styleSet);

    final ILayoutManager layout = styleSet.getStyleValue(LayoutManagerStyle.class, node, defaultLayout);
    layout.format(styleSet, node, output, context);
  }
View Full Code Here

      grammarAccess.getUnquotedStringAccess().getDollarSignLeftCurlyBracketKeyword_1());
    final Selector interpolationEnd = Select.grammar(
      grammarAccess.getTextExpressionAccess().getRightCurlyBracketKeyword_1_3(), //
      grammarAccess.getUnquotedStringAccess().getRightCurlyBracketKeyword_3());

    final StyleSet resourceRightCurlyStyleNoDedent = StyleSet.withImmutableStyles(//
      styles.oneLineBreak(), //
      styles.noSpaceUnlessWrapped(), //
      styles.dedent(0));

    final StyleSet noSpaceUnlessWrappedNoLine = StyleSet.withImmutableStyles(
      styles.noSpaceUnlessWrapped(), styles.noLineBreak());
    // final StyleSet noSpaceNoLine = StyleSet.withImmutableStyles(styles.noSpace(), styles.noLineBreak());
    final StyleSet noSpaceOneLine = StyleSet.withImmutableStyles(
      styles.noSpaceUnlessWrapped(), styles.oneLineBreak());
    final StyleSet noSpaceOneLineOptionallyTwo = StyleSet.withImmutableStyles(
      styles.noSpaceUnlessWrapped(), styles.lineBreaks(1, 1, 2));
    final StyleSet noSpaceTwoLines = StyleSet.withImmutableStyles(
      styles.noSpaceUnlessWrapped(), styles.lineBreaks(2, 2, 2));
    final StyleSet oneSpaceNoLine = StyleSet.withImmutableStyles(styles.oneSpace(), styles.noLineBreak());
    final StyleSet oneOptionalSpaceNoLine = StyleSet.withImmutableStyles(//
      styles.oneSpace(), styles.noLineBreak());
    final StyleSet oneSpaceOneOptionalLine = StyleSet.withImmutableStyles(//
      styles.oneSpace(), styles.lineBreaks(0, 0, 1, true, true));

    DomCSS css = super.get();

    css.addRules(
View Full Code Here

            n.getStyleClassifiers().contains(NodeClassifier.LINESEPARATOR_TERMINATED)) {
          // comment breaks the line
          output.appendSpaces(1); // separate the comment with a space

          // format the comment with layout manager given by rules (or this layout by default)
          final StyleSet styleSet = context.getCSS().collectStyles(n);
          tracer.recordEffectiveStyle(node, styleSet);

          final ILayoutManager layout = styleSet.getStyleValue(LayoutManagerStyle.class, n, this);
          layout.format(styleSet, n, output, context);
          // do not process this comment again
          context.markConsumed(n);

          // comment counts as one linebreak
View Full Code Here

        styleSet.getStyleValue(DedentStyle.class, node, DEFAULT_0));
  }

  @Override
  public boolean format(IDomNode node, ITextFlow flow, ILayoutContext context) {
    StyleSet styleSet = context.getCSS().collectStyles(node);
    tracer.recordEffectiveStyle(node, styleSet);

    return format(styleSet, node, flow, context);
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.xtext.dommodel.formatter.css.StyleSet$ImmutableStyleSet

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.