Examples of MeasuredTextFlow


Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    // Step 1, must format up to the first case expression to know the correct indentation of the case
    // expression. (At point of entry to this method, the whitespace between a preceding statement and the case
    // expression has not yet been processed, and thus, no WS, break, indent etc. has taken place.
    //
    DelegatingLayoutContext dlc = new DelegatingLayoutContext(context);
    MeasuredTextFlow continuedFlow = new MeasuredTextFlow((MeasuredTextFlow) flow);

    int currentMaxWidth = flow.getPreferredMaxWidth();
    int availableWidth = 0; // set when first case is seen

    IBreakAndAlignAdvice advice = adviceProvider.get();
    final boolean doCompaction = advice.compactCasesWhenPossible();
    final boolean doAlignment = advice.isAlignCases();

    // used to collect the widths of each case's width of its values
    List<Integer> widths = Lists.newArrayList();
    // int maxLastLine = 0;
    boolean firstCaseSeen = false;
    List<IDomNode> colonNodes = Lists.newArrayList();
    IntegerCluster clusters = new IntegerCluster(20);
    boolean allCompactable = true; // until proven wrong
    for(IDomNode n : node.getChildren()) {
      if(n.getGrammarElement() == caseRuleCall) {
        if(!firstCaseSeen) {
          // finish measurement of the position the case will appear at
          //
          continuedFlow.appendBreak();
          continuedFlow.getIndentation();
          availableWidth = currentMaxWidth - (continuedFlow.getIndentation() + 1) *
              continuedFlow.getIndentSize();
        }
        // used to measure output of formatted case values
        // adjust its width to available width (and do not mark items consumed in the given context)
        DelegatingLayoutContext innerContext = new DelegatingLayoutContext(context, availableWidth);
        TextFlow measuredFlow = new TextFlow(innerContext);
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    // Step 1, must format up to the first selector entry expression to know the correct indentation of the selector entry
    // expression. (At point of entry to this method, the whitespace between a preceding statement and the selector
    // expression has not yet been processed, and thus, no WS, break, indent etc. has taken place.
    //
    DelegatingLayoutContext dlc = new DelegatingLayoutContext(context);
    MeasuredTextFlow continuedFlow = new MeasuredTextFlow((MeasuredTextFlow) flow);

    int currentMaxWidth = flow.getPreferredMaxWidth();
    int availableWidth = 0; // set when first case is seen

    // IBreakAndAlignAdvice advice = adviceProvider.get(); // TODO: Advice? this formatting ?
    final boolean doAlignment = true; // advice.isAlignCases();

    // used to collect the widths of each case's width of its values
    List<Integer> widths = Lists.newArrayList();
    // int maxLastLine = 0;
    boolean firstSelectoEntrySeen = false;
    List<IDomNode> fatCommaNodes = Lists.newArrayList();
    IntegerCluster clusters = new IntegerCluster(SELECTOR_EXPRESSION_CLUSTER_SIZE);
    for(IDomNode n : node.getChildren()) {
      if(n.getGrammarElement() instanceof RuleCall &&
          ((RuleCall) n.getGrammarElement()).getRule() == selectorEntryRule) {
        if(!firstSelectoEntrySeen) {
          // finish measurement of the position the selectorEntry will appear at
          //
          continuedFlow.appendBreak();
          continuedFlow.getIndentation();
          availableWidth = currentMaxWidth - (continuedFlow.getIndentation() + 1) *
              continuedFlow.getIndentSize();
        }
        // used to measure output of formatted selector entry values
        // adjust its width to available width (and do not mark items consumed in the given context)
        DelegatingLayoutContext innerContext = new DelegatingLayoutContext(context, availableWidth);
        TextFlow measuredFlow = new TextFlow(innerContext);
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    }
    if(compactResource && styles.contains(ResourceStyle.COMPACTABLE)) {
      // must check if rendering would overflow
      node.getStyleClassifiers().addAll(styles);
      DelegatingLayoutContext dlc = new DelegatingLayoutContext(context);
      MeasuredTextFlow continuedFlow = new MeasuredTextFlow((MeasuredTextFlow) flow);
      int heightBefore = continuedFlow.getHeight();
      feeder.sequence(node.getChildren(), continuedFlow, dlc, new FirstLeafWithTextAndTheRest(), untilTheEnd);
      if(continuedFlow.getHeight() - heightBefore > 2) {
        node.getStyleClassifiers().remove(ResourceStyle.COMPACTABLE);
      }
    }
    else {
      // the style is set on the container and is used in containment checks for resource bodies.
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertEquals("Should produce expected result", expected, "  " + CharSequences.trimLeft(s.getText()).toString());
  }

  @Test
  public void test_MeasuringTextStream() {
    MeasuredTextFlow flow = this.getInjector().getInstance(MeasuredTextFlow.class);
    appendSampleFlow(flow);
    assertSampleFlowMetrics(flow);
  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertSampleFlowMetrics(flow);
  }

  @Test
  public void test_MeasuringTextStreamEmpty() {
    MeasuredTextFlow flow = this.getInjector().getInstance(MeasuredTextFlow.class);
    appendSampleFlow(flow);
    assertSampleFlowMetrics(flow);
  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertSampleFlowMetrics(flow);
  }

  @Test
  public void test_MeasuringTextStreamOneLineNoBreak() {
    MeasuredTextFlow flow = this.getInjector().getInstance(MeasuredTextFlow.class);
    flow.appendText("123");
    assertFlowOneLineNoBreak(flow);
  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertFlowOneLineNoBreak(flow);
  }

  @Test
  public void test_Recording() {
    MeasuredTextFlow flow = this.getInjector().getInstance(TextFlowRecording.class);
    appendSampleFlow(flow);
    assertSampleFlowMetrics(flow);
  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertSampleFlowMetrics(flow);
  }

  @Test
  public void test_RecordingOneLineNoBreak() {
    MeasuredTextFlow flow = this.getInjector().getInstance(TextFlowRecording.class);
    flow.appendText("123");
    assertFlowOneLineNoBreak(flow);
  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertFlowOneLineNoBreak(flow);
  }

  @Test
  public void test_TextFlow() {
    MeasuredTextFlow flow = this.getInjector().getInstance(TextFlow.class);
    appendSampleFlow(flow);
    assertSampleFlowMetrics(flow);

  }
View Full Code Here

Examples of com.puppetlabs.xtext.textflow.MeasuredTextFlow

    assertEquals(5, flow.getWidthOfLastLine());
  }

  @Test
  public void test_TextFlowEmpty() {
    MeasuredTextFlow flow = this.getInjector().getInstance(TextFlow.class);
    appendSampleFlow(flow);
    assertSampleFlowMetrics(flow);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.