Package org.jacoco.core.analysis

Examples of org.jacoco.core.analysis.ICounter


    sortColumn.getParent().setSortDirection(direction);
  }

  public int compare(Viewer viewer, Object e1, Object e2) {
    ICounterMode mode = settings.getCounterMode();
    ICounter c1 = mode.getCounter(CoverageTools.getCoverageInfo(e1));
    ICounter c2 = mode.getCounter(CoverageTools.getCoverageInfo(e2));
    int res = 0;
    switch (settings.getSortColumn()) {
    case CoverageView.COLUMN_ELEMENT:
      res = elementsorter.compare(viewer, e1, e2);
      break;
    case CoverageView.COLUMN_RATIO:
      res = Double.compare(c1.getCoveredRatio(), c2.getCoveredRatio());
      break;
    case CoverageView.COLUMN_COVERED:
      res = (int) (c1.getCoveredCount() - c2.getCoveredCount());
      break;
    case CoverageView.COLUMN_MISSED:
      res = (int) (c1.getMissedCount() - c2.getMissedCount());
      break;
    case CoverageView.COLUMN_TOTAL:
      res = (int) (c1.getTotalCount() - c2.getTotalCount());
      break;
    }
    if (res == 0) {
      res = elementsorter.compare(viewer, e1, e2);
    } else {
View Full Code Here


    sortColumn.getParent().setSortDirection(reverse ? SWT.DOWN : SWT.UP);
  }

  public int compare(Viewer viewer, Object e1, Object e2) {
    CounterEntity counters = settings.getCounters();
    ICounter c1 = CoverageTools.getCoverageInfo(e1).getCounter(counters);
    ICounter c2 = CoverageTools.getCoverageInfo(e2).getCounter(counters);
    int res = 0;
    switch (settings.getSortColumn()) {
    case CoverageView.COLUMN_ELEMENT:
      res = elementsorter.compare(viewer, e1, e2);
      break;
    case CoverageView.COLUMN_RATIO:
      res = Double.compare(c1.getCoveredRatio(), c2.getCoveredRatio());
      break;
    case CoverageView.COLUMN_COVERED:
      res = (int) (c1.getCoveredCount() - c2.getCoveredCount());
      break;
    case CoverageView.COLUMN_MISSED:
      res = (int) (c1.getMissedCount() - c2.getMissedCount());
      break;
    case CoverageView.COLUMN_TOTAL:
      res = (int) (c1.getTotalCount() - c2.getTotalCount());
      break;
    }
    if (res == 0) {
      res = elementsorter.compare(viewer, e1, e2);
    } else {
View Full Code Here

          ICoverageNode c = CoverageTools.getCoverageInfo(element);
          if (c == null || c.getInstructionCounter().getTotalCount() == 0) {
            return false;
          }
          if (settings.getHideUnusedTypes()) {
            ICounter cnt = c.getClassCounter();
            return cnt.getTotalCount() == 0 || cnt.getCoveredCount() != 0;
          }
          return true;
        }
      }
    });
View Full Code Here

   * @throws IOException
   */
  public static void writeCounters(final ICoverageNode node,
      final XMLElement parent) throws IOException {
    for (final CounterEntity counterEntity : CounterEntity.values()) {
      final ICounter counter = node.getCounter(counterEntity);
      if (counter.getTotalCount() > 0) {
        final XMLElement counterNode = parent.element("counter");
        counterNode.attr("type", counterEntity.name());
        writeCounter(counterNode, "missed", "covered", counter);
        counterNode.close();
      }
View Full Code Here

  /**
   * This method must be called exactly once after all instructions and
   * branches have been incremented for this method coverage node.
   */
  public void incrementMethodCounter() {
    final ICounter base = this.instructionCounter.getCoveredCount() == 0 ? CounterImpl.COUNTER_1_0
        : CounterImpl.COUNTER_0_1;
    this.methodCounter = this.methodCounter.increment(base);
    this.complexityCounter = this.complexityCounter.increment(base);
  }
View Full Code Here

    return DEFAULT_COUNTERS;
  }

  private void createCounterElement(final CounterEntity counterEntity)
      throws IOException {
    final ICounter counter = node.getCounter(counterEntity);

    final XMLElement counterNode = this.element("counter");
    counterNode.attr("type", counterEntity.name());
    counterNode
        .attr("covered", Integer.toString(counter.getCoveredCount()));
    counterNode.attr("notcovered", Integer.toString(counter
        .getNotCoveredCount()));

    counterNode.close();
  }
View Full Code Here

  private void cell(final HTMLElement tr, final ICoverageNode node)
      throws IOException {
    if (visible) {
      tr.td(); // extra column to allow alignment to the right
      final ICounter c = node.getCounter(entity);
      tr.td(Styles.CTR1).text(
          integerFormat.format(c.getNotCoveredCount())).text(" / ");
      tr.td(Styles.CTR2).text(integerFormat.format(c.getTotalCount()));
    }
  }
View Full Code Here

  }

  @Test
  public void testSimple1() throws Exception {
    instrument(Simple.class);
    final ICounter complexity = analyze();
    assertEquals(CounterImpl.getInstance(1, 0), complexity);
  }
View Full Code Here

  @Test
  public void testSimple2() throws Exception {
    instrument(Simple.class);
    target.test(0);
    final ICounter complexity = analyze();
    assertEquals(CounterImpl.getInstance(0, 1), complexity);
  }
View Full Code Here

        node.getSignature(), node.getSuperName(),
        node.getInterfaceNames());
    writer.write(className);

    for (final CounterEntity entity : COUNTERS) {
      final ICounter counter = node.getCounter(entity);
      writer.write(counter.getMissedCount());
      writer.write(counter.getCoveredCount());
    }

    writer.nextLine();
  }
View Full Code Here

TOP

Related Classes of org.jacoco.core.analysis.ICounter

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.